Spot Price Example
To fetch the spot price for MGO (Marine Gas Oil) at the Singapore port (port ID: "sgsin"), you can use the following query. The JavaScript and Python tabs assume you already have an access token (accessToken in JavaScript, access_token in Python) from the Authentication guide.
- GraphQL
- JavaScript
- Python
query spotPrice {
latestSpotPrices(input: { portIds: ["sgsin"], fuelGradeIds: ["mgo"] }) {
port {
id
name
}
fuelGrade {
id
description
}
latestPrices {
publishedDate
price
band68Lower
band68Upper
}
}
}
const response = await fetch("https://api.tideform.io/graphql", {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `query spotPrice {
latestSpotPrices(input: { portIds: ["sgsin"], fuelGradeIds: ["mgo"] }) {
port { id name }
fuelGrade { id description }
latestPrices { publishedDate price band68Lower band68Upper }
}
}`,
}),
});
const { data } = await response.json();
import requests
response = requests.post(
"https://api.tideform.io/graphql",
json={
"query": """
query spotPrice {
latestSpotPrices(input: { portIds: ["sgsin"], fuelGradeIds: ["mgo"] }) {
port { id name }
fuelGrade { id description }
latestPrices { publishedDate price band68Lower band68Upper }
}
}
"""
},
headers={"Authorization": f"Bearer {access_token}"},
)
data = response.json()["data"]
This query fetches the latest MGO spot price for Singapore, including the published date, and returns the confidence band (band68Lower / band68Upper) around the price when one is available - otherwise these fields are null.