{"id":18224018,"url":"https://github.com/open-rpc/mock-server","last_synced_at":"2025-08-16T07:30:37.251Z","repository":{"id":34080167,"uuid":"167081426","full_name":"open-rpc/mock-server","owner":"open-rpc","description":"Provides a mock JSON-RPC API given an OpenRPC document.","archived":false,"fork":false,"pushed_at":"2024-06-19T17:52:39.000Z","size":2455,"stargazers_count":26,"open_issues_count":4,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-14T07:50:21.099Z","etag":null,"topics":["mock-server","openrpc","openrpc-document","postman"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-rpc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2019-01-22T23:07:44.000Z","updated_at":"2024-11-03T15:59:39.000Z","dependencies_parsed_at":"2023-02-17T00:35:22.636Z","dependency_job_id":"443024fe-4817-4c96-9f58-a89a8069c495","html_url":"https://github.com/open-rpc/mock-server","commit_stats":{"total_commits":532,"total_committers":11,"mean_commits":48.36363636363637,"dds":0.4473684210526315,"last_synced_commit":"5c3bb2f9698bbcb89a97968b2064524c5a00227a"},"previous_names":["open-rpc/generator-mock-server"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/open-rpc/mock-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Fmock-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Fmock-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Fmock-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Fmock-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-rpc","download_url":"https://codeload.github.com/open-rpc/mock-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Fmock-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266277463,"owners_count":23904001,"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":["mock-server","openrpc","openrpc-document","postman"],"created_at":"2024-11-04T01:05:49.968Z","updated_at":"2025-08-16T07:30:36.912Z","avatar_url":"https://github.com/open-rpc.png","language":"TypeScript","readme":"# open-rpc-mock-server\n\n\u003ccenter\u003e\n  \u003cspan\u003e\n    \u003cimg alt=\"CircleCI branch\" src=\"https://img.shields.io/circleci/project/github/open-rpc/mock-server/master.svg\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/open-rpc/mock-server/branch/master/graph/badge.svg\" /\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/dt/@open-rpc/mock-server.svg\" /\u003e\n    \u003cimg alt=\"GitHub release\" src=\"https://img.shields.io/github/release/open-rpc/mock-server.svg\" /\u003e\n    \u003cimg alt=\"GitHub commits since latest release\" src=\"https://img.shields.io/github/commits-since/open-rpc/mock-server/latest.svg\" /\u003e\n  \u003c/span\u003e\n\u003c/center\u003e\n\nProvide a [Mock server](https://en.wikipedia.org/wiki/Mock_object) for an [OpenRPC Document](https://spec.open-rpc.org/).\n\n\n## Features\n\n### Basic Mode\n\nGiven an [OpenRPC document](https://github.com/open-rpc/spec#openrpc-document), Mock server will provide a mock implementation of the JSON-RPC api that:\n - implements all of the methods specified in the given [OpenRPC document](https://github.com/open-rpc/spec#openrpc-document).\n - when calling a method with params used in an example, the example's result will be returned.\n - params without examples will have their results generated according to the [`method.result.schema: JSONSchema`](https://spec.open-rpc.org/#content-descriptor-schema).\n - validates input params against their respective JSONSchemas.\n - Provides [rpc.discover](https://github.com/open-rpc/spec#service-discovery-method) for service discovery-based integration testing.\n\n\n### Service Mode\n\nRunning the mock server in service mode will run a [JSON-RPC service](https://github.com/open-rpc/mock-server/blob/master/service-mode-openrpc.json) that:\n - implements one method: `mock`. It takes an openrpc document, returns a url path postfix. Appending the path to the services url will give us a mock server for the document provided.\n - host it yourself or use the OpenRPC hosted one: `https://mock.open-rpc.org`\n\n### CLI \u0026 Javascript/Typescript API\n\nMock server is generally meant to be run via CLI, however it can also be imported to your project. doing so will:\n - give you a function to start the server, and returns you the [OpenRPC Server instance](https://github.com/open-rpc/server-js)\n - from there you can add transports, routers \u0026 middleware\n\n## Install\n\n### CLI\n\n```bash\nnpm i -g @open-rpc/mock-server\n```\n\n### Javascript API\n\n```bash\nnpm i -S @open-rpc/mock-server\n```\n\n## Usage\n\n### CLI\n#### Defaults\nThe default settings expect to find a file in the root of your project called `open-rpc.json`. It will must be a valid OpenRPC document as validated by [OpenRPC Metaschema](https://meta.open-rpc.org/), or an error will be returned.\n\n```bash\nnpm run mock-server\n```\n\nthis will start an [HTTP server](https://github.com/open-rpc/server-js) on http://localhost:3333 (default settings)\n\n#### Custom path or filename\nWhere my-open-rpc-document.json is a file in the current directory which is a valid OpenRPC document as validated by [OpenRPC Metaschema](https://meta.open-rpc.org/).\n\n```bash\nopen-rpc-mock-server -d my-open-rpc-document.json\n```\n\n#### OpenRPC Document from url\nYou can also provide a URL that will resolve the OpenRPC document in JSON format:\n```bash\nopen-rpc-mock-server -d https://raw.githubusercontent.com/open-rpc/examples/master/service-descriptions/simple-math-openrpc.json\n```\n\n#### Running in Service Mode\nAllows you to add documents to the running server as a JSON-RPC request. One mock server in service mode can handle a large number of mocked services at once with this configuration.\n\n```bash\nopen-rpc-mock-server --mode service\n```\n\nA server is running on http://localhost:3333 now. You can call the `mock` method, and pass it your OpenRPC document, which will start mocking that service (under the returned url path).\n\n\n## Trying out the mocked service\n\n - Try out the free to use OpenRPC-hosted mock server `https://mock.open-rpc.org/` [here](https://playground.open-rpc.org/?url=https://mock.open-rpc.org)\n - use your own localhost mock server with playground [here](https://playground.open-rpc.org/?url=http://localhost:3333)\n - or try the postman-like only interface [OpenRPC Inspector](https://inspector.open-rpc.org/) with any of the above links\n\n## Example\n\n- [Using OpenRPC Mock Server to test against an Ethereum JSON-RPC API](https://medium.com/etclabscore/using-openrpc-mock-server-to-test-against-an-ethereum-json-rpc-api-50b86b6d02d6) - Jun 11, 2019 - ETC Labs Core\n\n## Contributing\n\nHow to contribute, build and release are outlined in [CONTRIBUTING.md](CONTRIBUTING.md), [BUILDING.md](BUILDING.md) and [RELEASING.md](RELEASING.md) respectively. Commits in this repository follow the [CONVENTIONAL_COMMITS.md](CONVENTIONAL_COMMITS.md) specification.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-rpc%2Fmock-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-rpc%2Fmock-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-rpc%2Fmock-server/lists"}