Apply a geographical filter for AIS messages

Limit the AIS messages you receive if you're only interested in particular regions

Two Ways to Apply a Geographical Filter to the Messages API

If you're only interested in a particular region of the world and want to filter out everything else, we recommend using geographical filters. These filters are inclusive: any messages that fall on the border will be included.

Try it out within an API call

This can be done via the "position" API filter parameter. Here's an example: https://ais.spire.com/messages?fields=decoded&position={"type":"Polygon","coordinates":[[[135.25, -30], [135.25, 30.5], [170, 30.5], [170, -30], [135.25, -30]]]} . 

Note 1: Make sure the definition of the polygon follows the "right-hand rule", otherwise your query may not work properly. We recommend testing your coordinates at geojson.io or GeoJSONLint to ensure it's formatted properly.

Note 1: Make sure that the first point of the polygon is repeated as the last point of the polygon to close it. The example below uses a valid GeoJson polygon but does not repeat the first point to close the polygon.

https://api.sense.spire.com/vessels?limit=100&position={"type":"Polygon","coordinates":[[[121.6,35.4],[121.4,32.8],[123.7,31.9],[125.07,34.2],[124.4,36.8]]]}
Result
{ "status": 422, "title": "Invalid query parameter(s)", "description": "Invalid GeoJSON Polygon position coordinates" }
But this is the corrected polygon with first point repeated as the last point
{"type":"Polygon","coordinates":[[[121.6,35.4],[121.4,32.8],[123.7,31.9],[125.07,34.2],[121.6,35.4]]]}
And this API call using the corrected polygon will now return data
https://api.sense.spire.com/vessels?limit=100&position={"type":"Polygon","coordinates":[[[121.6,35.4],[121.4,32.8],[123.7,31.9],[125.07,34.2],[121.6,35.4]]]}

Make a request to the Spire Customer Experience team

If you are positively interested in a particular region of the earth, we're happy to place a geo-filter on your account. Once applied, the Messages API will only feed you AIS messages within the defined region.

Note: If you're using the TCP feed, the Customer Experience team will have to apply a geo-filter for you.