{"id":15958186,"url":"https://github.com/jesufemi-o/fake-coy-api","last_synced_at":"2026-05-17T11:35:03.186Z","repository":{"id":254762176,"uuid":"847467104","full_name":"JesuFemi-O/fake-coy-api","owner":"JesuFemi-O","description":"Dummy api to explore dlt rest api. has authentication, pagination and filtering enabled","archived":false,"fork":false,"pushed_at":"2024-10-05T04:50:44.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-27T08:46:40.092Z","etag":null,"topics":["data-engineering","data-generator","dlthub","fastapi"],"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/JesuFemi-O.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-08-25T22:34:29.000Z","updated_at":"2024-12-05T13:15:07.000Z","dependencies_parsed_at":"2024-10-30T00:19:36.703Z","dependency_job_id":null,"html_url":"https://github.com/JesuFemi-O/fake-coy-api","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"54b8e901faba4a81ce45d5afccc64d194ef9a556"},"previous_names":["jesufemi-o/fake-coy-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JesuFemi-O/fake-coy-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JesuFemi-O%2Ffake-coy-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JesuFemi-O%2Ffake-coy-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JesuFemi-O%2Ffake-coy-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JesuFemi-O%2Ffake-coy-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JesuFemi-O","download_url":"https://codeload.github.com/JesuFemi-O/fake-coy-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JesuFemi-O%2Ffake-coy-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33136869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["data-engineering","data-generator","dlthub","fastapi"],"created_at":"2024-10-07T14:01:59.150Z","updated_at":"2026-05-17T11:35:03.170Z","avatar_url":"https://github.com/JesuFemi-O.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fake-COY-API\n\n## Overview\n\nThis FastAPI application provides endpoints to fetch paginated lists of companies and their employees. The data is generated using a fake data generator and stored in memory. You can filter the data by various criteria and retrieve it in a paginated format. API key authentication is required to access the endpoints.\n\n### How to Start the API\nSpin up the API using Docker Compose:\n\n```bash\ndocker-compose up -d\n```\n\n### API Endpoints\n\n1. **Get Companies**: `/companies`\n2. **Get Employees by Company ID**: `/companies/{company_id}/employees`\n3. **Update Company Valuation**: `/companies/update-valuation`\n\n### Authentication\n\nAll endpoints require an API key for authentication. The API key must be passed in the `x-api-key` header.\n\n### API Key Example\n\n```bash\nx-api-key: mysecretkey\n```\n\n### Base URL\n\nThe API is hosted at `http://localhost:8000/`.\n\n## Endpoints\n\n### 1. Get Companies\n\n- **Endpoint:** `/companies`\n- **Method:** `GET`\n- **Authentication:** API key required (`x-api-key`)\n- **Description:** Returns a paginated list of companies with optional filtering by industry and date fields.\n\n#### Query Parameters:\n\n- `page` (int): Page number (default: 1)\n- `size` (int): Number of items per page (default: 10, max: 100)\n- `industry` (str, optional): Filter by industry\n- `start_dt` (datetime, optional): Filter companies updated after this date\n- `end_dt` (datetime, optional): Filter companies updated before this date (requires `start_dt` to be provided)\n\n#### Response:\n\nReturns a JSON object containing the paginated list of companies without employee data.\n\n```json\n{\n    \"items\": [\n        {\n            \"id\": 1,\n            \"name\": \"Company A\",\n            \"industry\": \"Tech\",\n            \"created_at\": \"2023-08-20T00:00:00\",\n            \"updated_at\": \"2023-08-21T00:00:00\",\n            \"valuation\": 100000000\n        }\n    ],\n    \"total\": 100,\n    \"page\": 1,\n    \"size\": 10,\n    \"total_pages\": 10\n}\n```\n\n#### Example Request with Python `requests`:\n\n```python\nimport requests\n\nBASE_URL = \"http://localhost:8000\"\nAPI_KEY = \"mysecretkey\"\n\nresponse = requests.get(\n    f\"{BASE_URL}/companies\",\n    headers={\"x-api-key\": API_KEY},\n    params={\"page\": 1, \"size\": 10, \"industry\": \"Health\"}\n)\n\nif response.status_code == 200:\n    print(response.json())\nelse:\n    print(\"Failed:\", response.status_code, response.text)\n```\n\n### 2. Get Employees by Company ID\n\n- **Endpoint:** `/companies/{company_id}/employees`\n- **Method:** `GET`\n- **Authentication:** API key required (`x-api-key`)\n- **Description:** Returns a paginated list of employees for a specific company, with optional filtering by job title and date fields.\n\n#### Path Parameters:\n\n- `company_id` (int): The ID of the company\n\n#### Query Parameters:\n\n- `page` (int): Page number (default: 1)\n- `size` (int): Number of items per page (default: 10, max: 100)\n- `job_title` (str, optional): Filter by job title\n- `start_dt` (datetime, optional): Filter employees updated after this date\n- `end_dt` (datetime, optional): Filter employees updated before this date (requires `start_dt` to be provided)\n\n#### Response:\n\nReturns a JSON object containing the paginated list of employees.\n\n```json\n{\n    \"items\": [\n        {\n            \"id\": 1,\n            \"first_name\": \"John\",\n            \"last_name\": \"Doe\",\n            \"job_title\": \"Engineer\",\n            \"email\": \"john.doe@example.com\",\n            \"created_at\": \"2023-08-20T00:00:00\",\n            \"updated_at\": \"2023-08-21T00:00:00\"\n        }\n    ],\n    \"total\": 50,\n    \"page\": 1,\n    \"size\": 10,\n    \"total_pages\": 5\n}\n```\n\n#### Example Request with Python `requests`:\n\n```python\nimport requests\n\nBASE_URL = \"http://localhost:8000\"\nAPI_KEY = \"mysecretkey\"\n\ncompany_id = 1\n\nresponse = requests.get(\n    f\"{BASE_URL}/companies/{company_id}/employees\",\n    headers={\"x-api-key\": API_KEY},\n    params={\"page\": 1, \"size\": 10, \"job_title\": \"Engineer\"}\n)\n\nif response.status_code == 200:\n    print(response.json())\nelse:\n    print(\"Failed:\", response.status_code, response.text)\n```\n\n### 3. Update Company Valuation\n\n- **Endpoint:** `/companies/update-valuation`\n- **Method:** `GET`\n- **Authentication:** API key required (`x-api-key`)\n- **Description:** Randomly selects up to 10 companies and updates their valuations.\n\n#### Response:\n\nReturns a JSON list of companies with updated valuations.\n\n```json\n[\n    {\n        \"id\": 1,\n        \"name\": \"Company A\"\n    },\n    {\n        \"id\": 5,\n        \"name\": \"Company B\"\n    }\n]\n```\n\n#### Example Request with Python `requests`:\n\n```python\nimport requests\n\nBASE_URL = \"http://localhost:8000\"\nAPI_KEY = \"mysecretkey\"\n\nresponse = requests.get(\n    f\"{BASE_URL}/companies/update-valuation\",\n    headers={\"x-api-key\": API_KEY}\n)\n\nif response.status_code == 200:\n    print(response.json())\nelse:\n    print(\"Failed:\", response.status_code, response.text)\n```\n\n## Using `dlt`'s `RESTClient`\n\nYou can also use `dlt`'s `RESTClient` to interact with the API. Below are examples for both endpoints.\n\n### 1. Fetch Companies with `dlt.RESTClient`\n\n```python\nfrom requests import Request, Response\nfrom dlt.sources.helpers.rest_client.paginators import RangePaginator\nfrom dlt.sources.helpers.rest_client.auth import APIKeyAuth\nfrom dlt.sources.helpers.rest_client import RESTClient\n\n\nclient = RESTClient(\n    base_url=\"http://localhost:8000/\",\n    paginator=RangePaginator(param_name='page', initial_value=1, value_step=1, total_path='total'),\n    auth = APIKeyAuth(api_key=\"mysecretkey\", location=\"header\", name=\"x-api-key\"),\n    data_selector = \"$.items\" # not compulsory, client can detect the data selector\n)\n\n# Fetch companies with pagination\nfor company_batch in client.paginate(\"/companies\", params={\"size\": 10, \"industry\": \"Health\"}):\n    for company in company_batch:\n        print(company)\n    break # to prevent printing out too many records\n```\n\n### 2. Fetch Employees by Company ID with `dlt.RESTClient`\n\n```python\ncompany_id = 1\n\nfor employee_batch in client.paginate(f\"/companies/{company_id}/employees\"):\n    for employee in employee_batch:\n        print(employee)\n    break\n```\n\n## Conclusion\n\nThis API allows you to fetch paginated lists of companies and their employees with optional filtering by various criteria. The API requires an API key for authentication. You can interact with the API using Python's `requests` library or `dlt`'s `RESTClient` for more advanced use cases.\n\nFor more details, you can access the Swagger documentation at the root URL: `http://localhost:8000/`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesufemi-o%2Ffake-coy-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjesufemi-o%2Ffake-coy-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesufemi-o%2Ffake-coy-api/lists"}