POST
https://api.cryptohopper.com/v1/hopper/{id}/short/close
Closes the given short positions by placing buy orders at the current ask, or at market.
OAuth scope:
read manage trade About scopes
position_ids are short position IDs; market_order 1 places market orders. Shorts that already have an open order, or for which the quote currency balance is too low, are not closed. When only some shorts could be closed, the call still succeeds with a message saying so. Not available for exchange arbitrage, market maker, copy, grid and AI bots.
Example request
curl -X POST "https://api.cryptohopper.com/v1/hopper/HOPPER_ID/short/close" \
-H "access-token: YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"position_ids":[223344,223345],"market_order":0}'
const response = await fetch('https://api.cryptohopper.com/v1/hopper/HOPPER_ID/short/close', {
method: 'POST',
headers: {
"access-token": "YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"position_ids": [
223344,
223345
],
"market_order": 0
})
});
const data = await response.json();
import requests
response = requests.post(
"https://api.cryptohopper.com/v1/hopper/HOPPER_ID/short/close",
headers={
"access-token": "YOUR_ACCESS_TOKEN"
},
json={
"position_ids": [
223344,
223345
],
"market_order": 0
},
)
data = response.json()
$ch = curl_init('https://api.cryptohopper.com/v1/hopper/HOPPER_ID/short/close');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'access-token: YOUR_ACCESS_TOKEN',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'position_ids' => [
223344,
223345,
],
'market_order' => 0,
]),
]);
$data = json_decode(curl_exec($ch), true);
Parameters
Headers
| Name | Type | Required | Description |
|---|---|---|---|
access-token |
string | Required | The OAuth access token of the user. |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string | Required | Hopper ID. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
position_ids | array of integer | Required |
Response
{
"data": "Buy orders (2) have been placed for the selected short position(s)."
}