AISStream.NET 1.0.0

dotnet add package AISStream.NET --version 1.0.0
                    
NuGet\Install-Package AISStream.NET -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AISStream.NET" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AISStream.NET" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AISStream.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AISStream.NET --version 1.0.0
                    
#r "nuget: AISStream.NET, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AISStream.NET@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AISStream.NET&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AISStream.NET&version=1.0.0
                    
Install as a Cake Tool

AISStream.NET

An aisstream.io client library for .NET

Overview

AISStream.NET provides a memory-efficient client library for receiving AIS data from aisstream.io with support for:

  • Custom bounding boxes (including global coverage)
  • Filters for message types and MMSI numbers
  • Automatic websocket reconnection
  • Async processing for multiple concurrent readers

Usage

You will need an aisstream.io API key, which you can obtain by signing up on their website with a GitHub account.

  1. Install the package via NuGet
  2. Create an AISEventReceiver using your API key
  3. Call ConnectAsync with your desired AISSubscriptionRequestOptions
  4. Await events from the EventStream, retrieving the AISEvent.Message property for each event
  5. Disconnect once finished using DisconnectAsync
public static class Program 
{
    public static async Task Main(string[] args)
    {
        // use a cancellation token to break out of the event loop
        // if used in a worker, this token would be cancelled in the StopAsync method
        using var cancellationTokenSource = new CancellationTokenSource();
        
        // create event receiver with api key from aisstream.io
        var client = new AISEventReceiver("your_api_key_here");
        var options = new AISSubscriptionRequestOptions 
        {
            BoundingBoxes = [BoundingBox.World],
            FiltersMessageType = [AISMessageType.PositionReport, AISMessageType.ShipStaticData]
        };
        
        // start connection and begin reading events
        await client.ConnectAsync(options);
    
        try
        {
            await foreach (var aisEvent in client.EventStream.ReadAllAsync(cancellationTokenSource.CancellationToken))
            {
                ProcessMessage(aisEvent);
            }
        }
        catch (OperationCancelledException) when (cancellationTokenSource.IsCancellationRequested)
        {
            // expected when cancelling
        }
        
        // disconnect when done
        await client.DisconnectAsync();
    }
    
    private static void ProcessMessage(AISEvent event) 
    {
        switch (event.Message)
        {
            case AISPositionReportMessage positionReport:
                Console.WriteLine($"Position report from MMSI {positionReport.MMSI}: Lat {positionReport.Latitude}, Lon {positionReport.Longitude}");
                break;
    
            case AISShipStaticDataMessage staticData:
                Console.WriteLine($"Static data from MMSI {staticData.MMSI}: Name {staticData.ShipName}, Type {staticData.ShipType}");
                break;
    
            default:
                Console.WriteLine($"Received other AIS message type: {event.Message.GetType().Name}");
                break;
        }
    }
}

License

This project is licensed under the Apache-2.0 License. See license.md for more details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 327 12/7/2025