{"id":20139276,"url":"https://github.com/harryho/flat-api","last_synced_at":"2025-04-09T18:22:23.719Z","repository":{"id":57430914,"uuid":"98087328","full_name":"harryho/flat-api","owner":"harryho","description":"A zero-coding and zero-configuration restful fake API for developers","archived":false,"fork":false,"pushed_at":"2017-09-19T13:46:31.000Z","size":54,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T20:22:31.703Z","etag":null,"topics":["flask","json","json-api","json-server","python","zero-coding"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harryho.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-23T09:22:14.000Z","updated_at":"2024-07-22T09:14:45.000Z","dependencies_parsed_at":"2022-08-28T22:11:37.302Z","dependency_job_id":null,"html_url":"https://github.com/harryho/flat-api","commit_stats":null,"previous_names":["harryho/pseu-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harryho%2Fflat-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harryho%2Fflat-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harryho%2Fflat-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harryho%2Fflat-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harryho","download_url":"https://codeload.github.com/harryho/flat-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085710,"owners_count":21045197,"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":["flask","json","json-api","json-server","python","zero-coding"],"created_at":"2024-11-13T21:44:37.888Z","updated_at":"2025-04-09T18:22:23.690Z","avatar_url":"https://github.com/harryho.png","language":"Python","readme":"FlatApi\n----\n\n|Build Status| |Coverage| |Version|\n\nFlatApi is a **zero coding** and **zero configuration** restful API server inspired by Json-Server_ and Eve_. It is designed to be used as fake restful api for development, especially for people want to use Python stack. Setup process is **less than 10 seconds**. \n\n\nFlatApi is:\n\n- **Zero coding and configuration to setup Restful API** FlatApi is designed to use without coding and configuration by default. You just need one config to setup all endpoints you need, then you can use it immediately. \n\n- **Flask based web server** FlatApi is built on the top of _Flask\n\n- **Json flat file database** FlatApi uses FlatApi_ to manage the Json flat file database. FlatApi is a document oriented database. \n\n- **Caching memory storage availble** FlatApi supports caching momery storage after version 4.0.0. \n\nInstall Package\n***************\n\n.. code-block:: bash\n\n    $ pip uninstall flatapi\n    $ pip install --no-cache-dir flatapi\n\n\nQuick Start\n***********\n\n- Launch FlatApi without configuration\n\n.. code-block:: bash\n\n    # Start the FlatApi - Sample 1 \n    $ python3 /\u003cpath_to_package\u003e/flatapi -S MEMORY -G NO\n    # Start the FlatApi - Sample 2\n    $ python3 /\u003cpath_to_package\u003e/flatapi --storage MEMORY -cfgfile NO\n    # Start the FlatApi with prefix - Sample 3\n    $ python3 /\u003cpath_to_package\u003e/flatapi --storage memory -cfgfile no -X api\n\n.. code-block:: bash\n\n    \\(^_^)/ Hi\n\n    Loading  is done.\n\n    There is no config file found. Flat Api uses internal configuration.\n\n    Resource :\n    /\u003cstring:doc\u003e -- The doc is the collection name\n                        you want to post or put the object.\n    /\u003cstring:doc\u003e/\u003cint:id\u003e --The id is the unique id for query or delete.\n\n    Database: Memory\n\n    * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n\n- Test api via postman \n\n    It would be a much more handy and easy way to play around with the API immediately.\n\n.. code-block:: bash\n\n    GET /posts       --\u003e Get all posts\n    POST /posts      --\u003e Add new post\n    PUT /posts/1     --\u003e Update existing post which id is 1\n    DELETE /posts/1  --\u003e Delete a post which id is 1\n    DELETE /posts    --\u003e Delete all posts\n\n- Test api via curl \n\n.. code-block:: bash\n\n    # Add a new post\n    $ curl -d \"{\\\"text\\\":\\\"post 1\\\",\\\"author\\\":\\\"harry\\\"}\" -H \"Content-Type: application/json\" -X POST http://localhost:5000/posts\n    {\"author\": \"harry\", \"text\": \"post 1\", \"id\": 1}\n\n    # Get post by Id\n    $ curl -X GET http://localhost:5000/posts/1\n    {\"author\": \"harry\", \"text\": \"post 1\", \"id\": 1}\n    \n    # Get all posts\n    $ curl -X GET http://localhost:5000/posts\n    [{\"author\": \"harry\", \"text\": \"post 1\", \"id\": 1}]\n\n    # Update  the post\n    $ curl -d \"{\\\"text\\\":\\\"post updated\\\",\\\"author\\\":\\\"harry\\\"}\" -H \"Content-Type: application/json\" -X PUT http://localhost:5000/posts/1\n    [{\"author\": \"harry\", \"text\": \"post updated\", \"id\": 1}]\n\n    # Delete \n    $ curl -X DELETE http://localhost:5000/posts \n\n\n\nCustom Configuration\n********************\n\n- Create config.json as sample below (There is a sample in the repo as well)\n\n.. code-block:: json\n\n    {\n        \"db\": \"db.json\",\n        \"routes\":[\n            \"/posts\",\n            \"/comments\"\n        ]\n    }\n\n- Launch FlatApi. Please make sure the config.json is under current diretory\n\n.. code-block:: bash\n    \n    $ python3 /\u003cpath_to_package\u003e/flatapi \n\n     \\(^_^)/ Hi\n\n    Loading config.json is done.\n\n    Resource :\n    /posts\n    /comments\n\n    Database: db.json\n\n    * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n\n\n\n\nAdvanced usage\n**************\n\n- **Change default port**\n\n.. code-block:: bash\n\n    $ python3 flatapi -P 4999\n    ...\n    * Running on http://127.0.0.1:4999/ (Press CTRL+C to quit)\n\n- **Add prefix to the API via config.json**\n\n.. code-block:: json\n\n    {\n        \"db\":\"db.json\",\n        \"prefix\": \"api\",\n        \"routes\":[\n            \"/posts\",\n            \"/comments\"\n        ]\n    }\n\n- API changes as follows\n\n.. code-block:: bash\n\n    GET /api/posts       --\u003e Get all posts\n    GET /api/posts/1     --\u003e Get the post which id is 1\n    POST /api/posts      --\u003e Add new post\n    PUT /api/posts/1     --\u003e Update existing post which id is 1\n    DELETE /api/posts/1  --\u003e Delete a post which id is 1\n    DELETE /api/posts    --\u003e Delete all posts\n\n- **Advanced queries**\n\n\n- Create sample test data in db.json\n\n.. code-block:: json\n\n    {\n        \"posts\": [{\n            \"author\": \"harry\",\n            \"text\": \"post 1\",\n            \"id\": 1,\n            \"recommended\": 4\n        }],\n        \"comments\": [{\n            \"postId\": 1,\n            \"commentator\": \"john\",\n            \"text\": \"comment  1\",\n            \"id\": 1\n        }]\n    }\n\n- Use built-in embed route setting to retrieve children objects. It is inspired by Json-Server.\n\n.. code-block:: bash\n\n    GET /posts/1/comments\n\n\n- Following is query result\n\n.. code-block:: json\n\n    {\n        \"author\": \"harry\",\n        \"comments\": [\n            {\n                \"postId\": 1,\n                \"commentator\": \"john\",\n                \"text\": \"comment  1\",\n                \"id\": 1\n            }\n        ],\n        \"text\": \"post 1\",\n        \"id\": 1,\n        \"recommended\": 4\n    }\n\n\n-  Use expand to retrieve parent objects\n\n.. code-block:: bash\n\n    GET /comments/1?expand=posts\n\n\n- Following is query result\n\n\n.. code-block:: json\n          \n    {\n        \"postId\": 1,\n        \"commentator\": \"john\",\n        \"post\": {\n            \"author\": \"harry\",\n            \"text\": \"post 1\",\n            \"id\": 1\n        },\n        \"text\": \"comment  1\",\n        \"id\": 1,\n        \"recommended\": 4\n    }\n\n- Use query string to retrieve the objects\n\n.. code-block:: bash\n\n    GET /posts?author=harry\n\n\n- Following is query result \n\n\n.. code-block:: json\n\n    {\n        \"author\": \"harry\",\n        \"text\": \"post 1\",\n        \"id\": 1,\n        \"recommended\": 4\n    }\n\n- Use `_like` to retrieve the objects\n\n.. code-block:: bash\n\n    GET /posts?text_like=4\n\n\n- Following is query result \n\n\n.. code-block:: json\n\n    {\n        \"author\": \"harry\",\n        \"text\": \"post 1\",\n        \"id\": 1,\n        \"recommended\": 4\n    }\n\n- Use `_gte`, `_gt`, `_lt`, `_lte` to retrieve the objects\n\n.. code-block:: bash\n\n    GET /posts?recommended_gte=4\n\n\n- Following is query result \n\n.. code-block:: json\n\n    {\n        \"author\": \"harry\",\n        \"text\": \"post 1\",\n        \"id\": 1,\n        \"recommended\": 4\n    }\n\n- **Use caching momery storage**\n\n- Use following config to launch the api with caching memory storage.  \n\n.. code-block:: json\n\n    {\n        \"storage\": \"MEMORY\",\n        \"routes\":[\n            \"/posts\",\n            \"/comments\"\n        ]\n    }   \n\n\n\n\n.. |Build Status| image:: https://travis-ci.org/harryho/flat-api.svg?branch=master\n    :target: https://travis-ci.org/harryho/flat-api\n.. |Coverage| image:: https://coveralls.io/repos/github/harryho/flat-api/badge.svg?branch=master\n    :target: https://coveralls.io/github/harryho/flat-api?branch=master\n\n.. |Version| image:: https://badge.fury.io/py/flatapi.svg\n    :target: https://badge.fury.io/py/flatapi\n\n.. _Flask: http://flask.pocoo.org/\n.. _Eve: http://python-eve.org/\n.. _Json-Server: https://github.com/typicode/json-server\n.. _FlatApi: https://github.com/harryho/flata\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharryho%2Fflat-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharryho%2Fflat-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharryho%2Fflat-api/lists"}