{"id":19045462,"url":"https://github.com/marirs/fastapi-boilerplate","last_synced_at":"2025-08-21T18:33:31.111Z","repository":{"id":42669563,"uuid":"219757434","full_name":"marirs/fastapi-boilerplate","owner":"marirs","description":"fastAPI boilerplate for API based access along with user management","archived":false,"fork":false,"pushed_at":"2023-02-14T21:35:06.000Z","size":93,"stargazers_count":143,"open_issues_count":1,"forks_count":43,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-11T12:25:48.875Z","etag":null,"topics":["api","apikey","asyncio","boilerplate","fastapi","mongodb","motor","python3","user-management"],"latest_commit_sha":null,"homepage":null,"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/marirs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-11-05T13:55:02.000Z","updated_at":"2024-08-19T08:46:08.000Z","dependencies_parsed_at":"2024-11-08T22:50:20.250Z","dependency_job_id":"d194aa07-1f35-4af4-9109-8b20811bb8af","html_url":"https://github.com/marirs/fastapi-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Ffastapi-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Ffastapi-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Ffastapi-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marirs%2Ffastapi-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marirs","download_url":"https://codeload.github.com/marirs/fastapi-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230527866,"owners_count":18240051,"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":["api","apikey","asyncio","boilerplate","fastapi","mongodb","motor","python3","user-management"],"created_at":"2024-11-08T22:50:17.240Z","updated_at":"2024-12-20T03:10:04.660Z","avatar_url":"https://github.com/marirs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastAPI Biolerplate\n\nA FastAPI project!\n\n- Every endpoint should be accessed by an API key\n- API key has roles, such a way that, access to appropriate endpoints is allowed or denied\n- Multiple endpoint project\n- User management to create new users, disable users, verify email accounts and then allow api access, etc...\n- Connects to MongoDB\n\n![](docs/fastAPIboilerplate.png)\n\n---\n\nA Rust version can be found [here](https://github.com/marirs/rocketapi).\n\n---\n#### Requirements\n\n* fastAPI\n* Python 3.7+\n\n#### Lib Requirements\n\n* UVLoop\n* re2\n\n#### Database\n\n* MongoDB\n\n#### Setting up\n```\nmkvirtualenv --python=/usr/bin/python3 fastapi-boilerplate\ncd /path/to/project\nsetvirtualenvproject\n```\n\n#### Installing the requirements\n```\npip install pipenv\npipenv install\n```\nOR\n```\npip install -r requirements.txt\n```\n\n#### Creating the first user\n```\n$ ./first_user.py email@somemail.tld\nYour API Key is: _hplIyYGpeVKc... (Do not loose this key as its not stored in the system)\n```\n\n#### Running the Project in Dev env\n```\nuvicorn server.main:app --reload\n```\n\n#### Project Structure\n\n```\napi/endpoints - handlers for all endpoint routes\ncore          - general components like settings, security, key validation, etc...\ndb            - db connection specific\ndb/crud       - CRUD for types from models\nmodels        - pydantic models that used in crud or handlers\n```\n\n---\n#### Docs\n\nAccessing the \"user\" endpoint with non superuser account\n```\n$ curl -H'x-api-key: -OWN3pNZ6FsaPppPqsyeuF6sxe' -H'x-email-id: e@mail.tld' http://127.0.0.1:8000/api/user/ \n\n{\n    \"created_at\": \"2019-11-01T03:21:02.868000\",\n    \"updated_at\": \"2019-11-06T03:22:01.045000\",\n    \"email\": \"e@mail.tld\"\n}\n```\nAccessing the \"user\" endpoint with superuser account\n```\n$ curl -H'x-api-key: -OWN3pNZ6FsaPppPqsyeuF6sxe' -H'x-email-id: e@mail.tld' http://127.0.0.1:8000/api/user/ \n{\n    \"total_users\": 1,\n    \"users\": [\n        {\n            \"created_at\": \"2019-11-01T03:21:02.868000\",\n            \"updated_at\": \"2019-11-06T03:22:01.045000\",\n            \"email\": \"e@mail.tld\",\n            \"endpoint_access\": [\n                \"user\"\n            ],\n            \"is_superuser\": true,\n            \"is_active\": true,\n            \"disabled\": false,\n            \"hashed_api_key\": \"$2b$12$DJ2D249xR4MY.aeTODeq5OasBR8TUoxknjxX6WqLf1QoG1k7VWQim\",\n            \"salt\": \"$2b$12$lJ937UATRjcCU4.kk0HYZ.\"\n        }\n    ]\n}\n```\nAccessing the \"hello\" endpoint\n```\n$ curl -H'x-api-key: -OWN3pNZ6FsaPppPqsyeuF6sxe' -H'x-email-id: e@mail.tld' http://127.0.0.1:8000/api/hello/ \n\n\"Hello World\"\n```\nVerify an email account of an added API user account\n```\n$ curl http://127.0.0.1:8000/api/user/verify?email=marirs@gmail.com\n\n{\n    \"detail\": \"e@mail.tld is now verified! You can start using your API key.\"\n}\n```\nDisabling an email account\n```\n$ curl  -H'x-api-key: -OWN3pNZ6FsaPppPqsyeuF6sxe' -H'x-email-id: e@mail.tld' http://localhost:8000/api/user/disable?email=someone@gmail.com\n\n{\n    \"detail\": \"someone@gmail.com is disabled!\"\n}\n```\n---\nInitial Author: Sriram\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Ffastapi-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarirs%2Ffastapi-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarirs%2Ffastapi-boilerplate/lists"}