npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aisstreamer

v0.0.2

Published

Easy-to-use client for the AISstream socket API

Downloads

17

Readme

AISstreamer Test and generate docs

Client for AISstream socket API. It uses AISstream free (and experimental) API to track specific, single, ships (in the first version).

Installation

It should be as easy as npm install aisstreamer.

Documentation

Documentation is hosted at GitHub pages; regenerate it locally after changes with npm run doc. If you fork this repository and give the fork the necessary permissions, the included workflow will do that for you.

Use

Two exported functions, AISTrackAll and AISTrack, as well as a constant, defaultBoundingBox

import { AIStrack, AISTrackAll, defaultBoundingBox } from "aisstreamer";

// API_KEY can be defined as an environment variable
const API_KEY = process.env.AISSTREAM_API_KEY;

// Execute the callback for every message related to vessels in the box
AISTrackAll(API_KEY,
            defaultBoundingBox,
            (msg) => console.log( msg["MessageType"]));

// The exact ship name needs to be used; this might include the company name
const SHIP_NAME = process.env.SHIP_NAME.toUpperCase();

AIStrack(API_KEY, SHIP_NAME);

This will use the default callback, which simply prints the message in JSON format, every time it finds the ship. Please read the documentation if you want to change the tracked zone, as well as have a different callback called when the ship is found. Please check out the reference for a more extensive explanation, and the examples directory for a few scripts that use this.

AISstream messages

Every message received from AISstream will have a form similar to this one

 {
  Message: {
    ShipStaticData: {
      AisVersion: 2,
      CallSign: 'ZGIJ3',
      Destination: 'ANTIBES',
      Dimension: [Object],
      Dte: false,
      Eta: [Object],
      FixType: 3,
      ImoNumber: 9794549,
      MaximumStaticDraught: 3.3,
      MessageID: 5,
      Name: 'PAPA',
      RepeatIndicator: 0,
      Spare: false,
      Type: 37,
      UserID: 319156300,
      Valid: true
    }
  },
  MessageType: 'ShipStaticData',
  MetaData: {
    MMSI: 319156300,
    ShipName: 'PAPA',
    latitude: 43.587181666666666,
    longitude: 7.130946666666667,
    time_utc: '2023-05-10 11:46:52.509865357 +0000 UTC'
  }
}

That is, there are three keys: Message, MessageType, Metadata. The value of MessageType will be also the single key in Message. The content of this message will vary with the type of data; however, the Metadata part will remain invariable, and it contains the name of the ship as well as the MMSI for the ship we're tracking

Versions

  • 0.0.1 Initial version.

LICENSE

(c) JJ Merelo, 2023

This is released under the GPL-3.0 license. See LICENSE for more information.