554 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			554 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
# Class: HttpClient
 | 
						|
 | 
						|
This class includes all the functionality related to interacting with a set of HTTP endpoints
 | 
						|
that implement the standard relayer API v2
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **HttpClient**
 | 
						|
 | 
						|
### Implements
 | 
						|
 | 
						|
* [Client](#interface-client)
 | 
						|
 | 
						|
 | 
						|
### Constructors
 | 
						|
 | 
						|
##  constructer
 | 
						|
 | 
						|
\+ **new HttpClient**(`url`: string): *[HttpClient](#class-httpclient)*
 | 
						|
 | 
						|
*Defined in [http_client.ts:44](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L44)*
 | 
						|
 | 
						|
Instantiates a new HttpClient instance
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`url` | string | The relayer API base HTTP url you would like to interact with |
 | 
						|
 | 
						|
**Returns:** *[HttpClient](#class-httpclient)*
 | 
						|
 | 
						|
An instance of HttpClient
 | 
						|
 | 
						|
### Methods
 | 
						|
 | 
						|
##  getAssetPairsAsync
 | 
						|
 | 
						|
▸ **getAssetPairsAsync**(`requestOpts?`: `RequestOpts` & `AssetPairsRequestOpts` & `PagedRequestOpts`): *`Promise<AssetPairsResponse>`*
 | 
						|
 | 
						|
*Defined in [http_client.ts:59](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L59)*
 | 
						|
 | 
						|
Retrieve assetData pair info from the API
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`requestOpts?` | `RequestOpts` & `AssetPairsRequestOpts` & `PagedRequestOpts` | Options specifying assetData information to retrieve, page information, and network id. |
 | 
						|
 | 
						|
**Returns:** *`Promise<AssetPairsResponse>`*
 | 
						|
 | 
						|
The resulting AssetPairsResponse that match the request
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getFeeRecipientsAsync
 | 
						|
 | 
						|
▸ **getFeeRecipientsAsync**(`requestOpts?`: `RequestOpts` & `PagedRequestOpts`): *`Promise<FeeRecipientsResponse>`*
 | 
						|
 | 
						|
*Defined in [http_client.ts:160](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L160)*
 | 
						|
 | 
						|
Retrieve the list of fee recipient addresses used by the relayer.
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`requestOpts?` | `RequestOpts` & `PagedRequestOpts` | Options specifying page information, and network id. |
 | 
						|
 | 
						|
**Returns:** *`Promise<FeeRecipientsResponse>`*
 | 
						|
 | 
						|
The resulting FeeRecipientsResponse
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrderAsync
 | 
						|
 | 
						|
▸ **getOrderAsync**(`orderHash`: string, `requestOpts?`: `RequestOpts`): *`Promise<APIOrder>`*
 | 
						|
 | 
						|
*Defined in [http_client.ts:99](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L99)*
 | 
						|
 | 
						|
Retrieve a specific order from the API
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`orderHash` | string | An orderHash generated from the desired order |
 | 
						|
`requestOpts?` | `RequestOpts` | - |
 | 
						|
 | 
						|
**Returns:** *`Promise<APIOrder>`*
 | 
						|
 | 
						|
The APIOrder that matches the supplied orderHash
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrderConfigAsync
 | 
						|
 | 
						|
▸ **getOrderConfigAsync**(`request`: `OrderConfigRequest`, `requestOpts?`: `RequestOpts`): *`Promise<OrderConfigResponse>`*
 | 
						|
 | 
						|
*Defined in [http_client.ts:139](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L139)*
 | 
						|
 | 
						|
Retrieve fee information from the API
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`request` | `OrderConfigRequest` | A OrderConfigRequest instance describing the specific fees to retrieve |
 | 
						|
`requestOpts?` | `RequestOpts` | Options specifying network id. |
 | 
						|
 | 
						|
**Returns:** *`Promise<OrderConfigResponse>`*
 | 
						|
 | 
						|
The resulting OrderConfigResponse that matches the request
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrderbookAsync
 | 
						|
 | 
						|
▸ **getOrderbookAsync**(`request`: `OrderbookRequest`, `requestOpts?`: `RequestOpts` & `PagedRequestOpts`): *`Promise<OrderbookResponse>`*
 | 
						|
 | 
						|
*Defined in [http_client.ts:117](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L117)*
 | 
						|
 | 
						|
Retrieve an orderbook from the API
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`request` | `OrderbookRequest` | An OrderbookRequest instance describing the specific orderbook to retrieve |
 | 
						|
`requestOpts?` | `RequestOpts` & `PagedRequestOpts` | Options specifying page information, and network id. |
 | 
						|
 | 
						|
**Returns:** *`Promise<OrderbookResponse>`*
 | 
						|
 | 
						|
The resulting OrderbookResponse that matches the request
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrdersAsync
 | 
						|
 | 
						|
▸ **getOrdersAsync**(`requestOpts?`: `RequestOpts` & `OrdersRequestOpts` & `PagedRequestOpts`): *`Promise<OrdersResponse>`*
 | 
						|
 | 
						|
*Defined in [http_client.ts:79](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L79)*
 | 
						|
 | 
						|
Retrieve orders from the API
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`requestOpts?` | `RequestOpts` & `OrdersRequestOpts` & `PagedRequestOpts` | Options specifying orders to retrieve and page information, page information, and network id. |
 | 
						|
 | 
						|
**Returns:** *`Promise<OrdersResponse>`*
 | 
						|
 | 
						|
The resulting OrdersResponse that match the request
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  submitOrderAsync
 | 
						|
 | 
						|
▸ **submitOrderAsync**(`signedOrder`: `SignedOrder`, `requestOpts?`: `RequestOpts`): *`Promise<void>`*
 | 
						|
 | 
						|
*Defined in [http_client.ts:177](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/http_client.ts#L177)*
 | 
						|
 | 
						|
Submit a signed order to the API
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`signedOrder` | `SignedOrder` | A SignedOrder instance to submit |
 | 
						|
`requestOpts?` | `RequestOpts` | Options specifying network id.  |
 | 
						|
 | 
						|
**Returns:** *`Promise<void>`*
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Class: WebSocketOrdersChannel
 | 
						|
 | 
						|
This class includes all the functionality related to interacting with a websocket endpoint
 | 
						|
that implements the standard relayer API v0
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **WebSocketOrdersChannel**
 | 
						|
 | 
						|
### Implements
 | 
						|
 | 
						|
* [OrdersChannel](#interface-orderschannel)
 | 
						|
 | 
						|
 | 
						|
### Constructors
 | 
						|
 | 
						|
##  constructer
 | 
						|
 | 
						|
\+ **new WebSocketOrdersChannel**(`client`: `w3cwebsocket`, `handler`: [OrdersChannelHandler](#interface-orderschannelhandler)): *[WebSocketOrdersChannel](#class-websocketorderschannel)*
 | 
						|
 | 
						|
*Defined in [ws_orders_channel.ts:21](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/ws_orders_channel.ts#L21)*
 | 
						|
 | 
						|
Instantiates a new WebSocketOrdersChannel instance
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`client` | `w3cwebsocket` | A WebSocket client |
 | 
						|
`handler` | [OrdersChannelHandler](#interface-orderschannelhandler) | An OrdersChannelHandler instance that responds to various                               channel updates |
 | 
						|
 | 
						|
**Returns:** *[WebSocketOrdersChannel](#class-websocketorderschannel)*
 | 
						|
 | 
						|
An instance of WebSocketOrdersChannel
 | 
						|
 | 
						|
### Methods
 | 
						|
 | 
						|
##  close
 | 
						|
 | 
						|
▸ **close**(): *void*
 | 
						|
 | 
						|
*Defined in [ws_orders_channel.ts:66](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/ws_orders_channel.ts#L66)*
 | 
						|
 | 
						|
Close the websocket and stop receiving updates
 | 
						|
 | 
						|
**Returns:** *void*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  subscribe
 | 
						|
 | 
						|
▸ **subscribe**(`subscriptionOpts`: `OrdersChannelSubscriptionOpts`): *void*
 | 
						|
 | 
						|
*Defined in [ws_orders_channel.ts:50](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/ws_orders_channel.ts#L50)*
 | 
						|
 | 
						|
Subscribe to orderbook snapshots and updates from the websocket
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type | Description |
 | 
						|
------ | ------ | ------ |
 | 
						|
`subscriptionOpts` | `OrdersChannelSubscriptionOpts` | An OrdersChannelSubscriptionOpts instance describing which                               assetData pair to subscribe to  |
 | 
						|
 | 
						|
**Returns:** *void*
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Enumeration: HttpRequestType
 | 
						|
 | 
						|
 | 
						|
### Enumeration members
 | 
						|
 | 
						|
##  Get
 | 
						|
 | 
						|
• **Get**: = "GET"
 | 
						|
 | 
						|
*Defined in [types.ts:46](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L46)*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  Post
 | 
						|
 | 
						|
• **Post**: = "POST"
 | 
						|
 | 
						|
*Defined in [types.ts:47](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L47)*
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Interface: Client
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **Client**
 | 
						|
 | 
						|
### Implemented by
 | 
						|
 | 
						|
* [HttpClient](#class-httpclient)
 | 
						|
 | 
						|
 | 
						|
### Properties
 | 
						|
 | 
						|
##  getAssetPairsAsync
 | 
						|
 | 
						|
• **getAssetPairsAsync**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:18](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L18)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`requestOpts?`: `AssetPairsRequestOpts` & `PagedRequestOpts`): *`Promise<PaginatedCollection<AssetPairsItem>>`*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`requestOpts?` | `AssetPairsRequestOpts` & `PagedRequestOpts` |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getFeeRecipientsAsync
 | 
						|
 | 
						|
• **getFeeRecipientsAsync**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:25](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L25)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`requestOpts?`: `PagedRequestOpts`): *`Promise<FeeRecipientsResponse>`*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`requestOpts?` | `PagedRequestOpts` |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrderAsync
 | 
						|
 | 
						|
• **getOrderAsync**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:22](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L22)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`orderHash`: string): *`Promise<APIOrder>`*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`orderHash` | string |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrderConfigAsync
 | 
						|
 | 
						|
• **getOrderConfigAsync**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:24](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L24)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`request`: `OrderConfigRequest`): *`Promise<OrderConfigResponse>`*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`request` | `OrderConfigRequest` |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrderbookAsync
 | 
						|
 | 
						|
• **getOrderbookAsync**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:23](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L23)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`request`: `OrderbookRequest`, `requestOpts?`: `PagedRequestOpts`): *`Promise<OrderbookResponse>`*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`request` | `OrderbookRequest` |
 | 
						|
`requestOpts?` | `PagedRequestOpts` |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  getOrdersAsync
 | 
						|
 | 
						|
• **getOrdersAsync**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:21](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L21)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`requestOpts?`: `OrdersRequestOpts` & `PagedRequestOpts`): *`Promise<PaginatedCollection<APIOrder>>`*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`requestOpts?` | `OrdersRequestOpts` & `PagedRequestOpts` |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  submitOrderAsync
 | 
						|
 | 
						|
• **submitOrderAsync**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:26](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L26)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`signedOrder`: `SignedOrder`): *`Promise<void>`*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`signedOrder` | `SignedOrder` |
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Interface: HttpRequestOptions
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **HttpRequestOptions**
 | 
						|
 | 
						|
 | 
						|
