{"id":19394431,"url":"https://github.com/ruanbekker/python-fastapi-restapi-basic","last_synced_at":"2026-04-30T08:41:01.686Z","repository":{"id":139707030,"uuid":"425448425","full_name":"ruanbekker/python-fastapi-restapi-basic","owner":"ruanbekker","description":"Basic Example using Python FastAPI","archived":false,"fork":false,"pushed_at":"2022-03-04T07:44:12.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T09:56:42.380Z","etag":null,"topics":["api","docker","docker-compose","fastapi","python","redoc","swagger"],"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/ruanbekker.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}},"created_at":"2021-11-07T09:17:26.000Z","updated_at":"2024-05-30T14:46:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"5c59d0d3-1f35-48d5-a3a1-9ae429b6195e","html_url":"https://github.com/ruanbekker/python-fastapi-restapi-basic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ruanbekker/python-fastapi-restapi-basic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruanbekker%2Fpython-fastapi-restapi-basic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruanbekker%2Fpython-fastapi-restapi-basic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruanbekker%2Fpython-fastapi-restapi-basic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruanbekker%2Fpython-fastapi-restapi-basic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruanbekker","download_url":"https://codeload.github.com/ruanbekker/python-fastapi-restapi-basic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruanbekker%2Fpython-fastapi-restapi-basic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285028340,"owners_count":27102545,"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","status":"online","status_checked_at":"2025-11-18T02:00:05.759Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","docker","docker-compose","fastapi","python","redoc","swagger"],"created_at":"2024-11-10T10:32:52.088Z","updated_at":"2026-04-30T08:41:01.679Z","avatar_url":"https://github.com/ruanbekker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-fastapi-restapi-basic\n\nBasic Example using Python FastAPI\n\n## About\n\nThis is a example using fastapi using python directly or using docker-compose.\n\n## Getting Started\n\n### Docker\n\nBuild:\n\n```bash\n$ docker-compose build\n```\n\nStart:\n\n```bash\n$ docker-compose up\n```\n\n### Non-Docker\n\nCreate a virtual environment:\n\n```bash\n$ python3 -m pip install virtualenv\n$ python3 -m virtualenv -p python3 .venv\n$ source .venv/bin/activate\n```\n\nInstall dependecies:\n\n```bash\n$ python3 -m pip install -r requirements.pip\n```\n\n### Tests\n\nRun tests using pytest:\n\n```bash\n$ pytest \n=============================================== test session starts ===============================================\nplatform darwin -- Python 3.7.12, pytest-7.0.1, pluggy-1.0.0\nrootdir: /Users/ruan/git/python-fastapi-restapi-basic\nplugins: anyio-3.3.4\ncollected 1 item                                                                                                  \n\ntests/test_main.py .                                                                                    [100%]\n\n================================================ 1 passed in 0.30s ================================================\n```\n\n### Start the Server\n\nStart the application:\n\n```bash\n$ hypercorn main:app --reload\n```\n\n## API Usage\n\nSeed the in-memory database:\n\n```bash\n$ curl -XPOST http://localhost:8000/seed\n{\"msg\":\"seeded 3 users\"}\n```\n\nGet all the students:\n\n```bash\n$ curl -s http://localhost:8000/students\n[\n  {\n\t\"userid\":\"ruanb\",\n\t\"email\":\"ruanb@localhost\"\n  },\n  {\n\t\"userid\":\"jamesd\",\n\t\"email\":\"jamesd@localhost\"\n  },\n  {\n\t\"userid\":\"deant\",\n\t\"email\":\"deant@localhost\"\n  }\n]\n```\n\nGet a single student:\n\n```bash\n$ curl -s http://localhost:8000/students/ruanb\n[{\"userid\":\"ruanb\",\"email\":\"ruanb@localhost\"}]\n```\n\nRegister a student:\n\n```bash\n$ curl -XPOST -H 'Content-Type: application/json' http://localhost:8000/students -d '{\"userid\": \"frankp\", \"email\": \"frankp@localhost\"}'\n{\"userid\":\"frankp\",\"email\":\"frankp@localhost\"}\n```\n\nUpdate a student:\n\n```bash\n$ curl -s -H \"Content-Type: application/json\" -XPUT http://localhost:8000/students/ruanb -d '{\"userid\":\"ruanb\", \"email\":\"ruan.bekker@localhost\"}'\n```\n\nDelete a student:\n\n```bash\n$ curl -XDELETE http://localhost:8000/students/ruanb\n{\"msg\":\"deleted ruanb\"}\n```\n\n## API Documentation\n\nIf you head over to http://localhost:8000/docs you will get to the [Swagger](https://github.com/swagger-api) UI:\n\n![image](https://user-images.githubusercontent.com/567298/140638024-1b466b91-ff71-462c-a876-9ae59274099f.png)\n\nIf you head over to http://localhost:8000/redoc you will get to the [Redoc](https://github.com/Redocly/redoc) UI:\n\n![image](https://user-images.githubusercontent.com/567298/142222509-87a12ccd-f0a1-4b28-ad5b-5eb1ddc5d744.png)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruanbekker%2Fpython-fastapi-restapi-basic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruanbekker%2Fpython-fastapi-restapi-basic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruanbekker%2Fpython-fastapi-restapi-basic/lists"}