{"id":31646794,"url":"https://github.com/bishaldebroy007/fast-api-practice-part-1","last_synced_at":"2026-05-18T03:02:49.148Z","repository":{"id":317588257,"uuid":"1068051345","full_name":"bishaldebroy007/fast-api-practice-part-1","owner":"bishaldebroy007","description":"Just the first step towards working with Fast API","archived":false,"fork":false,"pushed_at":"2025-10-01T19:47:51.000Z","size":9152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-10T22:40:05.471Z","etag":null,"topics":["fastapi","python3"],"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/bishaldebroy007.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-01T19:27:49.000Z","updated_at":"2025-10-01T19:48:52.000Z","dependencies_parsed_at":"2025-10-01T21:37:58.630Z","dependency_job_id":null,"html_url":"https://github.com/bishaldebroy007/fast-api-practice-part-1","commit_stats":null,"previous_names":["bishaldebroy007/fast-api-practice-part-1"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bishaldebroy007/fast-api-practice-part-1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bishaldebroy007%2Ffast-api-practice-part-1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bishaldebroy007%2Ffast-api-practice-part-1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bishaldebroy007%2Ffast-api-practice-part-1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bishaldebroy007%2Ffast-api-practice-part-1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bishaldebroy007","download_url":"https://codeload.github.com/bishaldebroy007/fast-api-practice-part-1/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bishaldebroy007%2Ffast-api-practice-part-1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"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":["fastapi","python3"],"created_at":"2025-10-07T05:56:08.071Z","updated_at":"2026-05-18T03:02:49.112Z","avatar_url":"https://github.com/bishaldebroy007.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI CRUD API - Learning Project\nA simple FastAPI application demonstrating basic CRUD (Create, Read, Update, Delete) operations with an in-memory data store.\n## Environment Setup\n\nTo create a virtual environment(linux):\n```bash\npython3 -m venv venv\n```\n\nTo activate that:\n\n```bash\nsource venv/bin/activate\n```\n\nOptional (this is kind of package.json in javascript projects)\n\n```bash\npip freeze \u003e requirements.txt\n```\n\n\n\n## Code Overview\nThis is a basic REST API built with FastAPI that manages a collection of items with `id`, `name`, and `origin` properties.\n\n## Dependencies\n\n```python\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom typing import List\n```\n\n- FastAPI: The web framework for building APIs.\n- Pydantic: Data validation using Python type annotations.\n- typing.List: Type hints for lists\n\n## Data Model\n\n```python\nclass Home_Class(BaseModel):\n    id: int\n    name: str\n    origin: str\n```\nThe `Home_Class` uses Pydantic's `BaseModel` for automatic validation and serialization of incoming/outgoing data.\n\n## In-Memory Storage\n\n```python\ndata: List[Home_Class] = []\n```\nData is stored in memory (will reset when the server restarts).\n\n## API Endpoints\n\n### 1. Root Endpoint\n\n- Method: GET\n- Path: /\n- Purpose: Welcome message\n- Response: {\"message\": \"Welcome to the API!\"}\n\n### 2. Get All Items\n\n- Method: GET\n- Path: /about\n- Purpose: Retrieve all items from the data store\n- Response: List of all items\n\n### 3. Create New Item\n\n- Method: POST\n- Path: /about\n- Purpose: Add a new item to the data store\n- Request Body:\n\n```python\n  {\n    \"id\": 1,\n    \"name\": \"Example\",\n    \"origin\": \"Location\"\n  }\n```\n- Response: The created item\n- Note: There's a bug in the original code - it should be data.append(tea) not data.append(data)\n\n### 4. Update Item\n\n- Method: PUT\n- Path: /about/{home_id}\n- Purpose: Update an existing item by ID\n- Path Parameter: home_id (int)\n- Request Body: Updated item data\n- Response: Updated item or error message\n\n### Delete Item\n\n- Method: DELETE\n- Path: /about/{home_id}\n- Purpose: Delete an item by ID\n- Path Parameter: home_id (int)\n- Response: Success message or error message.\n\n## Running the Application\n\n```python\n# Install FastAPI and uvicorn\npip install fastapi uvicorn\n\n# Run the server\nuvicorn filename:app --reload\n```\n\nReplace `filename` with your Python file name (without .py extension).\n\n\n## Testing the API\n\nOnce running, you can access:\n\n- Interactive API docs: http://127.0.0.1:8000/docs (Swagger UI)\n- Alternative docs: http://127.0.0.1:8000/redoc (ReDoc)\n\n## Important Notes\n\n- Bug in POST endpoint: The line `data.append(data)` should be `data.append(data)` to correctly add the new item.\n- Data Persistence: Data is stored in memory only. It will be lost when the server restarts. For persistence, you'd need to use a database.\n\n## Key Learning Points\n\n1. FastAPI decorators (`@app.get()`, `@app.post()`, etc.) define routes\n2. Pydantic models automatically validate request/response data\n3. Path parameters are defined in the route path (e.g., `{home_id}`)\n4. Type hints make the code more readable and enable automatic validation\n5. In-memory storage is simple but not production-ready\n\n## Next Steps for Learning\n\n- Add query parameters for filtering\n- Implement proper error handling with HTTP status codes\n- Connect to a database (SQLAlchemy)\n- Add authentication and authorization\n- Learn about FastAPI's dependency injection system\n- Explore async/await for database operations\n\n# Reference\n\n- [YouTube](https://youtu.be/foGklduxhM0?si=QIsip5EKq8IeODVJ)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbishaldebroy007%2Ffast-api-practice-part-1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbishaldebroy007%2Ffast-api-practice-part-1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbishaldebroy007%2Ffast-api-practice-part-1/lists"}