{"id":20348484,"url":"https://github.com/saadmairaj/blog-api","last_synced_at":"2026-04-18T12:03:59.902Z","repository":{"id":240749025,"uuid":"443746381","full_name":"Saadmairaj/blog-api","owner":"Saadmairaj","description":"Hatchway API competitive programming exam","archived":false,"fork":false,"pushed_at":"2022-01-16T14:04:10.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T01:17:12.508Z","etag":null,"topics":["api-rest","catch","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/Saadmairaj.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":"2022-01-02T11:15:38.000Z","updated_at":"2022-01-02T11:20:37.000Z","dependencies_parsed_at":"2024-05-20T19:39:26.293Z","dependency_job_id":null,"html_url":"https://github.com/Saadmairaj/blog-api","commit_stats":null,"previous_names":["saadmairaj/blog-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Saadmairaj/blog-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saadmairaj%2Fblog-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saadmairaj%2Fblog-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saadmairaj%2Fblog-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saadmairaj%2Fblog-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saadmairaj","download_url":"https://codeload.github.com/Saadmairaj/blog-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saadmairaj%2Fblog-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31967994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"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":["api-rest","catch","fastapi"],"created_at":"2024-11-14T22:20:40.037Z","updated_at":"2026-04-18T12:03:59.879Z","avatar_url":"https://github.com/Saadmairaj.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blog Post API\n\nHigh-level API wrapper around the existing blog post API at *https://api.hatchways.io/assessment/blog/posts* with improvements and new features as follow:\n\n- Async API built with [FastAPI](https://fastapi.tiangolo.com)\n- Now can take multiple tags as comma separated query parameter _(`\"history,tech\"`)_\n- Sort results by _id_, _likes_, _reads_, _popularity_\n- New Caching system for faster and efficient responses\n\n## Installation\n\nThe installation is pretty straightforward\n\n1. Unzip the repo with unzip _(anything can be used unzip)_ and change the directory to it\n\n   ```bash\n   $ unzip test_assessment.zip\n   $ cd test_assessment\n   ```\n\n2. Create a python3.8 environment with virtualenv python package and activate the virtual environment\n\n   ```bash\n   $ pip3 install virtualenv\n   $ python -m venv env\n   $ source env/bin/activate\n   ```\n\n3. Install required packages from requirements/main.txt\n\n   ```bash\n   $ pip3 install -r requirements/main.txt\n   ```\n\n4. Change environment variable `.env.example` file to `.env` file and set required and optional variables\n\n   ```bash\n   $ mv .env.example .env\n   $ nano .env\n\n   BLOG_POST_ROUTE = \"https://api.hatchways.io/assessment/blog/posts\"\n\n   # API CACHING VARIABLES\n   CACHING = true\n   CACHE_EXPIRY = 10 # in minutes\n   ```\n\n## Start API\n\nFastAPI uses uvicorn ASGI server which is lightning fast. Run the API server with\n\n```bash\n$ uvicorn api.server:app --host 0.0.0.0 --port 8000\n\nINFO:     Started server process [1494]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\nINFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)\n```\n\nIf you want to run the server in debug mode then add `--reload` parameter\n\n```bash\n$ uvicorn api.server:app --host 0.0.0.0 --port 8000 --reload\n\nINFO:     Will watch for changes in these directories: ['/Users/saad/Desktop/assessment2']\nINFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)\nINFO:     Started reloader process [1523] using watchgod\nINFO:     Started server process [1525]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\n```\n\n## Routes\n\nThese are two routes in the api\n\n**_GET_** `/api/ping`\n\n**_GET_** `/api/posts?tags=history,tech\u0026sortBy=likes\u0026direction=desc`\n\n## Testing\n\nRun tests with pytest with following steps\n\n1. Activate the virtual environment and install dev requirements\n\n   ```bash\n   $ source env/bin/activate\n   $ pip3 install -r requirements/dev.txt\n   ```\n\n2. Run tests with\n\n   ```bash\n   $ pytest tests\n\n   collected 17 items\n\n   tests/test_database.py ...                                                                   [ 17%]\n   tests/test_models.py ....                                                                    [ 41%]\n   tests/test_server.py .......                                                                 [ 82%]\n   tests/test_utils.py ...                                                                      [100%]\n   ```\n\n3. Test coverage with\n\n   ```bash\n   $ pytest --cov=api tests/\n\n   collected 17 items\n\n   tests/test_database.py ...                                                                   [ 17%]\n   tests/test_models.py ....                                                                    [ 41%]\n   tests/test_server.py .......                                                                 [ 82%]\n   tests/test_utils.py ...                                                                      [100%]\n\n   ---------- coverage: platform darwin, python 3.8.3-final-0 -----------\n   Name              Stmts   Miss  Cover\n   -------------------------------------\n   api/__init__.py       2      0   100%\n   api/database.py      29      1    97%\n   api/models.py        19      0   100%\n   api/routes.py        17      0   100%\n   api/server.py         4      0   100%\n   api/utils.py         27      0   100%\n   -------------------------------------\n   TOTAL                98      1    99%\n\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaadmairaj%2Fblog-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaadmairaj%2Fblog-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaadmairaj%2Fblog-api/lists"}