{"id":44711426,"url":"https://github.com/rsc1975/api-mockr","last_synced_at":"2026-02-15T12:41:23.553Z","repository":{"id":41221061,"uuid":"508774449","full_name":"rsc1975/api-mockr","owner":"rsc1975","description":"Service that creates a Mock API REST","archived":false,"fork":false,"pushed_at":"2022-08-30T18:15:45.000Z","size":501,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T06:53:14.451Z","etag":null,"topics":["api-rest","integration-testing","mock"],"latest_commit_sha":null,"homepage":"https://api-mockr.dvlpr.tech","language":"TypeScript","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/rsc1975.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}},"created_at":"2022-06-29T16:50:39.000Z","updated_at":"2022-08-09T06:33:09.000Z","dependencies_parsed_at":"2023-01-16T17:45:32.509Z","dependency_job_id":null,"html_url":"https://github.com/rsc1975/api-mockr","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/rsc1975/api-mockr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsc1975%2Fapi-mockr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsc1975%2Fapi-mockr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsc1975%2Fapi-mockr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsc1975%2Fapi-mockr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsc1975","download_url":"https://codeload.github.com/rsc1975/api-mockr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsc1975%2Fapi-mockr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29478356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T11:35:25.641Z","status":"ssl_error","status_checked_at":"2026-02-15T11:34:57.128Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["api-rest","integration-testing","mock"],"created_at":"2026-02-15T12:41:23.030Z","updated_at":"2026-02-15T12:41:23.545Z","avatar_url":"https://github.com/rsc1975.png","language":"TypeScript","readme":"\n[![codecov](https://codecov.io/gh/rsc1975/api-mockr/branch/main/graph/badge.svg?token=IHB0J0OOPQ)](https://codecov.io/gh/rsc1975/api-mockr)\n[![Code size](https://img.shields.io/github/languages/code-size/rsc1975/api-mockr?logo=github\u0026logoColor=white)](https://github.com/rsc1975/api-mockr)\n[![License](https://img.shields.io/github/license/rsc1975/api-mockr?logo=open-source-initiative\u0026logoColor=green)](https://github.com/rsc1975/api-mockr/blob/main/LICENSE)\n[![CI](https://img.shields.io/github/workflow/status/rsc1975/api-mockr/Docker%20image?logo=github)](https://github.com/rsc1975/api-mockr/actions/workflows/dockerhub-upload.yml)\n[![Last Commit](https://img.shields.io/github/last-commit/rsc1975/api-mockr?logo=github)](https://github.com/rsc1975/api-mockr/commits/main)\n[![Docker version](https://img.shields.io/docker/v/dvlprtech/api-mockr?sort=semver\u0026logo=docker)](https://hub.docker.com/r/dvlprtech/api-mockr)\n\n\n# api-mockr\n\nJust another API mocker that can be configured to response random and specific data. It can help testing integrations with third parties. It's specially useful to create integration tests where we need to interact with an external service, so we can customize the response for different services exactly as we expect the external service responses. \n\nCurrently, only REST API responses are supported.\n\n\n# Demo\n\nThere is a demo available [here](https://api-mockr.dvlpr.tech/). The application is deployed in the free tier of [Cyclic](https://cyclic.sh/), so please, don't abuse.\n# Getting started\n\nThis is a Deno application, packaged as a Dokcer image.\n\n## Installation\n\nInstallation as docker image:\n\n```sh\ndocker pull dvlprtech/api-mockr\n```\n\n## How to use\n\nIf we only want to take a look and run the application with the default config:\n\n```\ndocker run --rm --name mockr -it -p 3003:3003 dvlprtech/api-mockr\n```\n\nWe should see something like:\n\n```\nLaunching api-mockr...\n[🟢 api-mockr] Server running at: http://0.0.0.0:3003\n```\n\nTo stop de server, if the container is running in interactive mode, press [Ctrl+C]\n\nThe application default port es 3003, to use custom config files we can map a volume on /config container directory and to pass specific parameters to the application we can pass them to the command line or use the environment variable MOCKR_PARAMS (Notice the missing E in \"MOCKR_\").\n\nIn the following example we are passing the --verbose option parameter and the local config file: `/my-local-configs-paths/user-crud.yml`:\n\n```sh\n# The  /config/user-crud.yml is the container path to config ile\ndocker run --rm --name mockr -it -p 3003:3003 -v /my-local-configs-paths:/config dvlprtech/api-mockr --verbose --config=/config/user-crud.yml\n```\n\nUsing the env `MOCKR_PARAMS`:\n\n```sh\n# The  /config/user-crud.yml is the container path to config ile\nMOCKR_PARAMS=\"--verbose --config=/config/user-crud.yml\"\ndocker run --rm --name mockr -it -p 3003:3003 -v /my-local-configs-paths:/config -e MOCKR_PARAMS=\"$MOCKR_PARAMS\" dvlprtech/api-mockr\n```\n\nThere are several options params that can be used to configure the server:\n\n* `--port`: The port to listen to. Default is `3003`.\n* `--host`: The host to listen to. Default is `0.0.0.0`.\n* `--silent`: If present, the server will not output any message. By default, the server will print every request with the basic info about the response.\n* `--verbose`: If present, the server will print every request with its params and payload and the applied server configuration when the server is created.\n* `--config`: The path to the config file. It's a multivalue param.\n* `--apiPrefix`: The prefix to invoque the API services. Default is `/`. If set all mocked routes should be invoked with this prefix. I.e. The configured route `/v1/users` should be invoked as `/api/v1/users` if we use `--apiPrefix=/api`.\n\nExample of use:\n    \n```sh\n$ docker run --rm -it -p 13003:13003 dvlprtech/api-mockr --port=13003 --apiPrefix=/api --verbose\n[🟢 api-mockr v0.0.0] Server running at: http://0.0.0.0:13003/api\n```\n\nWithout additional configuration, the default server will response with the following data to whatever request:\n\n```txt\n$ curl 'http://localhost:3003/api/whatever?foo=bar'\n{\"success\":true,\"request\":{\"path\":\"/api/whatever\",\"params\":{\"foo\":\"bar\"}}}\n```\n\nThere is an exception, the call to `/` will return a fixed text, that can be used to \"ping\" the server.\n```txt\n$ curl 'http://localhost:3003/'\nAPI Mockr (v0.0.0)\n```\n\n## Special params\n\nThere are some special params that can be used with each request:\n\n* `_pretty`: If it's set to `true`, the response will be pretty printed.\n* `_delay`: The delay in milliseconds to wait before responding. By default 0.\n* `_forceError`: If it's set to `true`, the response will be an error with a http status code of `500` by default.\n* `_clonePayload`: If it's set to `true`, the response payload will be a clone of the request payload but appling variable substitution if they are used in request payload.\n\n\nThe error response can be customized with 2 header:\n\n* `x-mocker-force-error'`: HTTP status code to be returned, can be any value between `400` and `599`. Values out of range will be ignored.\n* `x-mocker-error-msg`: The error message to be returned, you can use variables in the message, like `\"ERROR: ${random.emoji} ${random.phrase}\"`.\n\nExample of error response:\n\n```txt\n$ curl 'http://localhost:3003/api/whatever?foo=bar\u0026_forceError=true\u0026_pretty=1'\n{\n  \"success\": false,\n  \"error\": \"Error in request to path: /api/whatever\",\n  \"request\": {\n    \"body\": null,\n    \"params\": {\n      \"foo\": \"bar\",\n      \"_forceError\": \"true\",\n      \"_pretty\": \"1\"\n    }\n  }\n}\n```\n\nCustomizing the message and code:\n\n```txt\n$ curl -H \"x-mocker-force-error: 418\" -H 'x-mocker-error-msg: ERROR: ${random.emoji} ${random.phrase}' 'http://localhost:3003/api/whatever?foo=bar\u0026_forceError=true\u0026_pretty=1'\n{\n  \"success\": false,\n  \"error\": \"ERROR: 🐭 You cant quantify the driver without transmitting the multi-byte SQL microchip!\",\n  \"request\": {\n    \"body\": null,\n    \"params\": {\n      \"foo\": \"bar\",\n      \"_forceError\": \"true\",\n      \"_pretty\": \"1\"\n    }\n  }\n```\n\nThe emoji and the error phrase will be different with each call.\n\n## Server configuration\n\nThe config files can be read in YAML and JSON formats, the default config file is like this:\n\n```yaml\ndefaultResponse:\n  success: true\n  timestamp: ${server.isoDatetime}\n  request:\n    path: ${request.path} \n    body: ${request.payload}\n    params: ${request.params}\nerrorResponse:\n  $httpStatus$: 500\n  success: false\n  error: \"${error}\"\n  request:\n    body: ${request.payload}\n    params: ${request.params}\nroutes:\n  get: \n    \"say-whatever\":\n      success: true \n      author: ${random.personFirstName}\n      phrase: ${random.phrase}\n```\n\nThere are 3 main sections in the config file:\n\n* `defaultResponse`: The default response to be returned when there is no match for the request path and the configured routes\n* `errorResponse`: The error response payload to be returned when an error occurs.\n* `routes`: The routes to be mocked grouped by HTTP method (get, post, put, ...). A wildcard (`*`) can be used to match any method and/or any path.\n\n## Variables in configuration\n\nWe can use variables in the configuration files to provide dynamic values with every response. There are several variables types:\n\n* `random`: Random values for all sort of data. i.e. `random.personFullName`, `random.integer`, `random.department`, ...\n* `request`: Values from the request. i.e. `request.path`, `request.params`, `request.payload`\n* `server`: Values from the server. i.e. `server.timestamp`, `server.isoDate`, ...\n* Path variables: Variables created in the config file to refer a path section. i.e. A configured route like `/api/users/${username}` will create a variable `username` with value \"bob23\" for a request path like `/api/users/bob23`, this variable can be used in the route response (`... \"author\": \"${username}\", ...`).\n\nSome of the variables accept parameters, the params should be added after a dot (`variable.paramValue`) for example:\n\n* `request.params.foo`: In requests like `/api/whatever?foo=bar` It will return `bar`.\n* `random.personFirstName.male`: This params accepts `male` or `female` as possible input values\n* `random.choose.monday.sunday.tuesday`: This params accepts a variable number of params and It will return one of them randomly.\n\nFor further informaton about the supported variables, please refer to the [VARS.md](https://github.com/rsc1975/api-mockr/blob/main/VARS.md) file.\n\nThere are several examples of config files in [examples directory](./examples).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsc1975%2Fapi-mockr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsc1975%2Fapi-mockr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsc1975%2Fapi-mockr/lists"}