### Properties
 | 
						|
 | 
						|
## `Optional` params
 | 
						|
 | 
						|
• **params**? : *undefined | object*
 | 
						|
 | 
						|
*Defined in [types.ts:41](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L41)*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
## `Optional` payload
 | 
						|
 | 
						|
• **payload**? : *undefined | object*
 | 
						|
 | 
						|
*Defined in [types.ts:42](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L42)*
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Interface: OrdersChannel
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **OrdersChannel**
 | 
						|
 | 
						|
### Implemented by
 | 
						|
 | 
						|
* [WebSocketOrdersChannel](#class-websocketorderschannel)
 | 
						|
 | 
						|
 | 
						|
### Properties
 | 
						|
 | 
						|
##  close
 | 
						|
 | 
						|
• **close**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:31](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L31)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (): *void*
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  subscribe
 | 
						|
 | 
						|
• **subscribe**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:30](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L30)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`subscriptionOpts`: `OrdersChannelSubscriptionOpts`): *void*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`subscriptionOpts` | `OrdersChannelSubscriptionOpts` |
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Interface: OrdersChannelHandler
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **OrdersChannelHandler**
 | 
						|
 | 
						|
 | 
						|
### Properties
 | 
						|
 | 
						|
##  onClose
 | 
						|
 | 
						|
