# OpenAPI

## 1 Apply app\_key

Open the website <https://zksync.satori.finance/tradeApi> and connect your wallet,

Click the button "Create API" and input your data, you can read the doc detail.

<figure><img src="https://1159713765-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmWCeXnpYTefL1vFaVdo%2Fuploads%2FmnxtaN8SXRA9WgqOtVMm%2Fcreate_2.png?alt=media&#x26;token=5ae2ae62-a365-49ca-a8e9-2ce61acbc1cb" alt=""><figcaption></figcaption></figure>

Get your API Key.&#x20;

<figure><img src="https://1159713765-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmWCeXnpYTefL1vFaVdo%2Fuploads%2FKncLZpcKXB8iKVGk954H%2Fcreate_3.png?alt=media&#x26;token=724a0153-3ee6-4887-9783-b35e13c6f08f" alt=""><figcaption></figcaption></figure>

```
Note: the API Key need auth pass before it works. This may take some days.
```

## 2 Install the SDK

```
SDK path: https://github.com/satoridao/satori_openapi_sdk
```

Init the sdk config with your API key and your api address private key.

```
# config.ini
[keys]
base_url= https://openapi.satori.finance
ws_url= wss://openapi.satori.finance/api/market/ws
api_key= ${your api key}
api_secret= ${your api address private key}
```

## 3 Deposit USD into Satori

<figure><img src="https://1159713765-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLmWCeXnpYTefL1vFaVdo%2Fuploads%2FZrjoipUq6TgM2Iyp2pYF%2Fdeposite.png?alt=media&#x26;token=1e993b68-4899-4984-85d0-0b9cbf20af4c" alt=""><figcaption></figcaption></figure>

```
Note: The same address at different chain have different account in satori. Please choose the same chain with your api key you applyed.
```

After depositing, you can check your available balance from the web front or through the sdk.

example code:&#x20;

```
import json
​
from satori.client import Client
from examples.utils.prepare_env import get_env
​
if __name__ == '__main__':
    config = get_env()
    print(config)
    cs = Client(api_key=config["api_key"], api_secret=config["api_secret"], api_sign_type=config["api_sign_type"], base_url=config["base_url"])
    time = cs.time()["data"]
    print(json.dumps(cs.balance("USD", time), ensure_ascii=False))
```

## 4 Open orders

> Open orders

```
#!/usr/bin/env python
import json
​
from satori.client import Client,Order
from examples.utils.prepare_env import get_env
​
if __name__ == '__main__':
    config = get_env()
    cs = Client(api_key=config["api_key"], api_secret=config["api_secret"], api_sign_type=config["api_sign_type"], base_url=config["base_url"])
    time = cs.time()["data"]
    order1 = Order(str(time), True, False, 1, 1, "ETH-USD", 3, "0.02", "2000")
    print(json.dumps(cs.create_order(order1,str(time)), ensure_ascii=False))
```

> Cancel orders

```
#!/usr/bin/env python
import json
​
from satori.client import Client
from examples.utils.prepare_env import get_env
​
if __name__ == '__main__':
    config = get_env()
    cs = Client(api_key=config["api_key"], api_secret=config["api_secret"], api_sign_type=config["api_sign_type"], base_url=config["base_url"])
    time = cs.time()["data"]
    # print(cs.order_list("ETH-USD",time))
    print(json.dumps(cs.cancel_order(entrustId=178790278,timestamp=str(time)), ensure_ascii=False))
```

<br>
