{"id":25105265,"url":"https://github.com/stanmiglight/lab3","last_synced_at":"2026-04-26T12:32:44.923Z","repository":{"id":264325133,"uuid":"878441935","full_name":"stanmiglight/Lab3","owner":"stanmiglight","description":"This project showcases using FastAPI to interact with an external API. It fetches data, processes it with Python, and returns structured JSON. It also demonstrates creating an endpoint that merges data from multiple external APIs.","archived":false,"fork":false,"pushed_at":"2025-01-30T04:49:45.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T08:16:38.483Z","etag":null,"topics":["fastapi","jsonplaceholder","python"],"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/stanmiglight.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":"2024-10-25T11:59:44.000Z","updated_at":"2025-01-30T04:58:31.000Z","dependencies_parsed_at":"2025-01-30T05:32:33.169Z","dependency_job_id":null,"html_url":"https://github.com/stanmiglight/Lab3","commit_stats":null,"previous_names":["stanmiglight/lab3"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stanmiglight/Lab3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stanmiglight","download_url":"https://codeload.github.com/stanmiglight/Lab3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32297895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","jsonplaceholder","python"],"created_at":"2025-02-07T22:52:59.835Z","updated_at":"2026-04-26T12:32:44.906Z","avatar_url":"https://github.com/stanmiglight.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# External API Integration with FastAPI\n\nThis project demonstrates how to interact with an external API using FastAPI. The goal is to fetch data from an external API, manipulate it using Python, and return the results in a structured JSON format. The project also includes an example of creating a new API endpoint that combines data from multiple external API calls.\n\n## Features\n\n- **FastAPI**: A modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python type hints.\n- **External API Integration**: Fetches data from [JSONPlaceholder](https://jsonplaceholder.typicode.com/) to retrieve posts and comments.\n- **Data Manipulation**: Processes and formats the data according to specific requirements.\n- **CRUD-like Operations**: Provides endpoints to retrieve posts, comments, and detailed user posts with associated comments.\n\n## Installation\n\n### Clone the repository:\n\n```bash\ngit clone https://github.com/yourusername/external-api-integration.git\ncd external-api-integration\n```\n\n### Set up a virtual environment (optional but recommended):\n\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\n```\n\n### Install dependencies:\n\n```bash\npip install fastapi uvicorn requests\n```\n\n### Run the application:\n\n```bash\nuvicorn main:app --reload\n```\n\nThe `--reload` flag enables auto-reloading, so the server will restart whenever you make changes to the code.\n\n## Usage\n\nOnce the server is running, you can access the API at `http://127.0.0.1:8000`.\n\n## Endpoints\n\n### 1. GET `/posts/`\n\n**Description**: Retrieve all posts or a specific post by `postId`.\n\n**Query Parameter:**\n\n- `postId` (optional): The ID of the post to retrieve.\n\n**Example Request:**\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/posts/\"\n```\n\nor\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/posts/?postId=1\"\n```\n\n**Example Response:**\n\n```json\n[\n  {\n    \"userId\": 1,\n    \"id\": 1,\n    \"title\": \"sunt aut facere repellat provident occaecati excepturi optio reprehenderit\",\n    \"body\": \"quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\"\n  }\n]\n```\n\n### 2. GET `/comments/`\n\n**Description**: Retrieve all comments or comments for a specific post by `postId`.\n\n**Example Request:**\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/comments/?postId=1\"\n```\n\n**Example Response:**\n\n```json\n[\n  {\n    \"postId\": 1,\n    \"id\": 1,\n    \"name\": \"id labore ex et quam laborum\",\n    \"email\": \"Eliseo@gardner.biz\",\n    \"body\": \"laudantium enim quasi est quidem magnam voluptate ipsam eos\\ntempora quo necessitatibus\\ndolor quam autem quasi\\nreiciendis et nam sapiente accusantium\"\n  }\n]\n```\n\n### 3. GET `/formatted_posts/{userID}`\n\n**Description**: Retrieve posts for a specific user and format the data.\n\n**Example Request:**\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/formatted_posts/1\"\n```\n\n**Example Response:**\n\n```json\n{\n  \"userID\": 1,\n  \"posts\": [\n    {\n      \"post_title\": \"sunt aut facere repellat provident occaecati excepturi optio reprehenderit\",\n      \"post_body\": \"quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\"\n    }\n  ]\n}\n```\n\n### 4. GET `/formatted_comment/{postID}`\n\n**Description**: Retrieve comments for a specific post and format the data.\n\n**Example Request:**\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/formatted_comment/1\"\n```\n\n**Example Response:**\n\n```json\n{\n  \"post_id\": 1,\n  \"comments\": [\n    {\n      \"commenter_email\": \"Eliseo@gardner.biz\",\n      \"commenter_name\": \"id labore ex et quam laborum\",\n      \"comment\": \"laudantium enim quasi est quidem magnam voluptate ipsam eos\\ntempora quo necessitatibus\\ndolor quam autem quasi\\nreiciendis et nam sapiente accusantium\"\n    }\n  ]\n}\n```\n\n### 5. GET `/detailed_post/{userID}`\n\n**Description**: Retrieve all posts for a specific user along with their associated comments.\n\n**Example Request:**\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/detailed_post/1\"\n```\n\n**Example Response:**\n\n```json\n{\n  \"userID\": 1,\n  \"posts\": [\n    {\n      \"post_title\": \"sunt aut facere repellat provident occaecati excepturi optio reprehenderit\",\n      \"post_body\": \"quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\",\n      \"comments\": [\n        {\n          \"commenter_name\": \"id labore ex et quam laborum\",\n          \"commenter_email\": \"Eliseo@gardner.biz\",\n          \"comment_body\": \"laudantium enim quasi est quidem magnam voluptate ipsam eos\\ntempora quo necessitatibus\\ndolor quam autem quasi\\nreiciendis et nam sapiente accusantium\"\n        }\n      ]\n    }\n  ]\n}\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n\n## Acknowledgments\n\n- **Sir Paulo** for the idea!\n- **FastAPI** for providing an easy-to-use and high-performance web framework.\n- **JSONPlaceholder** for providing a free fake API for testing and prototyping.\n- **Python** for being awesome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanmiglight%2Flab3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanmiglight%2Flab3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanmiglight%2Flab3/lists"}