{"id":27531221,"url":"https://github.com/richardschoen/fastapimockserver","last_synced_at":"2026-05-04T21:34:57.080Z","repository":{"id":236840665,"uuid":"793256178","full_name":"richardschoen/fastapimockserver","owner":"richardschoen","description":"Python FastAPI Mock Server for Serving JSON and CSV Files as API Responses","archived":false,"fork":false,"pushed_at":"2024-05-04T14:31:53.000Z","size":78,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T05:25:24.355Z","etag":null,"topics":["as400","csv","csv-parser","fastapi","ibmi","json","json-server","mock","mock-server","mocking","python","rest","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richardschoen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-28T21:00:07.000Z","updated_at":"2024-07-27T22:21:21.000Z","dependencies_parsed_at":"2025-04-18T18:01:03.337Z","dependency_job_id":"e7b3b2ee-e5eb-4d45-b1fc-ffc0819aa1a8","html_url":"https://github.com/richardschoen/fastapimockserver","commit_stats":null,"previous_names":["richardschoen/fastapimockserver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Ffastapimockserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Ffastapimockserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Ffastapimockserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Ffastapimockserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richardschoen","download_url":"https://codeload.github.com/richardschoen/fastapimockserver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardschoen%2Ffastapimockserver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259239037,"owners_count":22826847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["as400","csv","csv-parser","fastapi","ibmi","json","json-server","mock","mock-server","mocking","python","rest","rest-api"],"created_at":"2025-04-18T17:49:17.810Z","updated_at":"2026-05-04T21:34:57.034Z","avatar_url":"https://github.com/richardschoen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python FastAPI Mock Server\n\nThis mock server project contains a very simple Python FastAPI Mock Server for Serving JSON and CSV Files as JSON API Responses.\n\nThe server can be used to serve up static JSON and CSV files as JSON responses. JSON and CSV files can also be queried using the JMESPath JSON query language. Or you can extend the server with your own API calls.\n\nA mock JSON and CSV server can be used for retrieving and querying sample CSV and JSON data while developing mobile or other applications that need to receive data and the app APIs are not fully defined yet. Simply compose some CSV or JSON data, place the files on the server and start serving up your mocked up data.\n\nThere are other tools out there such as Mockaroo, but often it's nice to have your own mock data server. And this was an interesting project to showcase how easy it is to get new APIs off the ground with FastAPI and Python.\n\n## Getting started\n\n### Clone repository\n\nClone the respository to a local directory.  Ex: `/fastapimockserver`\n\n```sh\ncd / # or elsewhere\ngit clone https://github.com/richardschoen/fastapimockserver\n```\n\n### Edit the Config File\n\nEdit the config file `config.cfg` and make sure the `mockdatadirectory` setting matches the location where you cloned the project.\n\nThe default location for mockjson data is: `/fastapimockserver/mockjson`\n\n### Create a virtual environment and activate it (if you want to use venv)\n\n```sh\npython -m venv my_venv --system-site-packages\n. my_venv/bin/activate\n```\n\n### Install the necessary support modules\n\n```sh\npip install uvicorn fastapi jmespath\n```\n\n### Start up the FastAPI server\n\nThe following script file will start the FastAPI server to monitor all IP addresses on port 3001.  \n\n```sh\ncd /fastapimockserver\nsh ./startapp.sh\n```\n\n## Initial API Test\n\n### Access the API for initial testing via OpenAPI\n`http://localhost:3001/api/docs`\n\nThis URL will display the OpenAPI documentation where APIs can also be tested.   \n\n![image](https://github.com/richardschoen/fastapimockserver/assets/9791508/56712793-3322-40b6-ad59-80a5261b9ada)\n\n### Access the API for initial testing with simple URL test \n\nEnter one of the following URLs to serve up a sample CSV and JSON file repectively.\nCSV files are converted on-the-fly to JSON before serving up results.\n\nSample states.csv file served up as JSON:  \n`http://localhost:3001/api/jsongetfile/states.csv`\n\nSample weather.json file served up as raw JSON content:  \n`http://localhost:3001/api/jsongetfile/weather.json`\n\nSample customers.json file served up as raw JSON content:  \n`http://localhost:3001/api/jsongetfile/customers.json`\n\n**If data is returned to yout browser as JSON, the server is working as expected.**\n\n## API Routes\n\n### Read CSV or JSON file and return as JSON via Get - /api/jsongetfile/{jsonfile}\n\nThis route is used to read and return a CSV or JSON file.\n\nParameters:\n```{jsonfile}``` - JSON or CSV file to serve up as JSON\n\nSample URL for states.csv file served up as JSON after GET:  \n`http://localhost:3001/api/jsongetfile/states.csv`\n\nSample URL for weather.json file served up as raw JSON content after GET:  \n`http://localhost:3001/api/jsongetfile/weather.json`\n\nSample URL for customers.json file served up as raw JSON content after GET:  \n`http://localhost:3001/api/jsongetfile/customers.json`\n\n### Query CSV or JSON file and return as JSON via Get - /api/jsonqueryfile/{jsonfile}/{jmescriteria}\n\nThis route is used to read and return a CSV or JSON file.\n\nParameters:\n`{jsonfile}` - JSON or CSV file to serve up as JSON.  Ex: `states.csv`\n`{jmescriteria}` - JMESPath Query language criteria. ? encoded as `%3F`\nEx state abbreviation=MN: `data[%3FAbbreviation=='MN']`\n\nSample URL for states.csv file queried for state abbreviation = 'MN' served up as after GET:  \n`http://localhost:3001/api/jsonqueryfile/states.csv/data[%3FAbbreviation=='MN']`  \n\n### Read CSV or JSON file and return as JSON via Post - /api/jsongetfile\n\nThis route is used to read and return a CSV or JSON file.\n\nParameters are posted via JSON in the request body.\n\nContent type for post should be:\n`application/json`\n\nParameters:\n`{jsonfile}` - JSON or CSV file to serve up as JSON\n\nSample JSON post body:\n\n```json\n{\n\"jsonfile\":\"states.csv\"\n}\n```\n\nSample URL for states.csv file served up as JSON after POST:  \n`http://localhost:3001/api/jsongetfile`\n\n### Query CSV or JSON file and return as JSON via Post - /api/jsonqueryfile\n\nThis route is used to query a CSV or JSON file and return results as JSON.  \n\nParameters are posted via JSON in the request body.\n\nContent type for post should be:\n`application/json`\n\nParameters:\n`{jsonfile}` - JSON or CSV file to serve up as JSON.\n`{jmescriteria}` - JMESPath Query language criteria.\nEx state abbreviation=MN: `data[Abbreviation=='MN']`\n\nSample JSON post body:\n\n```json\n{\n\"jsonfile\":\"states.csv\",   \n\"jmescriteria\":\"data[?Abbreviation=='MN']\"   \n}\n```\n\nSample URL for states.csv file queried for state abbreviation = 'MN' served up as JSON after POST:  \n`http://localhost:3001/api/jsonqueryfile`\n\n### Adding Additional JSON or CSV Files to the Mock Server\n\nIf you have other JSON or CSV files you want to serve up with the mock server, place them in the correct mockdatadirectory.\nIn our example the mockdatadirectory is: `/fastapimockserver/mockjson`\n\n### More info on FastAPI\n\nFastAPI Home Page  \n\u003chttps://fastapi.tiangolo.com\u003e\n\nHow to install Python FastAPI Web Framework and Get Started on IBM i  \n\u003chttps://github.com/richardschoen/howtostuff/blob/master/installpythonfastapi.md\u003e\n\nJMESPath query language for JSON tutorial  \n\u003chttps://jmespath.org/tutorial.html\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardschoen%2Ffastapimockserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichardschoen%2Ffastapimockserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardschoen%2Ffastapimockserver/lists"}