{"id":25105264,"url":"https://github.com/stanmiglight/lab2","last_synced_at":"2026-05-15T13:06:47.738Z","repository":{"id":264325134,"uuid":"873022699","full_name":"stanmiglight/Lab2","owner":"stanmiglight","description":"This FastAPI web service manages a simple user database, supporting CRUD operations for users identified by a user_id and a name.","archived":false,"fork":false,"pushed_at":"2025-01-30T04:30:14.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T08:16:38.084Z","etag":null,"topics":["fastapi","pydantic","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-15T13:29:53.000Z","updated_at":"2025-01-30T04:59:19.000Z","dependencies_parsed_at":"2025-01-30T05:32:31.137Z","dependency_job_id":null,"html_url":"https://github.com/stanmiglight/Lab2","commit_stats":null,"previous_names":["stanmiglight/lab2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stanmiglight/Lab2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stanmiglight","download_url":"https://codeload.github.com/stanmiglight/Lab2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanmiglight%2FLab2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278722761,"owners_count":26034461,"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-10-07T02:00:06.786Z","response_time":59,"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","pydantic","python"],"created_at":"2025-02-07T22:52:59.798Z","updated_at":"2025-10-07T04:57:29.844Z","avatar_url":"https://github.com/stanmiglight.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# User Management API\n\nThis is a FastAPI-based web service for managing a simple user database. The API allows you to perform CRUD (Create, Read, Update, Delete) operations on a list of users. Each user has a `user_id` and a `name`.\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- **CRUD Operations**: The API supports creating, reading, updating, and deleting users.\n- **Pydantic Models**: Uses Pydantic for data validation and serialization.\n- **Error Handling**: Provides appropriate error messages for invalid operations (e.g., user not found, duplicate user ID).\n\n## Installation\n\n### Clone the repository:\n\n```bash\ngit clone https://github.com/yourusername/user-management-api.git\ncd user-management-api\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 pydantic\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](http://127.0.0.1:8000).\n\n## Endpoints\n\n### 1. `GET /users`\n**Description**: Retrieve all users or a specific user by `user_id`.\n\n**Query Parameter**:\n- `user_id` (optional): The ID of the user to retrieve.\n\n**Example Request:**\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/users\"\n```\n\nor\n\n```bash\ncurl -X GET \"http://127.0.0.1:8000/users?user_id=1\"\n```\n\n**Example Response:**\n\n```json\n{\n  \"status\": \"ok\",\n  \"result\": [\n    {\"user_id\": 1, \"name\": \"John Doe\"},\n    {\"user_id\": 2, \"name\": \"Jane Smith\"},\n    {\"user_id\": 3, \"name\": \"Alice Johnson\"}\n  ]\n}\n```\n\nor\n\n```json\n{\n  \"status\": \"ok\",\n  \"result\": {\"user_id\": 1, \"name\": \"John Doe\"}\n}\n```\n\n### 2. `POST /users`\n**Description**: Create a new user.\n\n**Request Body:**\n\n```json\n{\n  \"user_id\": 4,\n  \"name\": \"New User\"\n}\n```\n\n**Example Request:**\n\n```bash\ncurl -X POST \"http://127.0.0.1:8000/users\" -H \"Content-Type: application/json\" -d '{\"user_id\": 4, \"name\": \"New User\"}'\n```\n\n**Example Response:**\n\n```json\n{\n  \"status\": \"ok\",\n  \"result\": {\"user_id\": 4, \"name\": \"New User\"}\n}\n```\n\n### 3. `PUT /users/{user_id}`\n**Description**: Update an existing user by `user_id`.\n\n**Path Parameter:**\n- `user_id`: The ID of the user to update.\n\n**Request Body:**\n\n```json\n{\n  \"user_id\": 1,\n  \"name\": \"Updated Name\"\n}\n```\n\n**Example Request:**\n\n```bash\ncurl -X PUT \"http://127.0.0.1:8000/users/1\" -H \"Content-Type: application/json\" -d '{\"user_id\": 1, \"name\": \"Updated Name\"}'\n```\n\n**Example Response:**\n\n```json\n{\n  \"status\": \"ok\",\n  \"updated_data\": {\"user_id\": 1, \"name\": \"Updated Name\"}\n}\n```\n\n### 4. `DELETE /users/{user_id}`\n**Description**: Delete a user by `user_id`.\n\n**Path Parameter:**\n- `user_id`: The ID of the user to delete.\n\n**Example Request:**\n\n```bash\ncurl -X DELETE \"http://127.0.0.1:8000/users/1\"\n```\n\n**Example Response:**\n\n```json\n{\n  \"status\": \"ok\",\n  \"removed_data\": {\"user_id\": 1, \"name\": \"John Doe\"}\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- **Pydantic** for data validation and serialization.\n- **Python** for being awesome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanmiglight%2Flab2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanmiglight%2Flab2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanmiglight%2Flab2/lists"}