A Spring Boot REST API service for decoding AIS (Automatic Identification System) NMEA messages.
This service provides a simple HTTP API to decode AIS messages from NMEA format into structured JSON data. It uses the aismessages library to parse and decode AIS messages.
AIS (Automatic Identification System) is an automatic tracking system used on ships and by vessel traffic services (VTS) for identifying and locating vessels by electronically exchanging data with other nearby ships, AIS base stations, and satellites.
- REST API endpoint for decoding AIS NMEA messages
- Support for multi-line NMEA messages (message fragments)
- Returns decoded AIS messages as JSON
- Built with Spring Boot for easy deployment
- Docker support for containerized deployment
- Java 21 or higher
- Gradle (included via wrapper)
Build the project using the Gradle wrapper:
./gradlew buildThis will compile the code, run tests, and create a JAR file in build/libs/.
./gradlew bootRunjava -jar build/libs/aisdecoder-0.0.1-SNAPSHOT.jarBuild the Docker image:
./gradlew build
docker build -t aisdecoder .Run the container:
docker run -p 8080:8080 aisdecoderThe service will start on port 8080 by default.
Endpoint: POST /decode
Content-Type: application/json
Request Body: JSON array of NMEA message strings
Example:
curl -X POST http://localhost:8080/decode \
-H "Content-Type: application/json" \
-d '["!AIVDM,1,1,,A,13HOI:0P0000VOHLCnHQKwvL05Ip,0*23"]'Response: JSON array of decoded AIS message objects
The structure of the response depends on the type of AIS message being decoded. Each message type has different fields according to the AIS specification.
Some AIS messages are split across multiple NMEA sentences:
curl -X POST http://localhost:8080/decode \
-H "Content-Type: application/json" \
-d '[
"!AIVDM,2,1,3,B,55?MbV02>H97ac<H4F220<h6@E:22222222220t1@H:36ho0Ht50000000000,0*09",
"!AIVDM,2,2,3,B,000000000000000,2*27"
]'- Spring Boot 3.1.5 - Application framework
- aismessages 4.1.0 - AIS message parsing library
- Java 21 - Programming language
- Gradle 8.5 - Build tool
aisdecoder/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── dk/tbsalling/ais/decoder/aisdecoder/
│ │ │ ├── AisdecoderApplication.java # Spring Boot main application
│ │ │ ├── AisdecoderController.java # REST controller
│ │ │ └── AisdecoderService.java # AIS decoding service
│ │ └── resources/
│ │ └── application.properties
│ └── test/
│ └── java/
│ └── dk/tbsalling/ais/decoder/aisdecoder/
│ └── AisdecoderApplicationTests.java
├── build.gradle # Gradle build configuration
├── Dockerfile # Docker container configuration
└── README.md # This file
This project is maintained by Thomas Borg Salling (tbsalling@tbsalling.dk).
- aismessages - The underlying AIS message parsing library
Contributions are welcome! Please feel free to submit a Pull Request.