{"id":21659362,"url":"https://github.com/0xProject/standard-relayer-api","last_synced_at":"2025-07-17T22:31:58.489Z","repository":{"id":37664128,"uuid":"101449843","full_name":"0xProject/standard-relayer-api","owner":"0xProject","description":"Standard specifications for 0x relayer public APIs","archived":false,"fork":false,"pushed_at":"2020-05-21T09:07:42.000Z","size":181,"stargazers_count":163,"open_issues_count":21,"forks_count":54,"subscribers_count":23,"default_branch":"master","last_synced_at":"2023-11-07T18:19:41.422Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/0xProject.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":"2017-08-25T23:37:11.000Z","updated_at":"2023-10-20T10:28:32.000Z","dependencies_parsed_at":"2022-09-08T19:51:03.149Z","dependency_job_id":null,"html_url":"https://github.com/0xProject/standard-relayer-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xProject%2Fstandard-relayer-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xProject%2Fstandard-relayer-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xProject%2Fstandard-relayer-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xProject%2Fstandard-relayer-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xProject","download_url":"https://codeload.github.com/0xProject/standard-relayer-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226305676,"owners_count":17603859,"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":[],"created_at":"2024-11-25T09:30:56.196Z","updated_at":"2024-11-25T09:32:24.037Z","avatar_url":"https://github.com/0xProject.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Standard Relayer API\n\n0x Protocol is an open standard. Because of this, we expect many independent applications to be built that will want to use the protocol. In order to make it easier for anyone to source liquidity that conforms to the 0x order format, relayers can opt-in to implementing a set of standard relayer API endpoints. In doing so, they allow clients of the standard relayer API to access the orders on their orderbook.\n\n## Specification Versions\n\n### SRA v3\n\nMade to match [0x Protocol v3](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md). See [changes](https://github.com/0xProject/standard-relayer-api/releases/tag/v3.0.0) from v2.\n\n- [HTTP](https://github.com/0xProject/standard-relayer-api/blob/master/http/v3.md)\n- [WebSocket](https://github.com/0xProject/standard-relayer-api/blob/master/ws/v3.md)\n- OpenAPI Spec ([Docs](http://sra3-spec.s3-website-us-east-1.amazonaws.com/), [Package](https://github.com/0xProject/0x-monorepo/tree/development/packages/sra-spec))\n\n### SRA v2\n\nMade to match [0x Protocol v2](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md)\n\n- [HTTP](https://github.com/0xProject/standard-relayer-api/blob/master/http/v2.md)\n- [WebSocket](https://github.com/0xProject/standard-relayer-api/blob/master/ws/v2.md)\n- OpenAPI Spec ([Docs](http://sra-spec.s3-website-us-east-1.amazonaws.com/), [Package](https://github.com/0xProject/0x-monorepo/tree/development/packages/sra-spec))\n\n### SRA v1\n\nSkipped for naming convention and convenience reasons.\n\n### SRA v0\n\nMade to match [0x Protocol v1](https://github.com/0xProject/0x-protocol-specification/blob/master/v1/v1-whitepaper.pdf)\n\n- [HTTP](https://github.com/0xProject/standard-relayer-api/blob/master/http/v0.md)\n- [WebSocket](https://github.com/0xProject/standard-relayer-api/blob/master/ws/v0.md)\n\n## General Info\n\n### Versioning\n\nThe URL that specifies the SRA API endpoint should end in the version. Here are some examples:\n\n**HTTP**: `https://api.relayer.com/sra/v0/`, `https://api.relayer.com/sra/v2/`\n\n**Websocket**: `wss://api.relayer.com/sra/v0/`, `wss://api.relayer.com/sra/v2/`\n\n### Schemas\n\nThe [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas). Examples of each payload and response can be found in the library's [test suite](https://github.com/0xProject/0x.js/blob/development/packages/json-schemas/test/schema_test.ts#L1).\n\n```\nnpm install @0xproject/json-schemas --save\n```\n\nYou can easily validate your API's payloads and responses using the [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas) package:\n\n```\nimport {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas';\n\nconst {relayerApiTokenPairsResponseSchema} = schemas;\nconst validator = new SchemaValidator();\n\nconst tokenPairsResponse = {\n    ...\n};\nconst validatorResult: ValidatorResult = validator.validate(tokenPairsResponse, relayerApiTokenPairsResponseSchema);\n```\n\n### Asset Data Encoding\n\nAs we now support multiple [token transfer proxies](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxy), the identifier of which proxy to use for the token transfer must be encoded, along with the token information. Each proxy in 0x v2 has a unique identifier. If you're using 0x.js there will be helper methods for this [encoding](https://0xproject.com/docs/0x.js#zeroEx-encodeERC20AssetData) and [decoding](https://0xproject.com/docs/0x.js#zeroEx-decodeAssetProxyId).\n\nThe identifier for the Proxy uses a similar scheme to [ABI function selectors](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#function-selector).\n\n```\n// ERC20 Proxy ID  0xf47261b0\nbytes4(keccak256(\"ERC20Token(address)\"))\n// ERC721 Proxy ID 0x02571792\nbytes4(keccak256(\"ERC721Token(address,uint256)\"))\n```\n\nAsset data is encoded using [ABI encoding](https://solidity.readthedocs.io/en/develop/abi-spec.html).\n\nFor example, encoding the ERC20 token contract (address: 0x1dc4c1cefef38a777b15aa20260a54e584b16c48) using the ERC20 Transfer Proxy (id: 0xf47261b0) would be:\n\n```\n0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48\n```\n\nEncoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc74099f40e84`), token id (id: `99`, which hex encoded is `0x63`) and the ERC721 Transfer Proxy (id: `0x02571792`) would be:\n\n```\n0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063\n```\n\nFor more information see [the Asset Proxy](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#erc20proxy) section of the v2 spec and the [Ethereum ABI Spec](https://solidity.readthedocs.io/en/develop/abi-spec.html).\n\n### Meta Data in Order Responses\n\nIn v2 of the standard relayer API we added the `metaData` field. It is meant to provide a standard place for relayers to put optional, custom or non-standard fields that may of interest to the consumer of the API.\n\nA good example of such a field is `remainingTakerAssetAmount`, which is a convenience field that communicates how much of a 0x order is potentially left to be filled. Unlike the other fields in a 0x order, it is not guaranteed to be correct as it is derived from whatever mechanism the implementer (ie. the relayer) is using. While convenient for prototyping and low stakes situations, we recommend validating the value of the field by checking the state of the blockchain yourself, such as by using [Order Watcher](https://0xproject.com/wiki#0x-OrderWatcher).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xProject%2Fstandard-relayer-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xProject%2Fstandard-relayer-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xProject%2Fstandard-relayer-api/lists"}