Skip to main content

Creating API keys

To use Gunbot you need to create an API key at your exchange.

Through the API Gunbot can connect to the exchange and trade on your behalf. Gunbot uses the exchange assigned API key as license key to prevent fraud.

On most exchanges you can find the option to create API keys on their account or settings page.

This page shows the minimum required settings for often used exchanges to create a working API key.

Binance

Binance Futures

Bitfinex

Bitmex

Bittrex

CEX

Coinbase Pro

dYdX

Connecting Gunbot to dYdx is different than connecting to centralized exchanges.

By connecting your MetaMask wallet, API credentials are automatically generated and stored in your browser. You will need to use a MetaMask wallet that is not tied to a hardware wallet. This is because the private key of the wallet is needed for signing messages, and the private key of a hardware wallet does not leave the device by design.

In order to ensure the security of your credentials, Gunbot stores them using encryption in the config file. Once you have finished configuring Gunbot, be sure to delete the plain text credentials that you collected during the setup process.

Step 1: connect wallet

Go to https://trade.dydx.exchange/. Select 'Connect wallet' to start connecting a wallet.

Step 2: choose MetaMask

Select 'MetaMask' to proceed.

Step 3: choose connect

Select 'Connect' to proceed.

Step 3: enter MetaMask password

Enter your password to login to MetaMask.

Step 4: select remember me and give permissions

Select the 'Remember me' option before clicking 'Send requests'. This is important.

MetaMask will now show various prompts to allow the connection with dYdX. After you have successfully connected, log out and then log back in with the same MetaMask wallet address. If the wallet remembers the account, you can proceed. If not, repeat the process and make sure the wallet remembers the account.

Step 5: export private key

To be able to force closing positions and withdrawing from the exchange, it is needed to regularly sign messages on L2 with your current position information. To do this, Gunbot needs to use the wallet private key.

If you do not want to use this functionality - which defies the benefits of being able to close positions and force withdrawing funds - then enter 0 as value for private key instead.

The first credential to save is the wallet private key. To do this, open MetaMask and follow the following three steps:

Select the three dots icon.

Go to 'Account details'.

Select 'Export private key'. Save the key.

Step 6: open local storage manager

To get the rest of the needed credentials, open the browser developer tools while you are on the logged in page of the dYdX.

Depending on the browser, developer tools can usually be opened with the keyboard shortcut F12, or alternatively Ctrl-Shift-i.

Now locate the local storage. In Google Chrome that is in 'Application' > 'Local Storage'. In Firefox it's 'Storage' > 'Local Storage'.

Step 7: Stark private key

Save the value for 'privateKey' (selected in screenshot) in 'STARK_KEY_PAIRS', to use as 'Stark private key'.

Step 8: Wallet address

Save the value for 'walletAddress' (selected in screenshot) in 'STARK_KEY_PAIRS', to use as 'Wallet address'.

Step 9: API key

Save the value for 'key' (selected in screenshot) in 'API_KEY_PAIRS', to use as 'API key'.

Step 10: API secret

Save the value for 'secret' (selected in screenshot) in 'API_KEY_PAIRS', to use as 'API secret'.

Step 11: Passphrase

Save the value for 'passphrase' (selected in screenshot) in 'API_KEY_PAIRS', to use as 'Passphrase'.

Huobi

Kraken

Kucoin

Poloniex