{"id":13501434,"url":"https://github.com/umutseven92/apyr","last_synced_at":"2026-02-22T18:45:33.343Z","repository":{"id":42649510,"uuid":"336137320","full_name":"umutseven92/apyr","owner":"umutseven92","description":"API mocking with Python.","archived":false,"fork":false,"pushed_at":"2023-02-08T01:14:15.000Z","size":231,"stargazers_count":57,"open_issues_count":4,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-31T20:40:04.906Z","etag":null,"topics":["api","fastapi","mock","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umutseven92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-02-05T02:08:09.000Z","updated_at":"2024-09-13T19:53:46.000Z","dependencies_parsed_at":"2024-01-16T10:36:21.786Z","dependency_job_id":"2fd28ec3-feaf-45a5-880e-59d8c7b2447e","html_url":"https://github.com/umutseven92/apyr","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umutseven92%2Fapyr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umutseven92%2Fapyr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umutseven92%2Fapyr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umutseven92%2Fapyr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umutseven92","download_url":"https://codeload.github.com/umutseven92/apyr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246166904,"owners_count":20734357,"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","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","fastapi","mock","python"],"created_at":"2024-07-31T22:01:37.410Z","updated_at":"2025-03-29T09:30:27.359Z","avatar_url":"https://github.com/umutseven92.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# apyr ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/umutseven92/apyr?label=version) ![tests](https://github.com/umutseven92/apyr/workflows/tests/badge.svg?branch=master)\n\n**apyr** (all lowercase) is a simple \u0026 easy to use mock API server.\n\nIt's great for front-end development when your API is not ready, or when you are prototyping an API. It's also very\nuseful for demos \u0026 hackathons.\n\n## Installation\n\n* Clone the project;\n\n```bash\ngit clone https://github.com/umutseven92/apyr.git\n```\n\n* Edit `endpoints.yaml` with your endpoints (details below).\n\n### Via poetry\n\n* Install [poetry](https://python-poetry.org/docs/#installation).\n\n```bash\ncd apyr\npoetry install # Install dependencies\npoetry run apyr # Run apyr\n```\n\n### Via Docker\n\n```bash\ncd apyr\ndocker-compose up --build -d\n```\n\n## Configuration\n\nYour endpoints are defined in `endpoints.yaml`. An example `endpoints.yaml` comes with the project; feel free to edit\nit.\n\n| Syntax      | Required | Default | Description |\n| :--- | :---: | :--- | :-------- |\n| `method`      | ✅       | | [HTTP method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) of the endpoint | |\n| `path`        | ✅       | | Path to the endpoint, appended to the base URL | |\n| `status_code` | ✅       | | [Status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) of the response |\n| `media_type`  | ❌       | `application/json` | [Mime Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#important_mime_types_for_web_developers) of the response |\n| `content`\u003csup\u003e†\u003c/sup\u003e     | ❌       | | Body of the response |\n| `content_path`\u003csup\u003e†\u003c/sup\u003e     | ❌       | |  Path to the response body |\n\n\u003csup\u003e†\u003c/sup\u003e Both `content` and `content_path` can't be set at the same time.\n\n### Example endpoints.yaml\n\n```yaml\n# A GET method that returns a list of employees.\n- method: GET\n  path: test/employees\n  status_code: 200\n  content: \u003e\n    [\n      { \"first_name\": \"Peter\", \"last_name\": \"Venkman\" },\n      { \"first_name\": \"Ray\", \"last_name\": \"Stantz\" },\n      { \"first_name\": \"Egon\", \"last_name\": \"Spengler\" },\n    ]\n# A GET method that returns an employee.\n# Take note of the two %functions%- the employee's first name, last name and age will be random at every response.\n- method: GET\n  path: test/employee/2\n  status_code: 200\n  content: \u003e\n    {\n      \"first_name\": \"%random_first_name(female)%\",\n      \"last_name\": \"%random_last_name()%\",\n      \"age\": %random_int(20, 50)%\n    }\n# A POST method that returns a 500. Great for testing error pages.\n- method: POST\n  path: test/employee\n  media_type: text\n  status_code: 500\n  content: An unexpected error occured while creating the employee.\n# A PUT method that returns a 201. Does not return a body- content is optional.\n- method: PUT\n  path: test/employee/3\n  status_code: 201\n# A GET method that returns an HTML page.\n- method: GET\n  path: test/help\n  status_code: 200\n  media_type: text/html\n  content: \u003e\n    \u003c!DOCTYPE html\u003e\n     \u003chtml\u003e\n     \u003cbody\u003e\n     \u003ch1\u003eI've quit better jobs than this.\u003c/h1\u003e\n     \u003cp\u003eGhostbusters, whaddya want.\u003c/p\u003e\n     \u003c/body\u003e\n     \u003c/html\u003e\n# The same method as above, but the content is referenced from another file. Path is relative to project root.\n- method: GET\n  path: test/help2\n  status_code: 200\n  media_type: text/html\n  content_path: assets/help.html\n```\n\n### Example usage\n\nAn example of making a `curl` request to our second endpoint defined above:\n\n```bash\n~ λ curl 0.0.0.0:8000/test/employee/2 -v\n\u003e GET /test/employee/2 HTTP/1.1\n\u003e \n\u003c HTTP/1.1 200 OK\n\u003c server: uvicorn\n\u003c content-length: 52\n\u003c content-type: application/json\n\u003c \n{ \"first_name\": \"Geoffrey\", \"last_name\": \"Greeley\", \"age\": 28 }\n```\n\nNo need to restart **apyr** after editing `endpoints.yaml`- it's all taken care of!\n\n## Functions\n\n**apyr** supports different kinds of functions inside the content parameter.\n\nCurrently supported functions are:\n\n| Name | Parameters | Description | Examples |\n| :--- | :--- | :--- | :--- |\n| `%random_first_name(gender)%` | `gender`: Optional string. Can be `male` or `female`. If left empty, will default to both | Will be replaced by a random first name | `%random_first_name(male)%`, `%random_first_name(female)%`, `%random_first_name()%`\n| `%random_last_name()%` | | Will be replaced by a random last name | `%random_last_name()%` |\n| `%random_int(start, end)%` | `start`: Required int, `end`: Required int | Will be replaced by a random integer between `start` and `end` (both inclusive) | `%random_int(0, 20)%`, `%random_int(20, 50)%` |\n\n## Contributing\n\nIf you like this project, please consider [donating to the Electronic Frontier Foundation](https://supporters.eff.org/donate). ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumutseven92%2Fapyr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumutseven92%2Fapyr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumutseven92%2Fapyr/lists"}