Skip to main content

Samples

The JavaScript and Python tabs assume you already have an access token (accessToken in JavaScript, access_token in Python) from the Authentication guide.

All Spot Prices​

Fetches all available spot prices for all ports and fuel grades:

query allSpotPrices {
latestSpotPrices {
port {
id
name
countryName
}
fuelGrade {
id
description
}
latestPrices {
publishedDate
price
}
}
}

Filter By Fuel Grade​

Use fuel grade IDs such as mgo or vlsfo (see Fuel Grades for the full list; biofuel returns all three biofuel blends).

query allSpotPricesByFuelGrade {
latestSpotPrices(input: { fuelGradeIds: ["mgo", "vlsfo"] }) {
port {
id
name
countryName
}
fuelGrade {
id
description
}
latestPrices {
publishedDate
price
}
}
}

Filter By Port​

query allSpotPricesByPort {
latestSpotPrices(input: { portIds: ["sgsin", "nlrtm", "aefjr"] }) {
port {
id
name
countryName
}
fuelGrade {
id
description
}
latestPrices {
publishedDate
price
}
}
}

Filter By Fuel Grade And Port​

query spotPricesByFuelGradeAndPort {
latestSpotPrices(
input: {
fuelGradeIds: ["mgo", "vlsfo"]
portIds: ["sgsin", "nlrtm", "aefjr"]
}
) {
port {
id
name
countryName
}
fuelGrade {
id
description
}
latestPrices {
publishedDate
price
}
}
}

Additional Fields​

A few extra fields are worth knowing about - add any of these to the queries above.

Port location and time zone details, on any port selection:

port {
id
name
coordinates {
latitude
longitude
}
timeZone {
name
offset
}
}

Confidence band, the 68% confidence interval around the price (only populated for ports and fuel grades where one is calculated, null otherwise):

latestPrices {
publishedDate
price
band68Lower
band68Upper
}

Listing Ports​

Use the ports query to list ports, with pagination:

query ports {
ports(first: 10) {
totalCount
pageInfo {
startCursor
hasPreviousPage
hasNextPage
endCursor
}
edges {
cursor
node {
id
name
country
timeZone {
name
offset
}
}
}
}
}

To retrieve the next page when hasNextPage is true, pass the previous page's endCursor in the after parameter. Without a search, cursors are port IDs, so you can also start after a known port as below. With filter.search, results are sorted by how closely they match and the cursors are positions ("1", "2", ...), so always use endCursor from the previous page:

query ports {
ports(first: 10, after: "grpir") {
totalCount
pageInfo {
startCursor
hasPreviousPage
hasNextPage
endCursor
}
edges {
cursor
node {
id
name
country
timeZone {
name
offset
}
}
}
}
}