ExamplesEvents
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.
Query parameters
| Parameter | Value | Description |
|---|---|---|
offset | 0 | Pagination offset |
limit | 1 | Max number of events returned |
Request body
| Field | Value | Description |
|---|---|---|
datasets | ["public-global-encounters-events:latest"] | Encounter events dataset |
startDate | 2017-01-01 | Start of the date range |
endDate | 2017-01-31 | End of the date range |
vessels | ["55d38c0ee-e0d7-cb32-ac9c-8b3680d213b3"] | Vessel id to filter events for |
flags | ["TWN"] | 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-encounters-events:latest"],
"startDate": "2017-01-01",
"endDate": "2017-01-31",
"vessels": ["55d38c0ee-e0d7-cb32-ac9c-8b3680d213b3"],
"flags": ["TWN"],
"duration": 60,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-130.9735107421875,
-17.691128657307427
],
[
-130.4901123046875,
-17.691128657307427
],
[
-130.4901123046875,
-17.209017141391765
],
[
-130.9735107421875,
-17.209017141391765
],
[
-130.9735107421875,
-17.691128657307427
]
]
]
}
}'result = await gfw_client.events.get_all_events(
datasets=["public-global-encounters-events:latest"],
start_date="2017-01-01",
end_date="2017-01-31",
vessels=["55d38c0ee-e0d7-cb32-ac9c-8b3680d213b3"],
flags=["TWN"],
duration=60,
geometry={
"type": "Polygon",
"coordinates": [
[
[-130.9735107421875, -17.691128657307427],
[-130.4901123046875, -17.691128657307427],
[-130.4901123046875, -17.209017141391765],
[-130.9735107421875, -17.209017141391765],
[-130.9735107421875, -17.691128657307427],
]
],
},
)// 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-encounters-events:latest'],
startDate: '2017-01-01',
endDate: '2017-01-31',
vessels: ['55d38c0ee-e0d7-cb32-ac9c-8b3680d213b3'],
flags: ['TWN'],
duration: 60,
geometry: {
type: 'Polygon',
coordinates: [
[
[-130.9735107421875, -17.691128657307427],
[-130.4901123046875, -17.691128657307427],
[-130.4901123046875, -17.209017141391765],
[-130.9735107421875, -17.209017141391765],
[-130.9735107421875, -17.691128657307427],
],
],
},
}),
})
const data = await res.json()Response
{
"metadata": {
"datasets": ["public-global-encounters-events:v3.0"],
"vessels": ["55d38c0ee-e0d7-cb32-ac9c-8b3680d213b3"],
"dateRange": {
"from": "2017-01-01",
"to": "2017-01-31"
},
"encounterTypes": [
"FISHING-FISHING",
"FISHING-CARRIER",
"FISHING-SUPPORT",
"CARRIER-FISHING",
"SUPPORT-FISHING"
],
"flags": ["TWN"],
"geometry": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-130.9735107421875, -17.691128657307427],
[-130.4901123046875, -17.691128657307427],
[-130.4901123046875, -17.209017141391765],
[-130.9735107421875, -17.209017141391765],
[-130.9735107421875, -17.691128657307427]
]
]
}
}
]
}
},
"limit": 1,
"offset": 0,
"nextOffset": 1,
"total": 1,
"entries": [
{
"start": "2017-01-01T00:50:00.000Z",
"end": "2017-01-01T04:30:00.000Z",
"id": "05e5fcf80f3542a33154214f0a586f19.2",
"type": "encounter",
"position": {
"lat": -17.4783,
"lon": -130.7285
},
"regions": {
"mpa": [],
"eez": [],
"rfmo": ["WCPFC", "ACAP", "IWC", "IATTC", "SPRFMO"],
"fao": ["77"],
"majorFao": ["77"],
"eez12Nm": [],
"highSeas": ["63203"],
"mpaNoTakePartial": [],
"mpaNoTake": []
},
"boundingBox": [-130.7285232872, -17.4782849293, -130.7285232872, -17.4782849293],
"distances": {
"startDistanceFromShoreKm": 602,
"endDistanceFromShoreKm": 602,
"startDistanceFromPortKm": 760.023188,
"endDistanceFromPortKm": 760.023188
},
"vessel": {
"id": "55d38c0ee-e0d7-cb32-ac9c-8b3680d213b3",
"name": "JINHSIANGFA",
"ssvid": "416077500"
},
"encounter": {
"vessel": {
"id": "46ae0e5f9-9304-7ac9-dc78-462d84320bf5",
"flag": "TWN",
"name": "SHUNTIANFA168",
"type": "carrier",
"ssvid": "416602000"
},
"medianDistanceKilometers": 0.016,
"medianSpeedKnots": 1.067,
"type": "fishing-carrier",
"potentialRisk": false
}
}
]
}