Skip to content

Latest commit

 

History

History
290 lines (209 loc) · 8.65 KB

api.md

File metadata and controls

290 lines (209 loc) · 8.65 KB

Classes

MPXAPIError

MPXAPIError represents an Error that is gotten from the api response. It is usually returned as an Array of MPXAPIError.

Objects

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

Typedefs

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

MPXAPIError represents an Error that is gotten from the api response. It is usually returned as an Array of MPXAPIError.

Kind: global class

new exports.MPXAPIError(error)

Param Type
error Error

Path : object

Path constants that should be used when calling any of the get, post, etc. functions on the mpxAPI client

Kind: global namespace

Path.Root

Path to list a summary of all resources and their actions.

Kind: static property of Path

Path.Contracts

Path to contract resources.

Kind: static property of Path

Path.FeeRecipients

Path to fee receipeint resources.

Kind: static property of Path

Path.Fills

Path to fills resources.

Kind: static property of Path

Path.JWT

Path to perform jwt authentication.

Kind: static property of Path

Path.Me

Path to profile of current authenticated user.

Kind: static property of Path

Path.OrderBook

Path to orderbook resources.

Kind: static property of Path

Path.Orders

Path to order resources on the API.

Kind: static property of Path

Path.Settings

Path to API settings

Kind: static property of Path

Path.TokenPairs

Path to fetch token pairs on the API.

Kind: static property of Path

mpxAPI : object

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.Path

Alias for the global named export Path. Added for convenience

Kind: static property of mpxAPI

mpxAPI.setHost(newHost)

Set host for mpx-api example https://api.mpxechange.io

Kind: static method of mpxAPI

Param Type Description
newHost string apiHost

mpxAPI.setGlobalResponseHandler(handler)

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

mpxAPI.get(path, options) ⇒ Promise.<*>

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

mpxAPI.post(path, body, options) ⇒ Promise.<*>

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

mpxAPI.patch(path, body, options) ⇒ Promise.<*>

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

mpxAPI.put(path, body, options) ⇒ Promise.<*>

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

mpxAPI.delete(path, options) ⇒ Promise.<*>

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

ResponseHandler : function

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.

RequestOptions : Object

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.