cURL
curl --request GET \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId} \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"id": "8173b9a7-ee61-413e-b9e3-7c04b2a067c5",
"customerId": "1b0ada1e-fa1b-4cfe-a553-01b340c5650e",
"status": "Active",
"fixedSide": "toCurrencyAmount",
"transactionId": "4d78ac65-2c3f-47e2-8bf3-3f76124e9d27",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"externalCustomerId": "630231b3ae0d7e9e5097ad35",
"fromCurrency": "MXN",
"toCurrency": "USD",
"settlementType": "full",
"initialCollateralAmount": 1608.09,
"quote": 20.6165,
"externalMarkupPct": 1,
"issuedAt": "2023-01-18",
"acceptedAtTs": 1659625088,
"fromCurrencyAmount": 32161.8,
"toCurrencyAmount": 1560,
"endAt": "2023-02-23",
"settlementAt": "2023-02-23",
"updatedAt": "2023-02-23",
"cancelledAt": "2023-02-23",
"initialCollateralReceivedAt": "2023-01-20",
"fundsReceivedAt": "2023-02-23",
"completedAt": "2023-02-23",
"completedAtTs": 1659625090,
"overdueAt": "2023-02-23",
"adjustedMtmChangePct": 1.25,
"adjustedMtmChangeTs": 1674057600,
"contractType": "flexible",
"originalFromCurrencyAmount": 30924.75,
"originalToCurrencyAmount": 1500,
"originalQuote": 20.6165,
"originalEndAt": "2023-02-23",
"collateralAmount": 408.09,
"totalNumberOfDrawdowns": 3
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}Hedges
Get Hedge
Retrieves detailed information for a specific hedge.
GET
/
customers
/
{customerId}
/
hedges
/
{hedgeId}
cURL
curl --request GET \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId} \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"id": "8173b9a7-ee61-413e-b9e3-7c04b2a067c5",
"customerId": "1b0ada1e-fa1b-4cfe-a553-01b340c5650e",
"status": "Active",
"fixedSide": "toCurrencyAmount",
"transactionId": "4d78ac65-2c3f-47e2-8bf3-3f76124e9d27",
"externalTransactionId": "780231b3ae0d7e9e5097nd89",
"externalCustomerId": "630231b3ae0d7e9e5097ad35",
"fromCurrency": "MXN",
"toCurrency": "USD",
"settlementType": "full",
"initialCollateralAmount": 1608.09,
"quote": 20.6165,
"externalMarkupPct": 1,
"issuedAt": "2023-01-18",
"acceptedAtTs": 1659625088,
"fromCurrencyAmount": 32161.8,
"toCurrencyAmount": 1560,
"endAt": "2023-02-23",
"settlementAt": "2023-02-23",
"updatedAt": "2023-02-23",
"cancelledAt": "2023-02-23",
"initialCollateralReceivedAt": "2023-01-20",
"fundsReceivedAt": "2023-02-23",
"completedAt": "2023-02-23",
"completedAtTs": 1659625090,
"overdueAt": "2023-02-23",
"adjustedMtmChangePct": 1.25,
"adjustedMtmChangeTs": 1674057600,
"contractType": "flexible",
"originalFromCurrencyAmount": 30924.75,
"originalToCurrencyAmount": 1500,
"originalQuote": 20.6165,
"originalEndAt": "2023-02-23",
"collateralAmount": 408.09,
"totalNumberOfDrawdowns": 3
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}Authorizations
Basic authentication using the partner API keys from https://console.grainfinance.co/keys
Path Parameters
Response
Hedge Found
- Option 1
- Option 2
Hedge objects represent transactions which are currently hedged.
Indicates which currency amount was fixed (specified) when creating the hedge.
When fixedSide is toCurrencyAmount, the toCurrencyAmount was specified and fromCurrencyAmount was calculated.
When fixedSide is fromCurrencyAmount, the fromCurrencyAmount was specified and toCurrencyAmount was calculated.
Available options:
toCurrencyAmount, fromCurrencyAmount Example:
"toCurrencyAmount"