Buying and selling with a hopper

 

Perform a simple buy and a sell order on the exchange with your hopper by calling the order API endpoint.

To make API requests you will need to create an app and have an access token. If you haven't created an access token yet, please follow the tutorial Get an access token with Oauth2 first.

Placing a buy order

With the API you can place simple or more advanced buy orders with your hopper. In this example we will just focus on a simple buy order. A simple buy command to the API will just need a coin/currency, because most of the other neccessary details are already configured in the hopper itself, for example: the amount to buy. A buy order can be placed by making a POST call to the /hopper/{id}/order endpoint, where {id} is the id of your hopper.

API endpoint:

https://api.cryptohopper.com/v1/hopper/{id}/order

JSON POST example:

{
  "order_type": "buy",
  "coin": "The crypto currency to buy.",
  "amount": 0,
  "price": 0
}

The JSON values amount and price are optional, only order_type and coin are required. If you have a hopper with USD as base currency and you want to place a simple buy order for BTC, you would just need to POST the following JSON to the API.

{
  "order_type": "buy",
  "coin": "BTC"
}

When successfull you will receive a 200 status response with the message that your buy order will be placed at the exchange. Now check your hopper and see if the buy order did come through.

Placing a sell order

You can also place sell order, but because Cryptohopper works with positions, positions of the given coin/currency will be sold. For example: if you would send a command to sell BTC, all your BTC positions will be sold (if not on hold etc).

API endpoint:

https://api.cryptohopper.com/v1/hopper/{id}/order

JSON POST example:

{
  "order_type": "sell",
  "coin": "The crypto currency to sell."
}

The same API endpoint is used, but in this case we set order_type to sell. If you have a hopper with USD as base currency and you want to sell all BTC positions, you would just need to POST the following JSON to the API.

{
  "order_type": "sell",
  "coin": "BTC"
}

When successfull you will receive a 200 status response with the message that your sell order(s) will be placed at the exchange. Now check your hopper and see if your positions are sold.

Hopefully you managed to place buy and sell orders with the API after completing this tutorial. If you need more info about the order endpoint or want to place more advanced orders, please view the API reference for more info.