1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
|
{
"openapi": "3.0.0",
"info": {
"version": "2.0.0",
"title": "Standard Relayer REST API",
"description":
"# Testing\n\nUse the [sra-report](https://github.com/0xProject/0x-monorepo/tree/development/packages/sra-report) command line tool to test your API for SRA compliance.\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```bash\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```js\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# 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: <https://api.example-relayer.com/v2/asset_pairs?page=3&perPage=20>; rel=\"next\",\n<https://api.github.com/user/repos?page=10&perPage=20>; 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 – 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 0x08e937fa\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: 0x08e937fa) would be:\n\n```bash\n0x08e937fa000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063\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",
"license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }
},
"paths": {
"/v2/asset_pairs": {
"get": {
"description":
"Retrieves a list of available asset pairs and the information required to trade them (in any order). Setting only `assetDataA` or `assetDataB` returns pairs filtered by that asset only.",
"operationId": "getAssetPairs",
"parameters": [
{
"name": "networkId",
"in": "query",
"description": "The id of the Ethereum network",
"example": 42,
"schema": { "type": "number" }
},
{
"name": "page",
"in": "query",
"description": "The number of the page to request in the collection.",
"example": 3,
"schema": { "type": "number" }
},
{
"name": "perPage",
"in": "query",
"description": "The number of records to return per page.",
"example": 10,
"schema": { "type": "number" }
},
{
"name": "assetDataA",
"in": "query",
"description": "The assetData value for the first asset in the pair.",
"example": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"schema": { "$ref": "#/components/schemas/hexSchema" }
},
{
"name": "assetDataB",
"in": "query",
"description": "The assetData value for the second asset in the pair.",
"example": "0x0257179264389b814a946f3e92105513705ca6b990",
"schema": { "$ref": "#/components/schemas/hexSchema" }
}
],
"responses": {
"200": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The maximum number of requests you're permitted to make per hour.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Remaining": {
"description": "The number of requests remaining in the current rate limit window.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Reset": {
"description":
"The time at which the current rate limit window resets in UTC epoch seconds.",
"schema": { "type": "integer" }
}
},
"description": "Returns a collection of available asset pairs with some meta info",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiAssetDataPairsResponseSchema" },
"example": {
"total": 43,
"page": 1,
"perPage": 100,
"records": [
{
"assetDataA": {
"minAmount": "0",
"maxAmount": "10000000000000000000",
"precision": 5,
"assetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d"
},
"assetDataB": {
"minAmount": "0",
"maxAmount": "50000000000000000000",
"precision": 5,
"assetData": "0x0257179264389b814a946f3e92105513705ca6b990"
}
}
]
}
}
}
},
"400": {
"description": "Validation error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiErrorResponseSchema" },
"example": {
"code": 100,
"reason": "Validation failed",
"validationErrors": [
{
"field": "networkId",
"code": 1006,
"reason": "Network id 42 is not supported"
}
]
}
}
}
},
"404": { "description": "Not found" },
"429": { "description": "Too many requests - Rate limit exceeded" },
"500": { "description": "Internal Server Error" },
"501": { "description": "Not implemented." }
}
}
},
"/v2/orders": {
"get": {
"description":
"Retrieves a list of orders given query parameters. This endpoint should be [paginated](#section/Pagination). For querying an entire orderbook snapshot, the [orderbook endpoint](#operation/getOrderbook) is recommended. If both makerAssetData and takerAssetData are specified, returned orders will be sorted by price determined by (takerTokenAmount/makerTokenAmount) in ascending order. By default, orders returned by this endpoint are unsorted.",
"operationId": "getOrders",
"parameters": [
{
"name": "networkId",
"in": "query",
"description": "The id of the Ethereum network",
"example": 42,
"schema": { "type": "number" }
},
{
"name": "page",
"in": "query",
"description": "The number of the page to request in the collection.",
"example": 3,
"schema": { "type": "number" }
},
{
"name": "perPage",
"in": "query",
"description": "The number of records to return per page.",
"example": 10,
"schema": { "type": "number" }
},
{
"name": "makerAssetProxyId",
"in": "query",
"description":
"The maker [asset proxy id](https://0xproject.com/docs/0x.js#types-AssetProxyId) (example: \"0xf47261b0\" for ERC20, \"0x02571792\" for ERC721).",
"example": "0xf47261b0",
"schema": { "$ref": "#/components/schemas/hexSchema" }
},
{
"name": "takerAssetProxyId",
"in": "query",
"description":
"The taker asset [asset proxy id](https://0xproject.com/docs/0x.js#types-AssetProxyId) (example: \"0xf47261b0\" for ERC20, \"0x02571792\" for ERC721).",
"example": "0x02571792",
"schema": { "$ref": "#/components/schemas/hexSchema" }
},
{
"name": "makerAssetAddress",
"in": "query",
"description": "The contract address for the maker asset.",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/addressSchema" }
},
{
"name": "takerAssetAddress",
"in": "query",
"description": "The contract address for the taker asset.",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/addressSchema" }
},
{
"name": "exchangeAddress",
"in": "query",
"description":
"Same as exchangeAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/addressSchema" }
},
{
"name": "senderAddress",
"in": "query",
"description":
"Same as senderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/addressSchema" }
},
{
"name": "makerAssetData",
"in": "query",
"description":
"Same as makerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/hexSchema" }
},
{
"name": "takerAssetData",
"in": "query",
"description":
"Same as takerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/hexSchema" }
},
{
"name": "traderAssetData",
"in": "query",
"description":
"Same as traderAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/hexSchema" }
},
{
"name": "makerAddress",
"in": "query",
"description":
"Same as makerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/addressSchema" }
},
{
"name": "traderAddress",
"in": "query",
"description":
"Same as traderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/addressSchema" }
},
{
"name": "feeRecipientAddress",
"in": "query",
"description":
"Same as feeRecipientAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)",
"example": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"schema": { "$ref": "#/components/schemas/addressSchema" }
}
],
"responses": {
"200": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The maximum number of requests you're permitted to make per hour.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Remaining": {
"description": "The number of requests remaining in the current rate limit window.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Reset": {
"description":
"The time at which the current rate limit window resets in UTC epoch seconds.",
"schema": { "type": "integer" }
}
},
"description": "A collection of 0x orders with meta-data as specified by query params",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiOrdersResponseSchema" },
"example": {
"total": 984,
"page": 1,
"perPage": 100,
"records": [
{
"order": {
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"signature":
"0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
},
"metaData": {}
}
]
}
}
}
},
"400": {
"description": "Validation error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiErrorResponseSchema" },
"example": {
"code": 100,
"reason": "Validation failed",
"validationErrors": [
{
"field": "networkId",
"code": 1006,
"reason": "Network id 42 is not supported"
}
]
}
}
}
},
"404": { "description": "Not found" },
"429": { "description": "Too many requests - Rate limit exceeded" },
"500": { "description": "Internal Server Error" },
"501": { "description": "Not implemented." }
}
}
},
"/v2/order/{orderHash}": {
"get": {
"description": "Retrieves the 0x order with meta info that is associated with the hash.",
"operationId": "getOrder",
"parameters": [
{
"name": "networkId",
"in": "query",
"description": "The id of the Ethereum network",
"example": 42,
"schema": { "type": "number" }
},
{
"name": "orderHash",
"in": "path",
"description": "The hash of the desired 0x order.",
"example": "0xd4b103c42d2512eef3fee775e097f044291615d25f5d71e0ac70dbd49d223591",
"schema": { "$ref": "#/components/schemas/orderHashSchema" }
}
],
"responses": {
"200": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The maximum number of requests you're permitted to make per hour.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Remaining": {
"description": "The number of requests remaining in the current rate limit window.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Reset": {
"description":
"The time at which the current rate limit window resets in UTC epoch seconds.",
"schema": { "type": "integer" }
}
},
"description": "The order and meta info associated with the orderHash",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiOrderSchema" },
"example": {
"order": {
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"signature":
"0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
},
"metaData": {}
}
}
}
},
"400": {
"description": "Validation error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiErrorResponseSchema" },
"example": {
"code": 100,
"reason": "Validation failed",
"validationErrors": [
{
"field": "networkId",
"code": 1006,
"reason": "Network id 42 is not supported"
}
]
}
}
}
},
"404": { "description": "Not found" },
"429": { "description": "Too many requests - Rate limit exceeded" },
"500": { "description": "Internal Server Error" },
"501": { "description": "Not implemented." }
}
}
},
"/v2/orderbook": {
"get": {
"description":
"Retrieves the orderbook for a given asset pair. This endpoint should be [paginated](#section/Pagination). Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by _taker fee price_ which is defined as the **takerFee** divided by **takerTokenAmount**. After _taker fee price_, orders are to be sorted by expiration in ascending order. The way pagination works for this endpoint is that the **page** and **perPage** query params apply to both `bids` and `asks` collections, and if `page` * `perPage` > `total` for a certain collection, the `records` for that collection should just be empty. ",
"operationId": "getOrderbook",
"parameters": [
{
"name": "networkId",
"in": "query",
"description": "The id of the Ethereum network",
"example": 42,
"schema": { "type": "number" }
},
{
"name": "page",
"in": "query",
"description": "The number of the page to request in the collection.",
"example": 3,
"schema": { "type": "number" }
},
{
"name": "perPage",
"in": "query",
"description": "The number of records to return per page.",
"example": 10,
"schema": { "type": "number" }
},
{
"name": "baseAssetData",
"in": "query",
"description":
"assetData (makerAssetData or takerAssetData) designated as the base currency in the [currency pair calculation](https://en.wikipedia.org/wiki/Currency_pair) of price.",
"required": true,
"example": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"schema": { "$ref": "#/components/schemas/hexSchema" }
},
{
"name": "quoteAssetData",
"in": "query",
"description":
"assetData (makerAssetData or takerAssetData) designated as the quote currency in the currency pair calculation of price (required).",
"required": true,
"example": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"schema": { "$ref": "#/components/schemas/hexSchema" }
}
],
"responses": {
"200": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The maximum number of requests you're permitted to make per hour.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Remaining": {
"description": "The number of requests remaining in the current rate limit window.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Reset": {
"description":
"The time at which the current rate limit window resets in UTC epoch seconds.",
"schema": { "type": "integer" }
}
},
"description": "The sorted order book for the specified asset pair.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiOrderbookResponseSchema" },
"example": {
"bids": {
"total": 325,
"page": 2,
"perPage": 100,
"records": [
{
"order": {
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"signature":
"0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
},
"metaData": {}
}
]
},
"asks": {
"total": 500,
"page": 2,
"perPage": 100,
"records": [
{
"order": {
"makerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"takerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "20000000000000000",
"takerAssetAmount": "10000000000000000",
"makerFee": "200000000000000",
"takerFee": "100000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
"takerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"signature":
"0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891"
},
"metaData": {}
}
]
}
}
}
}
},
"400": {
"description": "Validation error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiErrorResponseSchema" },
"example": {
"code": 100,
"reason": "Validation failed",
"validationErrors": [
{
"field": "networkId",
"code": 1006,
"reason": "Network id 42 is not supported"
}
]
}
}
}
},
"404": { "description": "Not found" },
"429": { "description": "Too many requests - Rate limit exceeded" },
"500": { "description": "Internal Server Error" },
"501": { "description": "Not implemented." }
}
}
},
"/v2/order_config": {
"get": {
"description":
"Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: `senderAddress`, `feeRecipientAddress`, `makerFee`, `takerFee`. ",
"operationId": "getOrderConfig",
"parameters": [
{
"name": "networkId",
"in": "query",
"description": "The id of the Ethereum network",
"example": 42,
"schema": { "type": "number" }
}
],
"requestBody": {
"description":
"The fields of a 0x order the relayer may want to decide what configuration to send back.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiOrderConfigPayloadSchema" },
"example": {
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"expirationTimeSeconds": "1532560590"
}
}
}
},
"responses": {
"200": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The maximum number of requests you're permitted to make per hour.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Remaining": {
"description": "The number of requests remaining in the current rate limit window.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Reset": {
"description":
"The time at which the current rate limit window resets in UTC epoch seconds.",
"schema": { "type": "integer" }
}
},
"description": "The additional fields necessary in order to submit an order to the relayer.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiOrderConfigResponseSchema" },
"example": {
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"makerFee": "100000000000000",
"takerFee": "200000000000000"
}
}
}
},
"400": {
"description": "Validation error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiErrorResponseSchema" },
"example": {
"code": 100,
"reason": "Validation failed",
"validationErrors": [
{
"field": "networkId",
"code": 1006,
"reason": "Network id 42 is not supported"
}
]
}
}
}
},
"404": { "description": "Not found" },
"429": { "description": "Too many requests - Rate limit exceeded" },
"500": { "description": "Internal Server Error" },
"501": { "description": "Not implemented." }
}
}
},
"/v2/fee_recipients": {
"get": {
"description":
"Retrieves a collection of all fee recipient addresses for a relayer. This endpoint should be [paginated](#section/Pagination).",
"operationId": "getFeeRecipients",
"parameters": [
{
"name": "networkId",
"in": "query",
"description": "The id of the Ethereum network",
"example": 42,
"schema": { "type": "number" }
},
{
"name": "page",
"in": "query",
"description": "The number of the page to request in the collection.",
"example": 3,
"schema": { "type": "number" }
},
{
"name": "perPage",
"in": "query",
"description": "The number of records to return per page.",
"example": 10,
"schema": { "type": "number" }
}
],
"responses": {
"200": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The maximum number of requests you're permitted to make per hour.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Remaining": {
"description": "The number of requests remaining in the current rate limit window.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Reset": {
"description":
"The time at which the current rate limit window resets in UTC epoch seconds.",
"schema": { "type": "integer" }
}
},
"description": "A collection of all used fee recipient addresses.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiFeeRecipientsResponseSchema" },
"example": {
"total": 3,
"page": 1,
"perPage": 10,
"records": [
"0x6eC92694ea172ebC430C30fa31De87620967A082",
"0x9e56625509c2f60af937f23b7b532600390e8c8b",
"0xa2b31dacf30a9c50ca473337c01d8a201ae33e32"
]
}
}
}
},
"400": {
"description": "Validation error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiErrorResponseSchema" },
"example": {
"code": 100,
"reason": "Validation failed",
"validationErrors": [
{
"field": "networkId",
"code": 1006,
"reason": "Network id 42 is not supported"
}
]
}
}
}
},
"404": { "description": "Not found" },
"429": { "description": "Too many requests - Rate limit exceeded" },
"500": { "description": "Internal Server Error" },
"501": { "description": "Not implemented." }
}
}
},
"/v2/order": {
"post": {
"description": "Submit a signed order to the relayer.",
"operationId": "postOrder",
"parameters": [
{
"name": "networkId",
"in": "query",
"description": "The id of the Ethereum network",
"example": 42,
"schema": { "type": "number" }
}
],
"requestBody": {
"description": "A valid signed 0x order based on the schema.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/signedOrderSchema" },
"example": {
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
}
}
}
},
"responses": {
"200": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The maximum number of requests you're permitted to make per hour.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Remaining": {
"description": "The number of requests remaining in the current rate limit window.",
"schema": { "type": "integer" }
},
"X-Rate-Limit-Reset": {
"description":
"The time at which the current rate limit window resets in UTC epoch seconds.",
"schema": { "type": "integer" }
}
},
"description": "OK",
"content": {}
},
"400": {
"description": "Validation error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/relayerApiErrorResponseSchema" },
"example": {
"code": 100,
"reason": "Validation failed",
"validationErrors": [
{
"field": "networkId",
"code": 1006,
"reason": "Network id 42 is not supported"
}
]
}
}
}
},
"404": { "description": "Not found" },
"429": { "description": "Too many requests - Rate limit exceeded" },
"500": { "description": "Internal Server Error" },
"501": { "description": "Not implemented." }
}
}
}
},
"components": {
"schemas": {
"numberSchema": { "type": "string", "pattern": "^\\d+(\\.\\d+)?$" },
"addressSchema": { "type": "string", "pattern": "^0x[0-9a-f]{40}$" },
"hexSchema": { "type": "string", "pattern": "^0x(([0-9a-f][0-9a-f])+)?$" },
"orderHashSchema": { "type": "string", "pattern": "^0x[0-9a-fA-F]{64}$" },
"orderSchema": {
"properties": {
"makerAddress": { "$ref": "#/components/schemas/addressSchema" },
"takerAddress": { "$ref": "#/components/schemas/addressSchema" },
"makerFee": { "$ref": "#/components/schemas/numberSchema" },
"takerFee": { "$ref": "#/components/schemas/numberSchema" },
"senderAddress": { "$ref": "#/components/schemas/addressSchema" },
"makerAssetAmount": { "$ref": "#/components/schemas/numberSchema" },
"takerAssetAmount": { "$ref": "#/components/schemas/numberSchema" },
"makerAssetData": { "$ref": "#/components/schemas/hexSchema" },
"takerAssetData": { "$ref": "#/components/schemas/hexSchema" },
"salt": { "$ref": "#/components/schemas/numberSchema" },
"exchangeAddress": { "$ref": "#/components/schemas/addressSchema" },
"feeRecipientAddress": { "$ref": "#/components/schemas/addressSchema" },
"expirationTimeSeconds": { "$ref": "#/components/schemas/numberSchema" }
},
"required": [
"makerAddress",
"takerAddress",
"makerFee",
"takerFee",
"senderAddress",
"makerAssetAmount",
"takerAssetAmount",
"makerAssetData",
"takerAssetData",
"salt",
"exchangeAddress",
"feeRecipientAddress",
"expirationTimeSeconds"
],
"type": "object"
},
"signedOrderSchema": {
"allOf": [
{ "$ref": "#/components/schemas/orderSchema" },
{
"properties": { "signature": { "$ref": "#/components/schemas/hexSchema" } },
"required": ["signature"]
}
]
},
"signedOrdersSchema": { "type": "array", "items": { "$ref": "#/components/schemas/signedOrderSchema" } },
"ordersSchema": { "type": "array", "items": { "$ref": "#/components/schemas/orderSchema" } },
"paginatedCollectionSchema": {
"type": "object",
"properties": {
"total": { "type": "number" },
"perPage": { "type": "number" },
"page": { "type": "number" }
},
"required": ["total", "perPage", "page"]
},
"relayerApiErrorResponseSchema": {
"type": "object",
"properties": {
"code": { "type": "integer", "minimum": 100, "maximum": 103 },
"reason": { "type": "string" },
"validationErrors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"field": { "type": "string" },
"code": { "type": "integer", "minimum": 1000, "maximum": 1006 },
"reason": { "type": "string" }
},
"required": ["field", "code", "reason"]
}
}
},
"required": ["code", "reason"]
},
"relayerApiFeeRecipientsResponseSchema": {
"type": "object",
"allOf": [
{ "$ref": "#/components/schemas/paginatedCollectionSchema" },
{
"properties": { "records": { "$ref": "#/components/schemas/addressSchema" } },
"required": ["records"]
}
]
},
"relayerApiOrderSchema": {
"type": "object",
"properties": {
"order": { "$ref": "#/components/schemas/orderSchema" },
"metaData": { "type": "object" }
},
"required": ["order", "metaData"]
},
"relayerApiOrdersSchema": {
"type": "array",
"items": { "$ref": "#/components/schemas/relayerApiOrderSchema" }
},
"relayerApiOrderConfigPayloadSchema": {
"type": "object",
"properties": {
"makerAddress": { "$ref": "#/components/schemas/addressSchema" },
"takerAddress": { "$ref": "#/components/schemas/addressSchema" },
"makerAssetAmount": { "$ref": "#/components/schemas/numberSchema" },
"takerAssetAmount": { "$ref": "#/components/schemas/numberSchema" },
"makerAssetData": { "$ref": "#/components/schemas/hexSchema" },
"takerAssetData": { "$ref": "#/components/schemas/hexSchema" },
"exchangeAddress": { "$ref": "#/components/schemas/addressSchema" },
"expirationTimeSeconds": { "$ref": "#/components/schemas/numberSchema" }
},
"required": [
"makerAddress",
"takerAddress",
"makerAssetAmount",
"takerAssetAmount",
"makerAssetData",
"takerAssetData",
"exchangeAddress",
"expirationTimeSeconds"
]
},
"relayerApiOrderConfigResponseSchema": {
"type": "object",
"properties": {
"makerFee": { "$ref": "#/components/schemas/numberSchema" },
"takerFee": { "$ref": "#/components/schemas/numberSchema" },
"feeRecipientAddress": { "$ref": "#/components/schemas/addressSchema" },
"senderAddress": { "$ref": "#/components/schemas/addressSchema" }
},
"required": ["makerFee", "takerFee", "feeRecipientAddress", "senderAddress"]
},
"relayerApiOrderbookResponseSchema": {
"type": "object",
"properties": {
"bids": { "$ref": "#/components/schemas/relayerApiOrdersResponseSchema" },
"asks": { "$ref": "#/components/schemas/relayerApiOrdersResponseSchema" }
},
"required": ["bids", "asks"]
},
"relayerApiAssetDataPairsResponseSchema": {
"type": "object",
"allOf": [
{ "$ref": "#/components/schemas/paginatedCollectionSchema" },
{
"properties": { "records": { "$ref": "#/components/schemas/relayerApiAssetDataPairsSchema" } },
"required": ["records"]
}
]
},
"relayerApiAssetDataTradeInfoSchema": {
"type": "object",
"properties": {
"assetData": { "$ref": "#/components/schemas/hexSchema" },
"minAmount": { "$ref": "#/components/schemas/numberSchema" },
"maxAmount": { "$ref": "#/components/schemas/numberSchema" },
"precision": { "type": "number" }
},
"required": ["assetData"]
},
"relayerApiOrdersChannelSubscribeSchema": {
"type": "object",
"properties": {
"type": { "enum": ["subscribe"] },
"channel": { "enum": ["orders"] },
"requestId": { "type": "string" },
"payload": { "$ref": "#/components/schemas/relayerApiOrdersChannelSubscribePayload" }
},
"required": ["type", "channel", "requestId"]
},
"relayerApiOrdersChannelSubscribePayload": {
"type": "object",
"properties": {
"makerAssetProxyId": { "$ref": "#/components/schemas/hexSchema" },
"takerAssetProxyId": { "$ref": "#/components/schemas/hexSchema" },
"networkId": { "type": "number" },
"makerAssetAddress": { "$ref": "#/components/schemas/addressSchema" },
"takerAssetAddress": { "$ref": "#/components/schemas/addressSchema" },
"makerAssetData": { "$ref": "#/components/schemas/hexSchema" },
"takerAssetData": { "$ref": "#/components/schemas/hexSchema" },
"traderAssetData": { "$ref": "#/components/schemas/hexSchema" }
}
},
"relayerApiOrdersChannelUpdateSchema": {
"type": "object",
"properties": {
"type": { "enum": ["update"] },
"channel": { "enum": ["orders"] },
"requestId": { "type": "string" },
"payload": { "$ref": "#/components/schemas/relayerApiOrdersSchema" }
},
"required": ["type", "channel", "requestId"]
},
"relayerApiOrdersResponseSchema": {
"type": "object",
"allOf": [
{ "$ref": "#/components/schemas/paginatedCollectionSchema" },
{
"properties": { "records": { "$ref": "#/components/schemas/relayerApiOrdersSchema" } },
"required": ["records"]
}
]
},
"relayerApiAssetDataPairsSchema": {
"type": "array",
"items": {
"properties": {
"assetDataA": { "$ref": "#/components/schemas/relayerApiAssetDataTradeInfoSchema" },
"assetDataB": { "$ref": "#/components/schemas/relayerApiAssetDataTradeInfoSchema" }
},
"required": ["assetDataA", "assetDataB"],
"type": "object"
}
}
}
}
}
|