ExamplesEvents
Get loitering events with a custom polygon and duration filter (POST)
Example POST request for loitering events inside a custom GeoJSON polygon, filtered by event duration.
Query parameters
| Parameter | Value | Description |
|---|---|---|
offset | 0 | Pagination offset |
limit | 1 | Max number of events returned |
Request body
| Field | Value | Description |
|---|---|---|
datasets | ["public-global-loitering-events:latest"] | Loitering events dataset |
startDate | 2017-01-01 | Start of the date range |
endDate | 2017-01-31 | End of the date range |
vessels | ["82be6f228-8ce4-26d1-bf81-3b7979d0c72f"] | Vessel id to filter events for |
flags | ["KOR"] | Filter by vessel flag |
duration | 60 | Minimum event duration in minutes |
geometry | custom Polygon | Custom region to filter events in |
Request
# Make sure to replace [TOKEN] with your API Access Token.
curl --location --request POST 'https://gateway.api.globalfishingwatch.org/v3/events?offset=0&limit=1' \
--header 'Authorization: Bearer [TOKEN]' \
--header 'Content-Type: application/json' \
--data-raw '{
"datasets": [ "public-global-loitering-events:latest"],
"startDate": "2017-01-01",
"endDate": "2017-01-31",
"vessels": ["82be6f228-8ce4-26d1-bf81-3b7979d0c72f"],
"flags": ["KOR"],
"duration": 60,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
43.835981972515576,
-6.785011952437713
],
[
43.83602857589722,
-6.785011952437713
],
[
43.83602857589722,
-6.784984652340707
],
[
43.835981972515576,
-6.784984652340707
],
[
43.835981972515576,
-6.785011952437713
]
]
]
}
}'
result = await gfw_client.events.get_all_events(
datasets=["public-global-loitering-events:latest"],
start_date="2017-01-01",
end_date="2017-01-31",
vessels=["82be6f228-8ce4-26d1-bf81-3b7979d0c72f"],
flags=["KOR"],
duration=60,
geometry={
"type": "Polygon",
"coordinates": [
[
[43.835981972515576, -6.785011952437713],
[43.83602857589722, -6.785011952437713],
[43.83602857589722, -6.784984652340707],
[43.835981972515576, -6.784984652340707],
[43.835981972515576, -6.785011952437713],
]
],
},
)// Make sure to replace [TOKEN] with your API Access Token.
const res = await fetch('https://gateway.api.globalfishingwatch.org/v3/events?offset=0&limit=1', {
method: 'POST',
headers: {
Authorization: 'Bearer [TOKEN]',
'Content-Type': 'application/json',
},
body: JSON.stringify({
datasets: ['public-global-loitering-events:latest'],
startDate: '2017-01-01',
endDate: '2017-01-31',
vessels: ['82be6f228-8ce4-26d1-bf81-3b7979d0c72f'],
flags: ['KOR'],
duration: 60,
geometry: {
type: 'Polygon',
coordinates: [
[
[43.835981972515576, -6.785011952437713],
[43.83602857589722, -6.785011952437713],
[43.83602857589722, -6.784984652340707],
[43.835981972515576, -6.784984652340707],
[43.835981972515576, -6.785011952437713],
],
],
},
}),
})
const data = await res.json()Response
{
"metadata": {
"datasets": ["public-global-loitering-events-carriers:v20201001"],
"vessels": ["82be6f228-8ce4-26d1-bf81-3b7979d0c72f"],
"dateRange": {
"from": "2017-01-01",
"to": "2017-01-31"
},
"encounterTypes": [],
"flags": ["KOR"],
"geometry": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[43.835981972515576, -6.785011952437713],
[43.83602857589722, -6.785011952437713],
[43.83602857589722, -6.784984652340707],
[43.835981972515576, -6.784984652340707],
[43.835981972515576, -6.785011952437713]
]
]
}
}
]
}
},
"limit": 1,
"offset": 0,
"nextOffset": null,
"total": 0,
"entries": []
}Get encounter events with a custom polygon and duration filter (POST)
Example POST request for encounter events inside a custom GeoJSON polygon, filtered by event duration.
Get port visit events with a custom polygon and duration filter (POST)
Example POST request for port visit events inside a custom GeoJSON polygon, filtered by event duration.