Example requests - AIS API
AIS Stream
When sending a request to one of the streaming endpoints, the request will not end. You continue to receive new data until you disconnect.
Stream all vessels
curl --location --request GET 'https://live.ais.barentswatch.no/v1/combined' \
--header 'Authorization: Bearer <access_token>'
Example json response
{"courseOverGround":356.7,"latitude":69.543985,"longitude":17.769428,"name":"BALDER","rateOfTurn":null,"shipType":33,"speedOverGround":0,"trueHeading":null,"mmsi":257011940,"msgtime":"2022-11-02T13:14:25+00:00"}
{"courseOverGround":26.2,"latitude":68.860338,"longitude":16.66904,"name":"SARPEN","rateOfTurn":0,"shipType":34,"speedOverGround":0.1,"trueHeading":314,"mmsi":257056810,"msgtime":"2022-11-02T13:14:27+00:00"}
{"courseOverGround":133,"latitude":62.549605,"longitude":6.272812,"name":"RAV","rateOfTurn":0,"shipType":30,"speedOverGround":0.1,"trueHeading":149,"mmsi":257064490,"msgtime":"2022-11-02T13:14:27+00:00"}
{"courseOverGround":314.5,"latitude":62.074748,"longitude":6.21475,"name":"ASPER VICTORIA","rateOfTurn":0,"shipType":70,"speedOverGround":0,"trueHeading":127,"mmsi":257390000,"msgtime":"2022-11-02T13:14:27+00:00"}
{"courseOverGround":104.7,"latitude":58.996095,"longitude":10.058283,"name":"RESCUE STORMBULL","rateOfTurn":127,"shipType":51,"speedOverGround":1.7,"trueHeading":115,"mmsi":258258500,"msgtime":"2022-11-02T13:14:27+00:00"}
{"courseOverGround":314.3,"latitude":62.679135,"longitude":7.483285,"name":"LOTE","rateOfTurn":0,"shipType":60,"speedOverGround":8.9,"trueHeading":317,"mmsi":259125000,"msgtime":"2022-11-02T13:14:27+00:00"}
{"courseOverGround":67.9,"latitude":69.996897,"longitude":20.394438,"name":"KVALUNGEN","rateOfTurn":0,"shipType":30,"speedOverGround":7.1,"trueHeading":72,"mmsi":257333420,"msgtime":"2022-11-02T13:14:27+00:00"}
Stream with GeoJson output
Get more properties, and select GeoJson output format:
curl --location --request GET 'https://live.ais.barentswatch.no/v1/combined?modelType=Full&modelFormat=Geojson' \
--header 'Authorization: Bearer <access_token>'
Example GeoJson response
{"type":"Feature","geometry":{"type":"Point","coordinates":[16.909168,68.4016]},"properties":{"mmsi":257047350,"name":"OTTAR","msgtime":"2022-11-02T13:18:26+00:00","speedOverGround":null,"courseOverGround":null,"navigationalStatus":0,"rateOfTurn":-88,"shipType":70,"trueHeading":6,"callSign":"LH4258","destination":"HEKKELSTRAND","eta":"04221400","imoNumber":null,"dimensionA":4,"dimensionB":10,"dimensionC":4,"dimensionD":4,"draught":null,"shipLength":14,"shipWidth":8,"positionFixingDeviceType":3,"reportClass":"A"}}
{"type":"Feature","geometry":{"type":"Point","coordinates":[9.588648,63.727733]},"properties":{"mmsi":257076860,"name":"ODD LUNDBERG","msgtime":"2022-11-02T13:18:26+00:00","speedOverGround":0,"courseOverGround":213.8,"navigationalStatus":0,"rateOfTurn":0,"shipType":30,"trueHeading":315,"callSign":"LFUO","destination":null,"eta":"00000000","imoNumber":9840051,"dimensionA":44,"dimensionB":25,"dimensionC":14,"dimensionD":1,"draught":80,"shipLength":69,"shipWidth":15,"positionFixingDeviceType":1,"reportClass":"A"}}
{"type":"Feature","geometry":{"type":"Point","coordinates":[10.074347,58.777558]},"properties":{"mmsi":258216000,"name":"EIGENES","msgtime":"2022-11-02T13:18:26+00:00","speedOverGround":0.8,"courseOverGround":322.1,"navigationalStatus":7,"rateOfTurn":-127,"shipType":30,"trueHeading":100,"callSign":"LANW","destination":"CH 16","eta":"00002460","imoNumber":7434652,"dimensionA":19,"dimensionB":7,"dimensionC":2,"dimensionD":5,"draught":57,"shipLength":26,"shipWidth":7,"positionFixingDeviceType":1,"reportClass":"A"}}
Get a filtered stream
curl --location --request POST 'https://live.ais.barentswatch.no/v1/combined?modelType=Full&modelFormat=Geojson' --header 'Authorization: Bearer <access_token>' --header 'Content-Type: application/json' --data-raw '{
"shipTypes": [30], "countryCodes": ["DK"], "modelType":"Full", "Downsample": false
}'
This streams ships with type 30 from Denmark.
Example JSON response
{"mmsi":219339000,"msgtime":"2022-11-02T13:41:04+00:00","altitude":null,"courseOverGround":66,"latitude":62.63744,"longitude":7.098343,"navigationalStatus":5,"rateOfTurn":0,"speedOverGround":4.8,"trueHeading":63,"imoNumber":9468372,"callSign":"OZLM2","name":"HUNTER","destination":"DKSKA","eta":"11051200","draught":38,"shipLength":31,"shipWidth":9,"shipType":52,"dimensionA":8,"dimensionB":23,"dimensionC":4,"dimensionD":5,"positionFixingDeviceType":1,"reportClass":"A"}
{"mmsi":219805000,"msgtime":"2022-11-02T13:41:04+00:00","altitude":null,"courseOverGround":64.6,"latitude":59.341907,"longitude":10.517248,"navigationalStatus":1,"rateOfTurn":0,"speedOverGround":0,"trueHeading":175,"imoNumber":9722405,"callSign":"OWPW2","name":"TERNFJORD","destination":"SLAGEN","eta":"11020100","draught":70,"shipLength":147,"shipWidth":22,"shipType":85,"dimensionA":120,"dimensionB":27,"dimensionC":4,"dimensionD":18,"positionFixingDeviceType":1,"reportClass":"A"}
{"mmsi":219017214,"msgtime":"2022-11-02T13:41:04+00:00","altitude":null,"courseOverGround":39.5,"latitude":71.320422,"longitude":22.25207,"navigationalStatus":0,"rateOfTurn":0,"speedOverGround":0.2,"trueHeading":219,"imoNumber":9594042,"callSign":"OYPV2","name":"ESVAGT AURORA","destination":"GOLIAT FPSO","eta":"10210800","draught":59,"shipLength":87,"shipWidth":17,"shipType":99,"dimensionA":29,"dimensionB":58,"dimensionC":8,"dimensionD":9,"positionFixingDeviceType":1,"reportClass":"A"}
{"mmsi":219027771,"msgtime":"2022-11-02T13:41:05.8449617+00:00","altitude":null,"courseOverGround":289.7,"latitude":59.39282,"longitude":3.471525,"navigationalStatus":8,"rateOfTurn":127,"speedOverGround":8.4,"trueHeading":294,"imoNumber":null,"callSign":"OYNG","name":"L232 TOVE KYNDE","destination":"FISHING GROUNDKPON","eta":"01030501","draught":null,"shipLength":24,"shipWidth":8,"shipType":30,"dimensionA":8,"dimensionB":16,"dimensionC":4,"dimensionD":4,"positionFixingDeviceType":15,"reportClass":"A"}
Get the latest position
Latest position of all vessels
curl --location --request GET 'https://live.ais.barentswatch.no/v1/latest/combined' \
--header 'Authorization: Bearer <access_token>'
Example JSON response
[
{
"courseOverGround": 63.8,
"latitude": 59.141722,
"longitude": 5.819193,
"name": "GRIEG ARTIC",
"rateOfTurn": null,
"shipType": 53,
"speedOverGround": 0.1,
"trueHeading": null,
"mmsi": 257789800,
"msgtime": "2022-11-02T13:46:12+00:00"
},
{
"courseOverGround": 43.6,
"latitude": 67.2346,
"longitude": 14.224732,
"name": "FUGLOYFISK",
"rateOfTurn": null,
"shipType": 30,
"speedOverGround": 7.8,
"trueHeading": null,
"mmsi": 257198540,
"msgtime": "2022-11-02T13:49:39+00:00"
},
{
"courseOverGround": 210.6,
"latitude": 60.43138,
"longitude": 5.23878,
"name": "ROV1304",
"rateOfTurn": null,
"shipType": 34,
"speedOverGround": 0,
"trueHeading": 147,
"mmsi": 257055210,
"msgtime": "2022-11-02T13:35:08+00:00"
}
]
The response typically contains a few thousand vessels.
Latest position of one vessel
curl --location --request POST 'https://live.ais.barentswatch.no/v1/latest/combined' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"mmsi": [257882000]
}'
Example JSON response
[
{
"courseOverGround": 23.6,
"latitude": 68.408795,
"longitude": 16.04619,
"name": "DANTIC",
"rateOfTurn": 0,
"shipType": 70,
"speedOverGround": 8.7,
"trueHeading": 23,
"mmsi": 257882000,
"msgtime": "2022-11-02T13:54:25+00:00"
}
]
Find vessels in area
The area input is a GeoJSON polygon geometry.
You can draw the polygon you are interested in on the website https://geojson.io, then select the part of the json after "geometry:". Just make sure the area is less than 500 Km2.
curl --location --request POST 'https://historic.ais.barentswatch.no/v1/historic/mmsiinarea' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"msgtimefrom": "2022-10-25T00:00:00+00:00",
"msgtimeto": "2022-11-02T00:00:00+00:00",
"polygon":{
"coordinates": [
[
[
10.380585200334167,
63.45529966370819
],
[
10.376393978115715,
63.4497284424896
],
[
10.376104928308195,
63.44672437768591
],
[
10.383331173512175,
63.44142611902308
],
[
10.390268368908607,
63.44202383749905
],
[
10.393231129441858,
63.45494442979373
],
[
10.380585200334167,
63.45529966370819
]
]
],
"type": "Polygon"
}
}'
Example response
[
229061000,
247229700,
257072900,
257082200,
257114400,
257119000,
257213000,
257234800,
257347700,
257391000,
257752000,
257753000,
257882000,
257940800
]
The service only have data for the latest 14 days, so make sure msgtimefrom
and msgtimeto
is within that time frame.
Get vessel track
curl --location --request GET 'https://historic.ais.barentswatch.no/v1/historic/trackslast24hours/259139000' \
--header 'Authorization: Bearer <access_token>'
Example JSON response
[
{
"courseOverGround": 249.7,
"latitude": 63.642362,
"longitude": 9.613247,
"name": "NORDLYS",
"rateOfTurn": 0,
"shipType": 60,
"speedOverGround": 14.4,
"trueHeading": 250,
"mmsi": 259139000,
"msgtime": "2022-11-02T13:57:43+00:00"
},
{
"courseOverGround": 249.2,
"latitude": 63.643913,
"longitude": 9.622543,
"name": "NORDLYS",
"rateOfTurn": 0,
"shipType": 60,
"speedOverGround": 14.4,
"trueHeading": 251,
"mmsi": 259139000,
"msgtime": "2022-11-02T13:56:37+00:00"
}
...
]