# Maker APIs

## Download OpenAPI specification:

{% file src="<https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2FY9SU3V3nZ2WcXikzAiK8%2FLimitOrderAPIs.yaml?alt=media&token=9c98177e-eb91-463d-9c21-148a9333d9a7>" %}

## Maker APIs

<details>

<summary>API statuses and support</summary>

KyberSwap APIs uses the following statuses to minimize version miscommunications and ensure an uninterrupted service for the end user:

* `Latest`: API is functional and supported. This is the recommended version for all integrators (new and existing).
* `Legacy`: API remains functional with support for bugs only. No new feature updates.
* `Deprecated`: API is no longer functional and is not supported.

For all developers, it is highly recommended that you refer to the API with the `Latest` tag to ensure access to the latest features as well as improved service quality and efficiency. APIs which are planned to be sunset will be tagged `Legacy` during the transition period and thereafter moved to `Deprecated`.

The KyberSwap Docs will continue to maintain information regarding `Legacy` and `Deprecated` APIs.

</details>

### `Latest`

#### Create Order(s)

{% hint style="success" %}
**Developer Guide**

Please refer to [**Create Limit Order** ](https://docs.kyberswap.com/kyberswap-solutions/limit-order/developer-guides/create-limit-order)for the relevant sequence diagram as well as a TypeScript example.
{% endhint %}

## Get Unsigned Create Order Message

> Get EIP712 create order message to be signed. The response of this API will need to be signed with \[Sign Typed Data v4]\(<https://docs.metamask.io/guide/signing-data.html#sign-typed-data-v4>) before submitting create order request to KyberSwap via \`/write/api/v1/orders\`.

```json
{"openapi":"3.0.3","info":{"title":"KyberSwap Limit Order APIs","version":"1.2.0"},"servers":[{"url":"https://limit-order.kyberswap.com"}],"paths":{"/write/api/v1/orders/sign-message":{"post":{"summary":"Get Unsigned Create Order Message","tags":["Maker"],"operationId":"post-write-api-v1-orders-sign-message","description":"Get EIP712 create order message to be signed. The response of this API will need to be signed with [Sign Typed Data v4](https://docs.metamask.io/guide/signing-data.html#sign-typed-data-v4) before submitting create order request to KyberSwap via `/write/api/v1/orders`.","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["chainId","makerAsset","takerAsset","maker","makingAmount","takingAmount","expiredAt"],"properties":{"chainId":{"type":"string","description":"The chainId on which the order is being created. Only supports EVM chains."},"makerAsset":{"type":"string","description":"The token address of the asset which the Maker is selling."},"takerAsset":{"type":"string","description":"The token address of the asset which the Maker expects in return."},"maker":{"type":"string","description":"The address of the Maker."},"receiver":{"type":"string","description":"Defines who will receive the takerAsset when the order is filled.\nDefault: `maker`."},"allowedSenders":{"type":"array","maxItems":1,"description":"Defines the addresses who are allowed to fill the order.","items":{"type":"string"}},"makingAmount":{"type":"string","description":"The amount of `makerAsset` in wei. String representation of uint256 value."},"takingAmount":{"type":"string","description":"The amount of `takerAsset` in wei. String representation of uint256 value."},"expiredAt":{"type":"integer","description":"The unix timestamp upon which the order will automatically lapse (i.e. expire)."}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","required":["code","message","data"],"properties":{"code":{"type":"integer","description":"The response code."},"message":{"type":"string","description":"Server response message."},"data":{"type":"object","required":["types","domain","primaryType","message"],"properties":{"types":{"type":"object","required":["EIP712Domain","Order"],"properties":{"EIP712Domain":{"type":"array","items":{"$ref":"#/components/schemas/OrderSignMessageDefinition"}},"Order":{"type":"array","items":{"$ref":"#/components/schemas/OrderSignMessageDefinition"}}}},"domain":{"type":"object","required":["name","version","chainId","verifyingContract"],"properties":{"name":{"type":"string","description":"The user readable name of signing domain, i.e. the name of the DApp or the protocol."},"version":{"type":"string","description":"The current major version of the signing domain. Signatures from different versions are not compatible."},"chainId":{"type":"string","description":"The EIP-155 chain id. The user-agent should refuse signing if it does not match the currently active chain."},"verifyingContract":{"type":"string","description":"the address of the contract that will verify the signature. The user-agent may do contract specific phishing prevention."}}},"primaryType":{"type":"string","description":"The top-level type of the object in the EIP712 message but does not have to correspond to any of the types in the message."},"message":{"type":"object","required":["salt","makerAsset","takerAsset","maker","receiver","allowedSender","makingAmount","takingAmount","feeConfig","makerAssetData","takerAssetData","getMakerAmount","getTakerAmount","predicate","interaction"],"properties":{"salt":{"type":"string","description":"The randomized data fed as an additional input to the hashing function."},"makerAsset":{"type":"string","description":"The token address of the asset which the Maker is selling."},"takerAsset":{"type":"string","description":"The token address of the asset which the Maker expects in return."},"maker":{"type":"string","description":"The address of the Maker."},"receiver":{"type":"string","description":"The receiver of the takerAsset when order is filled."},"allowedSender":{"type":"string","description":"Defines the addresses who are allowed to fill the order. Deafults to `0x000...` if none specified."},"makingAmount":{"type":"string","description":"The amount of `makerAsset` in wei."},"takingAmount":{"type":"string","description":"The amount of `takerAsset` in wei."},"feeConfig":{"type":"string","description":"The hashstring representing the fee configuration for the order."},"takerTokenFeeAmount":{"type":"string","description":"The amount of token taken from the Taker as the limit order fee."},"makerAssetData":{"type":"string","description":"ABIv2 encoded data that can be decoded by a specified proxy contract when transferring makerAsset."},"takerAssetData":{"type":"string","description":"ABIv2 encoded data that can be decoded by a specified proxy contract when transferring takerAsset."},"getMakerAmount":{"type":"string","description":"The hexstring representing the `makerAsset` amount."},"getTakerAmount":{"type":"string","description":"The hexstring representing the `takerAsset` amount."},"predicate":{"type":"string","description":"Call data that indicates the validity of the orders logic."},"permit":{"type":"string","description":"Included data if token is able to leverage Permit function (EIP2612) for gasless approvals."},"interaction":{"type":"string","description":"Call data that is sent to an intermediate contract when the order is filled."}}}}}}}}}},"400":{"description":"Bad Request\n- Missing required fields\n- chainId is not supported\n- makerAsset, takerAsset, maker, receiver, allowedSenders are not ETH address\n- makerAsset or takerAsset are native tokens\n- makingAmount, takingAmount are less than or equal to 0\n- makingAmount, takingAmount are not uint128\n- expiredAt is in the past","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"OrderSignMessageDefinition":{"title":"OrderSignMessageDefinition","type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"}},"required":["name","type"]},"ErrorResponse":{"title":"ErrorResponse","type":"object","properties":{"code":{"type":"integer","description":"Error code"},"message":{"type":"string","description":"Error message"},"errorEntities":{"type":"array","items":{"type":"string"}}},"required":["code","message","errorEntities"]}}}}
```

## Create New Order

> API for Makers to create new orders by sending in order params which includes the signed EIP712 message returned in \`/write/api/v1/orders/sign-message\`.

```json
{"openapi":"3.0.3","info":{"title":"KyberSwap Limit Order APIs","version":"1.2.0"},"servers":[{"url":"https://limit-order.kyberswap.com"}],"paths":{"/write/api/v1/orders":{"post":{"summary":"Create New Order","tags":["Maker"],"operationId":"post-write-api-v1-orders","description":"API for Makers to create new orders by sending in order params which includes the signed EIP712 message returned in `/write/api/v1/orders/sign-message`.","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["chainId","makerAsset","takerAsset","maker","makingAmount","takingAmount","expiredAt","salt","signature"],"properties":{"chainId":{"type":"string","description":"The chainId on which the order is being created. Only supports EVM chains."},"makerAsset":{"type":"string","description":"The token address of the asset which the Maker is selling."},"takerAsset":{"type":"string","description":"The token address of the asset which the Maker expects in return."},"maker":{"type":"string","description":"The address of the Maker."},"receiver":{"type":"string","description":"Defines who will receive the takerAsset when the order is filled.\nDefault: `maker`."},"allowedSenders":{"type":"array","description":"Defines the addresses who are allowed to fill the order.","items":{"type":"string"}},"makingAmount":{"type":"string","description":"The amount of `makerAsset` in wei. String representation of uint256 value."},"takingAmount":{"type":"string","description":"The amount of `takerAsset` in wei. String representation of uint256 value."},"expiredAt":{"type":"integer","description":"The unix timestamp upon which the order will automatically lapse (i.e. expire)."},"salt":{"type":"string","description":"The randomized data fed as an additional input to the hashing function. Returned in `/write/api/v1/orders/sign-message`."},"signature":{"type":"string","description":"The signed(signDataTyped) EIP712 creation order returned in `/write/api/v1/orders/sign-message`."}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","required":["code","message","data"],"properties":{"code":{"type":"integer","description":"The response code."},"message":{"type":"string","description":"Server response message."},"data":{"type":"object","required":["id"],"properties":{"id":{"type":"integer","description":"ID of the successfully created order."}}}}}}}},"400":{"description":"Bad Request\n- Missing required fields\n- chainId is not supported\n- makerAsset, takerAsset, maker, receiver, allowedSenders are not ETH address\n- makerAsset, takerAsset are native token\n- makingAmount, takingAmount are less than or equal 0\n- makingAmount, takingAmount, salt are not uint256\n- makerAsset is equal to takerAsset\n- expiredAt is in the past\n- signature is incorrect\n- maker's balance is not enough\n- maker's allowance amount is not enough","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"ErrorResponse":{"title":"ErrorResponse","type":"object","properties":{"code":{"type":"integer","description":"Error code"},"message":{"type":"string","description":"Error message"},"errorEntities":{"type":"array","items":{"type":"string"}}},"required":["code","message","errorEntities"]}}}}
```

#### Query Maker Order(s)

{% openapi src="<https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-6a2a24b154519be1b7bf257b5407139817242cb5%2FLimitOrderAPIs_v1.2.1.yaml?alt=media>" path="/read-ks/api/v1/orders" method="get" %}
[LimitOrderAPIs\_v1.2.1.yaml](https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-6a2a24b154519be1b7bf257b5407139817242cb5%2FLimitOrderAPIs_v1.2.1.yaml?alt=media)
{% endopenapi %}

{% openapi src="<https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media>" path="/read-ks/api/v1/orders/active-making-amount" method="get" %}
[LimitOrderAPIs\_v1.2.yaml](https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media)
{% endopenapi %}

#### Gasless Cancel Order(s)

{% hint style="success" %}
**Developer Guide**

Please refer to [**Gasless Cancel**](https://docs.kyberswap.com/kyberswap-solutions/limit-order/developer-guides/gasless-cancel) for the relevant sequence diagram as well as a TypeScript example.
{% endhint %}

{% openapi src="<https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media>" path="/write/api/v1/orders/cancel-sign" method="post" %}
[LimitOrderAPIs\_v1.2.yaml](https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media)
{% endopenapi %}

{% openapi src="<https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media>" path="/write/api/v1/orders/cancel" method="post" %}
[LimitOrderAPIs\_v1.2.yaml](https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media)
{% endopenapi %}

#### Hard Cancel Order(s)

{% hint style="success" %}
**Developer Guide**

Please refer to [**Hard Cancel**](https://docs.kyberswap.com/kyberswap-solutions/limit-order/developer-guides/hard-cancel) for the relevant sequence diagram as well as a TypeScript example.
{% endhint %}

{% openapi src="<https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media>" path="/read-ks/api/v1/encode/cancel-batch-orders" method="post" %}
[LimitOrderAPIs\_v1.2.yaml](https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media)
{% endopenapi %}

{% openapi src="<https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media>" path="/read-ks/api/v1/encode/increase-nonce" method="post" %}
[LimitOrderAPIs\_v1.2.yaml](https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2Fgit-blob-a32e6b65bc3446af17c10e91b1476d6f65d7cf0c%2FLimitOrderAPIs_v1.2.yaml?alt=media)
{% endopenapi %}
