- MPXAPIError
MPXAPIError represents an Error that is gotten from the api response. It is usually returned as an Array of MPXAPIError.
- Path :
object
Path constants that should be used when calling any of the
get
,post
, etc. functions on the mpxAPI client- mpxAPI :
object
mpxAPI client namespace object.
Use the methods on this to to make requests
- ResponseHandler :
function
Callback for handling a response. Error would usually be an array of MPXAPIErrors.
- RequestOptions :
Object
Extra Options objects that are passed to request methods on the
MPXAPIError represents an Error that is gotten from the api response. It is usually returned as an Array of MPXAPIError.
Param | Type |
---|---|
error | Error |
Path constants that should be used when calling any of the get
, post
, etc.
functions on the mpxAPI client
Kind: global namespace
- Path :
object
Path to list a summary of all resources and their actions.
Kind: static property of Path
Path to contract resources.
Kind: static property of Path
Path to fee receipeint resources.
Kind: static property of Path
Path to fills resources.
Kind: static property of Path
Path to perform jwt authentication.
Kind: static property of Path
Path to profile of current authenticated user.
Kind: static property of Path
Path to orderbook resources.
Kind: static property of Path
Path to order resources on the API.
Kind: static property of Path
Path to API settings
Kind: static property of Path
Path to fetch token pairs on the API.
Kind: static property of Path
mpxAPI client namespace object.
Use the methods on this to to make requests
Kind: global namespace
Example
import { mpxAPI, Path } from '@marketprotocol/mpx-api-client'
mpxAPI.setHost('https://host-for-mpx-client');
// fetch all token pairs
mpxAPI.get(Path.TokenPairs)
.then(tokenPairs, () => {
// do what you want tokenPairs
});
- mpxAPI :
object
- .Path
- .setHost(newHost)
- .setGlobalResponseHandler(handler)
- .get(path, options) ⇒
Promise.<*>
- .post(path, body, options) ⇒
Promise.<*>
- .patch(path, body, options) ⇒
Promise.<*>
- .put(path, body, options) ⇒
Promise.<*>
- .delete(path, options) ⇒
Promise.<*>
Alias for the global named export Path
.
Added for convenience
Kind: static property of mpxAPI
Set host for mpx-api example https://api.mpxechange.io
Kind: static method of mpxAPI
Param | Type | Description |
---|---|---|
newHost | string |
apiHost |
Register a global response handler. All response from all requests would be send to this handler is set.
To unregister pass in a null handler argument.
Kind: static method of mpxAPI
Param | Type |
---|---|
handler | ResponseHandler |
Makes a GET request to the mpxAPI resource at path
.
Kind: static method of mpxAPI
Returns: Promise.<*>
- - Result of request
Param | Type | Description |
---|---|---|
path | string |
Path to request API |
options | RequestOptions |
Extra request options |
Makes a POST request to the mpxAPI resource at path
.
Kind: static method of mpxAPI
Returns: Promise.<*>
- result of request
Param | Type | Description |
---|---|---|
path | string |
Path to request API |
body | Object |
Request body payload |
options | RequestOptions |
Extra request options |
Makes a PATCH request to the marketAPI resource at path
.
Kind: static method of mpxAPI
Returns: Promise.<*>
- result of request
Param | Type | Description |
---|---|---|
path | string |
Path to request API |
body | Object |
Request body payload |
options | RequestOptions |
Extra request options |
Makes a PUT request to the marketAPI resource at path
.
Kind: static method of mpxAPI
Returns: Promise.<*>
- result of request
Param | Type | Description |
---|---|---|
path | string |
Path to request API |
body | Object |
Request body payload |
options | RequestOptions |
Extra request options |
Makes a DELETE request to the marketAPI resource at path
.
Kind: static method of mpxAPI
Returns: Promise.<*>
- result of request
Param | Type | Description |
---|---|---|
path | string |
Path to request API |
options | RequestOptions |
Extra request options |
Callback for handling a response. Error would usually be an array of MPXAPIErrors.
Kind: global typedef
Param | Type | Description |
---|---|---|
err | Error |
Error if any, null if no error |
data | object |
Parse json-api response data. |
Extra Options objects that are passed to request methods on the
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | string |
String value that overrides the id on the resource being requested. defaults to null . |
filterString | string |
Filter string, primarily used in get requests. defaults to null . |
serializeRequest | boolean |
Flag to state if the payload has should be json-api serialized. defaults to true . |
deserialize | boolean |
Flag to state if the response from a request should be json-api deserialized or note. defaults to false . |
authorizationToken | string |
Authorization token. Required for request to authenticated paths. |