{"id":20704413,"url":"https://github.com/nabind47/fastapi","last_synced_at":"2025-12-25T04:13:15.475Z","repository":{"id":189718239,"uuid":"681170491","full_name":"nabind47/fastapi","owner":"nabind47","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-21T12:27:57.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T20:13:30.110Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/nabind47.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}},"created_at":"2023-08-21T12:26:19.000Z","updated_at":"2023-08-21T12:26:28.000Z","dependencies_parsed_at":"2023-08-21T14:00:05.328Z","dependency_job_id":"962bc686-70df-4a41-b8a2-106a15bfd192","html_url":"https://github.com/nabind47/fastapi","commit_stats":null,"previous_names":["unique201347/fastapi","nabind47/fastapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabind47%2Ffastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabind47%2Ffastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabind47%2Ffastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabind47%2Ffastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabind47","download_url":"https://codeload.github.com/nabind47/fastapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242973963,"owners_count":20215245,"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":[],"created_at":"2024-11-17T01:12:14.276Z","updated_at":"2025-12-25T04:13:10.449Z","avatar_url":"https://github.com/nabind47.png","language":"Python","readme":"![FastAPI](https://images.datacamp.com/image/upload/v1664210695/A_simple_API_architecture_design_f98bfad9ce.png)\n\n```sh\npython -m venv venv\nsource venv/bin/activate\n```\n\n```sh\npip install fastapi uvicorn\n\npip freeze \u003e requirements.txt\npip install -r requirements.txt\n```\n\n```py\nfrom fastapi import FastAPI\n\napp = FastAPI()\n\n\n@app.get(\"/\")\nasync def root():\n    return {\"message\": \"Hello World\"}\n```\n\n```sh\nuvicorn main:app --reload\n```\n\n---\n\n```py\nfrom typing import Optional\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\nclass Item(BaseModel):\n    name: str\n    description: Optional[str] = None\n    price: float\n    tax: Optional[float] = None\n\napp = FastAPI()\n\n@app.post(\"/items/\")\nasync def create_item(item: Item):\n    item_dict = item.dict()\n    if item.tax:\n        price_with_tax = item.price + item.tax\n        item_dict.update({\"price_with_tax\": price_with_tax})\n    return item_dict\n```\n\n```py\nfrom typing import Optional\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\nclass Item(BaseModel):\n    name: str\n    description: Optional[str] = None\n    price: float\n    tax: Optional[float] = None\n\napp = FastAPI()\n\n@app.put(\"/items/{item_id}\")\nasync def create_item(item_id: int, item: Item):\n    return {\"item_id\": item_id, **item.dict()}\n\n```\n\n```py\nimport pymongo\nimport json\n\n# Connect to MongoDB\nclient = pymongo.MongoClient(\"mongodb://localhost:27017/\")\ndb = client[\"courses\"]\ncollection = db[\"courses\"]\n\n# Read courses from courses.json\nwith open(\"courses.json\", \"r\") as f:\n    courses = json.load(f)\n\n# Create index for efficient retrieval\ncollection.create_index(\"name\")\n\n# add rating field to each course\nfor course in courses:\n    course['rating'] = {'total': 0, 'count': 0}\n\n# add rating field to each chapter\nfor course in courses:\n    for chapter in course['chapters']:\n        chapter['rating'] = {'total': 0, 'count': 0}\n\n# Add courses to collection\nfor course in courses:\n    collection.insert_one(course)\n\n# Close MongoDB connection\nclient.close()\n```\n\n\u003e [**Documentation**](https://fastapi.tiangolo.com/tutorial/first-steps/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabind47%2Ffastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabind47%2Ffastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabind47%2Ffastapi/lists"}