{ "info": { "author": "F. Eugene Aumson", "author_email": "feuGeneA@users.noreply.github.com", "bugtrack_url": null, "classifiers": [], "description": "# 0x-sra-client\n\nA Python client for interacting with servers conforming to [the Standard Relayer API specification](https://github.com/0xProject/0x-monorepo/tree/development/packages/sra-spec).\n\nRead the [documentation](http://0x-sra-client-py.s3-website-us-east-1.amazonaws.com/)\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-monorepo/tree/development/packages/json-schemas). Examples of each payload and response can be found in the 0x.js library's [test suite](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/test/schema_test.ts#L1).\n\n```bash\npip install 0x-json-schemas\n```\n\nYou can easily validate your API's payloads and responses using the [0x-json-schemas](https://github.com/0xProject/0x.js/tree/development/python-packages/json_schemas) package:\n\n```python\nfrom zero_ex.json_schemas import assert_valid\nfrom zero_ex.order_utils import Order\n\norder: Order = {\n 'makerAddress': \"0x0000000000000000000000000000000000000000\",\n 'takerAddress': \"0x0000000000000000000000000000000000000000\",\n 'feeRecipientAddress': \"0x0000000000000000000000000000000000000000\",\n 'senderAddress': \"0x0000000000000000000000000000000000000000\",\n 'makerAssetAmount': \"1000000000000000000\",\n 'takerAssetAmount': \"1000000000000000000\",\n 'makerFee': \"0\",\n 'takerFee': \"0\",\n 'expirationTimeSeconds': \"12345\",\n 'salt': \"12345\",\n 'makerAssetData': \"0x0000000000000000000000000000000000000000\",\n 'takerAssetData': \"0x0000000000000000000000000000000000000000\",\n 'exchangeAddress': \"0x0000000000000000000000000000000000000000\",\n}\n\nassert_valid(order, \"/orderSchema\")\n```\n\n# Pagination\n\nRequests that return potentially large collections should respond to the **?page** and **?perPage** parameters. For example:\n\n```bash\n$ curl https://api.example-relayer.com/v2/asset_pairs?page=3&perPage=20\n```\n\nPage numbering should be 1-indexed, not 0-indexed. If a query provides an unreasonable (ie. too high) `perPage` value, the response can return a validation error as specified in the [errors section](#section/Errors). If the query specifies a `page` that does not exist (ie. there are not enough `records`), the response should just return an empty `records` array.\n\nAll endpoints that are paginated should return a `total`, `page`, `perPage` and a `records` value in the top level of the collection. The value of `total` should be the total number of records for a given query, whereas `records` should be an array representing the response to the query for that page. `page` and `perPage`, are the same values that were specified in the request. See the note in [miscellaneous](#section/Misc.) about formatting `snake_case` vs. `lowerCamelCase`.\n\nThese requests include the [`/v2/asset_pairs`](#operation/getAssetPairs), [`/v2/orders`](#operation/getOrders), [`/v2/fee_recipients`](#operation/getFeeRecipients) and [`/v2/orderbook`](#operation/getOrderbook) endpoints.\n\n# Network Id\n\nAll requests should be able to specify a **?networkId** query param for all supported networks. For example:\n\n```bash\n$ curl https://api.example-relayer.com/v2/asset_pairs?networkId=1\n```\n\nIf the query param is not provided, it should default to **1** (mainnet).\n\nNetworks and their Ids:\n\n| Network Id | Network Name |\n| ---------- | ------------ |\n| 1 | Mainnet |\n| 42 | Kovan |\n| 3 | Ropsten |\n| 4 | Rinkeby |\n\nIf a certain network is not supported, the response should **400** as specified in the [error response](#section/Errors) section. For example:\n\n```json\n{\n \\\"code\\\": 100,\n \\\"reason\\\": \\\"Validation failed\\\",\n \\\"validationErrors\\\": [\n {\n \\\"field\\\": \\\"networkId\\\",\n \\\"code\\\": 1006,\n \\\"reason\\\": \\\"Network id 42 is not supported\\\"\n }\n ]\n}\n```\n\n# Link Header\n\nA [Link Header](https://tools.ietf.org/html/rfc5988) can be included in a response to provide clients with more context about paging\nFor example:\n\n```bash\nLink: ; rel=\\\"next\\\",\n; rel=\\\"last\\\"\n```\n\nThis `Link` response header contains one or more Hypermedia link relations.\n\nThe possible `rel` values are:\n\n| Name | Description |\n| ----- | ------------------------------------------------------------- |\n| next | The link relation for the immediate next page of results. |\n| last | The link relation for the last page of results. |\n| first | The link relation for the first page of results. |\n| prev | The link relation for the immediate previous page of results. |\n\n# Rate Limits\n\nRate limit guidance for clients can be optionally returned in the response headers:\n\n| Header Name | Description |\n| --------------------- | ---------------------------------------------------------------------------- |\n| X-RateLimit-Limit | The maximum number of requests you're permitted to make per hour. |\n| X-RateLimit-Remaining | The number of requests remaining in the current rate limit window. |\n| X-RateLimit-Reset | The time at which the current rate limit window resets in UTC epoch seconds. |\n\nFor example:\n\n```bash\n$ curl -i https://api.example-relayer.com/v2/asset_pairs\nHTTP/1.1 200 OK\nDate: Mon, 20 Oct 2017 12:30:06 GMT\nStatus: 200 OK\nX-RateLimit-Limit: 60\nX-RateLimit-Remaining: 56\nX-RateLimit-Reset: 1372700873\n```\n\nWhen a rate limit is exceeded, a status of **429 Too Many Requests** should be returned.\n\n# Errors\n\nUnless the spec defines otherwise, errors to bad requests should respond with HTTP 4xx or status codes.\n\n## Common error codes\n\n| Code | Reason |\n| ---- | --------------------------------------- |\n| 400 | Bad Request \u2013 Invalid request format |\n| 404 | Not found |\n| 429 | Too many requests - Rate limit exceeded |\n| 500 | Internal Server Error |\n| 501 | Not Implemented |\n\n## Error reporting format\n\nFor all **400** responses, see the [error response schema](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_error_response_schema.ts#L1).\n\n```json\n{\n \\\"code\\\": 101,\n \\\"reason\\\": \\\"Validation failed\\\",\n \\\"validationErrors\\\": [\n {\n \\\"field\\\": \\\"maker\\\",\n \\\"code\\\": 1002,\n \\\"reason\\\": \\\"Invalid address\\\"\n }\n ]\n}\n```\n\nGeneral error codes:\n\n```bash\n100 - Validation Failed\n101 - Malformed JSON\n102 - Order submission disabled\n103 - Throttled\n```\n\nValidation error codes:\n\n```bash\n1000 - Required field\n1001 - Incorrect format\n1002 - Invalid address\n1003 - Address not supported\n1004 - Value out of range\n1005 - Invalid signature or hash\n1006 - Unsupported option\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```js\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```bash\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```bash\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\n# Misc.\n\n- All requests and responses should be of **application/json** content type\n- All token amounts are sent in amounts of the smallest level of precision (base units). (e.g if a token has 18 decimal places, selling 1 token would show up as selling `'1000000000000000000'` units by this API).\n- All addresses are sent as lower-case (non-checksummed) Ethereum addresses with the `0x` prefix.\n- All parameters are to be written in `lowerCamelCase`.\n\nThis Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:\n\n- API version: 2.0.0\n- Package version: 1.0.0\n- Build package: org.openapitools.codegen.languages.PythonClientCodegen\n\n## Requirements.\n\nPython 2.7 and 3.4+\n\n## Installation & Usage\n\n### pip install\n\nIf the python package is hosted on Github, you can install directly from Github\n\n```sh\npip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git\n```\n\n(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)\n\nThen import the package:\n\n```python\nimport sra_client\n```\n\n### Setuptools\n\nInstall via [Setuptools](http://pypi.python.org/pypi/setuptools).\n\n```sh\npython setup.py install --user\n```\n\n(or `sudo python setup.py install` to install the package for all users)\n\nThen import the package:\n\n```python\nimport sra_client\n```\n\n## Getting Started\n\nPlease follow the [installation procedure](#installation--usage) and then run the following:\n\n```python\nfrom __future__ import print_function\nimport time\nimport sra_client\nfrom sra_client.rest import ApiException\nfrom pprint import pprint\n\n# create an instance of the API class\napi_instance = sra_client.DefaultApi(sra_client.ApiClient(configuration))\nasset_data_a = 0xf47261b04c32345ced77393b3530b1eed0f346429d # str | The assetData value for the first asset in the pair. (optional)\nasset_data_b = 0x0257179264389b814a946f3e92105513705ca6b990 # str | The assetData value for the second asset in the pair. (optional)\nnetwork_id = 42 # float | The id of the Ethereum network (optional) (default to 1)\npage = 3 # float | The number of the page to request in the collection. (optional) (default to 1)\nper_page = 10 # float | The number of records to return per page. (optional) (default to 100)\n\ntry:\n api_response = api_instance.get_asset_pairs(asset_data_a=asset_data_a, asset_data_b=asset_data_b, network_id=network_id, page=page, per_page=per_page)\n pprint(api_response)\nexcept ApiException as e:\n print(\"Exception when calling DefaultApi->get_asset_pairs: %s\\n\" % e)\n```\n\n## Contributing\n\nWe welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.\n\nPlease read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.\n\n### Install Code and Dependencies\n\nEnsure that you have installed Python >=3.6, Docker, and docker-compose. Then:\n\n```bash\npip install -e .[dev]\n```\n\n### Test\n\nTests depend on a running instance of 0x-launch-kit-backend, backed by a Ganache node with the 0x contracts deployed in it. For convenience, a docker-compose file is provided that creates this environment. And a shortcut is provided to interface with that file: `./setup.py start_test_relayer` will start those services. With them running, the tests can be run with `./setup.py test`. When you're done with testing, you can `./setup.py stop_test_relayer`.\n\n### Clean\n\n`./setup.py clean --all`\n\n### Lint\n\n`./setup.py lint`\n\n### Build Documentation\n\n`./setup.py build_sphinx`\n\n### More\n\nSee `./setup.py --help-commands` for more info.\n\n## Documentation for API Endpoints\n\nAll URIs are relative to _http://localhost_\n\n| Class | Method | HTTP request | Description |\n| ------------ | --------------------------------------------------------------- | ----------------------------- | ----------- |\n| _DefaultApi_ | [**get_asset_pairs**](docs/DefaultApi.md#get_asset_pairs) | **GET** /v2/asset_pairs |\n| _DefaultApi_ | [**get_fee_recipients**](docs/DefaultApi.md#get_fee_recipients) | **GET** /v2/fee_recipients |\n| _DefaultApi_ | [**get_order**](docs/DefaultApi.md#get_order) | **GET** /v2/order/{orderHash} |\n| _DefaultApi_ | [**get_order_config**](docs/DefaultApi.md#get_order_config) | **POST** /v2/order_config |\n| _DefaultApi_ | [**get_orderbook**](docs/DefaultApi.md#get_orderbook) | **GET** /v2/orderbook |\n| _DefaultApi_ | [**get_orders**](docs/DefaultApi.md#get_orders) | **GET** /v2/orders |\n| _DefaultApi_ | [**post_order**](docs/DefaultApi.md#post_order) | **POST** /v2/order |\n\n## Documentation For Models\n\n- [OrderSchema](docs/OrderSchema.md)\n- [PaginatedCollectionSchema](docs/PaginatedCollectionSchema.md)\n- [RelayerApiAssetDataPairsResponseSchema](docs/RelayerApiAssetDataPairsResponseSchema.md)\n- [RelayerApiAssetDataTradeInfoSchema](docs/RelayerApiAssetDataTradeInfoSchema.md)\n- [RelayerApiErrorResponseSchema](docs/RelayerApiErrorResponseSchema.md)\n- [RelayerApiErrorResponseSchemaValidationErrors](docs/RelayerApiErrorResponseSchemaValidationErrors.md)\n- [RelayerApiFeeRecipientsResponseSchema](docs/RelayerApiFeeRecipientsResponseSchema.md)\n- [RelayerApiOrderConfigPayloadSchema](docs/RelayerApiOrderConfigPayloadSchema.md)\n- [RelayerApiOrderConfigResponseSchema](docs/RelayerApiOrderConfigResponseSchema.md)\n- [RelayerApiOrderSchema](docs/RelayerApiOrderSchema.md)\n- [RelayerApiOrderbookResponseSchema](docs/RelayerApiOrderbookResponseSchema.md)\n- [RelayerApiOrdersChannelSubscribePayloadSchema](docs/RelayerApiOrdersChannelSubscribePayloadSchema.md)\n- [RelayerApiOrdersChannelSubscribeSchema](docs/RelayerApiOrdersChannelSubscribeSchema.md)\n- [RelayerApiOrdersChannelUpdateSchema](docs/RelayerApiOrdersChannelUpdateSchema.md)\n- [RelayerApiOrdersResponseSchema](docs/RelayerApiOrdersResponseSchema.md)\n- [SignedOrderSchema](docs/SignedOrderSchema.md)\n\n## Documentation For Authorization\n\nAll endpoints do not require authorization.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/0xproject/0x-monorepo/tree/development/python-packages/sra_client", "keywords": "OpenAPI,OpenAPI-Generator,Standard Relayer REST API", "license": "", "maintainer": "", "maintainer_email": "", "name": "0x-sra-client", "package_url": "https://pypi.org/project/0x-sra-client/", "platform": "", "project_url": "https://pypi.org/project/0x-sra-client/", "project_urls": { "Homepage": "https://github.com/0xproject/0x-monorepo/tree/development/python-packages/sra_client" }, "release_url": "https://pypi.org/project/0x-sra-client/3.0.0/", "requires_dist": [ "urllib3 (>=1.15)", "six (>=1.10)", "certifi", "python-dateutil", "0x-contract-artifacts ; extra == 'dev'", "0x-contract-addresses ; extra == 'dev'", "0x-order-utils ; extra == 'dev'", "web3 ; extra == 'dev'", "bandit ; extra == 'dev'", "black ; extra == 'dev'", "coverage ; extra == 'dev'", "coveralls ; extra == 'dev'", "pycodestyle ; extra == 'dev'", "pydocstyle ; extra == 'dev'", "pylint ; extra == 'dev'", "pytest ; extra == 'dev'", "sphinx ; extra == 'dev'", "sphinx-autodoc-typehints ; extra == 'dev'" ], "requires_python": "", "summary": "Standard Relayer REST API Client", "version": "3.0.0" }, "last_serial": 5652139, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "ea849e7ca0b7b8ce1b175fca5d5ba878", "sha256": "cd0652d8425ab972b013da83dc4e2cdd6e6d60cebf4d0760949ea353efa9808a" }, "downloads": -1, "filename": "0x_sra_client-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ea849e7ca0b7b8ce1b175fca5d5ba878", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 47142, "upload_time": "2018-12-12T00:53:51", "url": "https://files.pythonhosted.org/packages/18/1b/35733fae62f2a802250f54b1fd754903d6c13f8f6ba92a79fd349f1e66c5/0x_sra_client-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21714f397d31b1d211b9441f820787ec", "sha256": "709afcd1bcbdb04404704194d4678cc912ef2d8c98b7372322562b0ca5b65635" }, "downloads": -1, "filename": "0x-sra-client-1.0.0.tar.gz", "has_sig": false, "md5_digest": "21714f397d31b1d211b9441f820787ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28802, "upload_time": "2018-12-12T00:53:53", "url": "https://files.pythonhosted.org/packages/c7/c0/b1296e3f361784c5a55838870d76fb80c12e90a847aa823564427a18870d/0x-sra-client-1.0.0.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "f3898877ec1898a1885325b769bd3045", "sha256": "7e637de90f03120437e7183925aa663da42faa3fddb52ef512b9c7bd6afa4e2c" }, "downloads": -1, "filename": "0x_sra_client-3.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f3898877ec1898a1885325b769bd3045", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 52179, "upload_time": "2019-08-08T20:39:47", "url": "https://files.pythonhosted.org/packages/d3/88/8be3527feb86e011a6cfd74e072f6ac769a1a7bde5d9d9bc674edd60cacf/0x_sra_client-3.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "83a89138726d24dc8a4d748eed198352", "sha256": "27eeac99aed60d01fd3e260849ac5189831f581ca1247e142769b16118e20b0b" }, "downloads": -1, "filename": "0x-sra-client-3.0.0.tar.gz", "has_sig": false, "md5_digest": "83a89138726d24dc8a4d748eed198352", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35594, "upload_time": "2019-08-08T20:39:49", "url": "https://files.pythonhosted.org/packages/e0/32/13a61e160b9249365750b8870336d3cb9f09ac59caea9ee20f234544910d/0x-sra-client-3.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f3898877ec1898a1885325b769bd3045", "sha256": "7e637de90f03120437e7183925aa663da42faa3fddb52ef512b9c7bd6afa4e2c" }, "downloads": -1, "filename": "0x_sra_client-3.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f3898877ec1898a1885325b769bd3045", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 52179, "upload_time": "2019-08-08T20:39:47", "url": "https://files.pythonhosted.org/packages/d3/88/8be3527feb86e011a6cfd74e072f6ac769a1a7bde5d9d9bc674edd60cacf/0x_sra_client-3.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "83a89138726d24dc8a4d748eed198352", "sha256": "27eeac99aed60d01fd3e260849ac5189831f581ca1247e142769b16118e20b0b" }, "downloads": -1, "filename": "0x-sra-client-3.0.0.tar.gz", "has_sig": false, "md5_digest": "83a89138726d24dc8a4d748eed198352", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35594, "upload_time": "2019-08-08T20:39:49", "url": "https://files.pythonhosted.org/packages/e0/32/13a61e160b9249365750b8870336d3cb9f09ac59caea9ee20f234544910d/0x-sra-client-3.0.0.tar.gz" } ] }