• **onClose**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:37](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L37)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`channel`: [OrdersChannel](#interface-orderschannel)): *void*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`channel` | [OrdersChannel](#interface-orderschannel) |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  onError
 | 
						|
 | 
						|
• **onError**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:36](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L36)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`channel`: [OrdersChannel](#interface-orderschannel), `err`: `Error`, `subscriptionOpts?`: `OrdersChannelSubscriptionOpts`): *void*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`channel` | [OrdersChannel](#interface-orderschannel) |
 | 
						|
`err` | `Error` |
 | 
						|
`subscriptionOpts?` | `OrdersChannelSubscriptionOpts` |
 | 
						|
 | 
						|
___
 | 
						|
 | 
						|
##  onUpdate
 | 
						|
 | 
						|
• **onUpdate**: *function*
 | 
						|
 | 
						|
*Defined in [types.ts:35](https://github.com/0xProject/0x-monorepo/blob/6474a4e08/packages/connect/src/types.ts#L35)*
 | 
						|
 | 
						|
#### Type declaration:
 | 
						|
 | 
						|
▸ (`channel`: [OrdersChannel](#interface-orderschannel), `subscriptionOpts`: `OrdersChannelSubscriptionOpts`, `orders`: `APIOrder`[]): *void*
 | 
						|
 | 
						|
**Parameters:**
 | 
						|
 | 
						|
Name | Type |
 | 
						|
------ | ------ |
 | 
						|
`channel` | [OrdersChannel](#interface-orderschannel) |
 | 
						|
`subscriptionOpts` | `OrdersChannelSubscriptionOpts` |
 | 
						|
`orders` | `APIOrder`[] |
 | 
						|
 | 
						|
<hr />
 | 
						|
 | 
						|
# Interface: OrdersChannelSubscriptionOptsMap
 | 
						|
 | 
						|
### Hierarchy
 | 
						|
 | 
						|
* **OrdersChannelSubscriptionOptsMap**
 | 
						|
 | 
						|
### Indexable
 | 
						|
 | 
						|
● \[▪ **key**: *string*\]: `OrdersChannelSubscriptionOpts`
 | 
						|
 | 
						|
<hr />
 | 
						|
 |