> For the complete documentation index, see [llms.txt](https://wingbits.gitbook.io/wingbits-ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wingbits.gitbook.io/wingbits-ai/build/nats-stream.md). Agents can also search and read this documentation through its [MCP server](https://wingbits.gitbook.io/wingbits-ai/~gitbook/mcp).

# Real-time stream (NATS)

Welcome! This guide walks you through connecting to the Wingbits real-time flight data stream, step by step. You do **not** need to be a developer to get the first flights showing up on your screen — if you can copy and paste a few commands, you're good. The whole thing takes about **10 minutes**.

> Throughout this guide, replace `<CUSTOMER>` with your company name wherever you see it (for example, `acme`). We'll send you a file named `prod-<CUSTOMER>-trial.creds` — that file is your key to the stream. We'll also send you the exact NATS subject assigned to your account. Use that subject exactly as provided; scoped trials cannot subscribe to every example subject shown in this guide.

***

## What you'll be connecting to

Wingbits delivers live aircraft positions (and more) over a system called [**NATS**](https://nats.io/). Think of NATS like a radio: we broadcast flight updates on different "channels" (called **subjects**), and you tune in to the ones you care about. It's fast, lightweight, and there are ready-made libraries for almost every programming language — but you can also just listen in from your terminal, which is what we'll do first.

**Two things you need:**

1. **The NATS command-line tool** (`nats`) — free, we'll install it below.
2. **Your credentials file** (`prod-<CUSTOMER>-trial.creds`) — we send this to you by email. Keep it private; it's like a password.

> **Don't have credentials yet?** If you're interested in trialing our NATS integration but don't yet have a credentials file, email us at [**sales@wingbits.com**](mailto:sales@wingbits.com) and we'll get you set up.

***

## Step 1 — Install the NATS tool

Pick your operating system.

**macOS** (using [Homebrew](https://brew.sh/)):

```shell
brew install nats-io/nats-tools/nats
```

**Windows** (using [Scoop](https://scoop.sh/)):

```shell
scoop install nats
```

**Linux** (or anything else):

```shell
curl -sf https://binaries.nats.dev/nats-io/natscli/nats@latest | sh
```

Check it worked by running:

```shell
nats --version
```

If you see a version number (e.g. `0.1.x`), you're ready. If it says "command not found", the install didn't complete — see [Troubleshooting](#troubleshooting).

***

## Step 2 — Save your credentials file

We send you your credentials as a file called `prod-<CUSTOMER>-trial.creds`. Save it somewhere you can find it — your Downloads folder is fine. **Open a terminal in that same folder** so the next commands can find the file.

> **What do credentials actually look like?** This is the #1 source of confusion, so check now that you really have them. A valid creds file is plain text, about 13 lines, and contains **two** long codes between labeled markers:
>
> * A **JWT** that starts with `eyJ...` and is several hundred characters long (around 700+), sitting between `-----BEGIN NATS USER JWT-----` and `------END NATS USER JWT------`.
> * A **seed** that starts with `SU...` and is **58 characters** long, sitting between `-----BEGIN USER NKEY SEED-----` and `------END USER NKEY SEED------`.
>
> If what you received has **no `eyJ...` block and no `SU...` block**, you don't actually have credentials yet — email [**sales@wingbits.com**](mailto:sales@wingbits.com) before going further.

> **Received your credentials as&#x20;*****text*****&#x20;instead of a file?** Sometimes the credentials arrive pasted into a document or email body rather than as an attachment. They'll look like a block starting with `-----BEGIN NATS USER JWT-----` and ending with `------END USER NKEY SEED------`. If so, you need to save that block as a file yourself:
>
> 1. Copy the **entire** block (from the first `-----BEGIN` to the last `-----`).
> 2. Open a plain-text editor (TextEdit in *plain text* mode, Notepad, VS Code).
> 3. Paste it in and save the file as `prod-<CUSTOMER>-trial.creds`.
>    * **macOS shortcut:** copy the block, then run `pbpaste > ~/Downloads/prod-<CUSTOMER>-trial.creds` in your terminal.

> Not sure how to "open a terminal in a folder"?
>
> * **macOS:** right-click the folder → *New Terminal at Folder*.
> * **Windows:** open the folder, type `cmd` in the address bar, press Enter.

**Confirm the file is really there before continuing.** In your terminal, run:

```shell
ls prod-<CUSTOMER>-trial.creds
```

If it prints the filename back, you're good. If it says `No such file or directory`, the file isn't in this folder — find where you saved it, or re-save it here. (Tip: on macOS you can avoid folder confusion entirely by using the file's **full path** in the next step — type `--creds "` and then drag the file from Finder into the terminal to paste its full path.)

***

## Step 3 — Connect

In the **same terminal window** from Step 2, paste the command below and press Enter. You only need to run it **once** — it saves a "context" (a saved connection) called `prod-<CUSTOMER>-trial` so you don't have to retype the server and credentials every time.

**Copy this as a single line** (don't break it across multiple lines):

```shell
nats context add prod-<CUSTOMER>-trial --server "nats://nats-cluster.wingbits.com:4222" --creds "prod-<CUSTOMER>-trial.creds" --select
```

> **Why one line?** If you split a command across multiple lines using `\`, the backslash must be the *very last* character on the line — a single stray space after it will break the whole command (you'll see `command not found` errors). Pasting it as one line avoids this entirely.

The `--select` at the end makes this your active connection. If the command runs with no error and returns you to a normal prompt, it worked.

***

## Step 4 — Test your connection

Let's make sure everything is wired up correctly:

```shell
nats context info
```

You should see your server (`nats-cluster.wingbits.com`) and your credentials file listed. Now subscribe to the **exact subject in your onboarding email**:

```shell
nats sub "<YOUR_ASSIGNED_SUBJECT>"
```

For example, a geographically scoped trial subject may look like this:

```shell
nats sub "flights.customers.trials.<TRIAL>.>"
```

Wingbits provides the complete subject string; you do not need to substitute `<TRIAL>` yourself.

Keep the final wildcard exactly as provided. Subscribing to the base subject without it, or replacing it with a broader subject such as `flights.>`, will be rejected by scoped credentials.

Within a few seconds you should start seeing flight updates streaming down your screen. **That's it — you're connected to live aircraft data.** Press `Ctrl + C` to stop.

If nothing shows up, jump to [Troubleshooting](#troubleshooting).

***

## How scoped trial access works

Scoped trial credentials are normally **subscribe-only** and restricted to the subject in your onboarding email. Use a direct Core NATS subscription:

* Do not publish messages with the trial credentials.
* Do not use request/reply APIs or create `_INBOX.*` subscriptions.
* Do not use JetStream APIs unless Wingbits has explicitly enabled them.
* Do not broaden or shorten the assigned subject.

The live feed does not replay messages missed while your client is disconnected. Keep the subscriber running and continuously reading from the connection.

***

## Keep your consumer healthy

The Wingbits flight stream is a live Core NATS feed. Your application must keep reading from the connection as messages arrive. If processing is slower than the incoming feed, messages build up in the client library's pending buffer. That can cause the client to drop messages and report a `Slow Consumer` warning.

If a client stops draining its network connection quickly enough, the Wingbits NATS service may close that connection. This is a deliberate safeguard that protects stream latency and performance for all customers; it is not an account revocation. Most NATS clients can reconnect automatically, but messages missed while disconnected are not replayed.

### Production consumer checklist

* Keep the subscription handler fast. Decode or validate the message, place it on a bounded internal queue, and return immediately.
* Perform database writes, file writes, API calls, and other slower work in separate workers. Do not block the NATS read loop on downstream systems.
* Bound and monitor internal queues. An ever-growing queue only moves the backlog and can eventually exhaust memory.
* Monitor pending messages and bytes, dropped-message or slow-consumer events, processing latency, queue depth, and disconnect/reconnect events. Configure your NATS client's asynchronous error or status handler so these signals are not lost.
* Enable automatic reconnect with backoff, and alert on repeated disconnects. A reconnect restores the live feed but does not recover missed messages.
* Load-test against the feed's peak rate, not only its average rate. Confirm that queue depth returns to normal after a burst.
* If your application cannot keep up with the assigned cadence, ask Wingbits whether a lower-frequency subject is available for your account.

Pending-buffer defaults and slow-consumer behavior differ between NATS client libraries. Review the official [NATS slow-consumer guidance](https://docs.nats.io/learn/resilient-clients/slow-consumers) for the options and events exposed by your client.

***

## Step 5 — Choose the right stream for you

If your account includes the general network subjects, we broadcast the **same flight data** at three different speeds. Pick the one that matches how "live" you need it to be. Faster = more data to handle. Scoped trials should continue using their assigned subject unless Wingbits confirms additional access.

| Channel (subject) | How often each aircraft updates     | Best for                                          |
| ----------------- | ----------------------------------- | ------------------------------------------------- |
| `flights.full.>`  | Every update, up to \~2× per second | Live maps, anything needing the freshest position |
| `flights.5s.>`    | Once every 5 seconds                | Most use cases — a great default                  |
| `flights.dd.>`    | Once every 10 seconds               | Dashboards, analytics, lower bandwidth            |

The `>` at the end is a **wildcard** meaning "every aircraft you're allowed to see." So `flights.5s.>` = all your aircraft, updated every 5 seconds.

To listen to a channel, just `sub` (subscribe) to it:

```shell
nats sub "flights.5s.>"      # all aircraft, every 5 seconds
nats sub "flights.full.>"    # all aircraft, as fast as it comes
```

### Following one specific aircraft

Every aircraft has a unique ID called an **ICAO hex** (a 6-character code like `7820d9`). To follow just one aircraft, put its hex at the end:

```shell
nats sub "flights.full.7820d9"
```

### Following a list of aircraft (a fleet)

If you only need certain aircraft, we grant you access to that exact list and you subscribe to each one. You can listen to several at once:

```shell
nats sub "flights.full.7820d9" "flights.full.a1b2c3" "flights.full.c0ffee"
```

> Just tell us which aircraft (or geographic area) you care about, and we'll set your access up to match.

***

## Optional add-ons

These are extra data feeds available on request. Once enabled for your account, you subscribe to them the same way:

| Add-on          | Subject        | What it is                                                     |
| --------------- | -------------- | -------------------------------------------------------------- |
| **ACAS / TCAS** | `flights.acas` | Collision-avoidance "resolution advisory" events               |
| **ADS-C**       | `flights.adsc` | Oceanic / satellite-based positions (aircraft over open ocean) |

```shell
nats sub "flights.acas"
nats sub "flights.adsc"
```

***

## Understanding the data

Each message is a small **JSON** record describing one aircraft at one moment. To keep messages tiny and fast, the field names are short codes. Here's what they mean:

| Code  | Field                            | Description                                |
| ----- | -------------------------------- | ------------------------------------------ |
| `h`   | ICAO Hex                         | The aircraft's unique ID                   |
| `f`   | Flight                           | Flight number / callsign                   |
| `la`  | Latitude                         | Aircraft latitude                          |
| `lo`  | Longitude                        | Aircraft longitude                         |
| `ab`  | Barometric Altitude              | Altitude from barometric pressure          |
| `ag`  | Geometric Altitude               | Altitude from GPS                          |
| `gs`  | Ground Speed                     | Speed over the ground                      |
| `tr`  | Track                            | Direction of travel (track angle)          |
| `th`  | True Heading                     | Heading relative to true north             |
| `mh`  | Magnetic Heading                 | Heading relative to magnetic north         |
| `og`  | On Ground                        | Whether the aircraft is on the ground      |
| `sq`  | Squawk                           | Transponder squawk code                    |
| `c`   | Category                         | Aircraft category                          |
| `t`   | Type                             | Message type                               |
| `v`   | Version                          | ADS-B version                              |
| `a`   | Alert                            | Alert status                               |
| `em`  | Emergency                        | Emergency status                           |
| `spi` | SPI                              | Special Position Indicator                 |
| `br`  | Baro Rate                        | Rate of climb/descent (barometric)         |
| `gr`  | Geometric Rate                   | Rate of climb/descent (GPS)                |
| `i`   | IAS                              | Indicated air speed                        |
| `m`   | Mach                             | Mach number                                |
| `ct`  | Calculated Track                 | Track calculated from position             |
| `oat` | Outside Air Temperature          | Air temperature outside the aircraft       |
| `tat` | Total Air Temperature            | Total air temperature                      |
| `wd`  | Wind Direction                   | Direction the wind is coming from          |
| `ws`  | Wind Speed                       | Wind speed                                 |
| `ro`  | Roll                             | Roll angle                                 |
| `trr` | Track Rate                       | Rate of change in track                    |
| `rs`  | RSSI                             | Received signal strength                   |
| `sn`  | Seen                             | When the message was last seen             |
| `sp`  | Seen Position                    | When the position was last seen            |
| `rc`  | Radius of Containment            | Position accuracy measure                  |
| `rdi` | Receiver Direction               | Direction from receiver to aircraft        |
| `rds` | Receiver Distance                | Distance from receiver to aircraft         |
| `nh`  | Nav Heading                      | Selected heading                           |
| `nq`  | Nav QNH                          | Altimeter setting                          |
| `naf` | Nav Altitude FMS                 | Altitude from the Flight Management System |
| `nam` | Nav Altitude MCP                 | Altitude set on the Mode Control Panel     |
| `n`   | Navigation Integrity Category    | NIC value                                  |
| `nb`  | NIC Baro                         | NIC value from barometric source           |
| `np`  | Navigation Accuracy for Position | NAC-p value                                |
| `nv`  | Navigation Accuracy for Velocity | NAC-v value                                |
| `s`   | SIL                              | Source Integrity Level                     |
| `st`  | SIL Type                         | Type of SIL                                |
| `sda` | SDA                              | System Design Assurance level              |
| `gv`  | Geometric Vertical Accuracy      | Accuracy of geometric altitude             |
| `gpb` | GPS OK Before                    | GPS was recently OK                        |

> Not every field appears in every message — aircraft only report what their equipment supports.

***

## Using the data in your own software

The terminal is great for testing, but you'll probably want to pull this into your own application. NATS has official libraries for [most languages](https://docs.nats.io/using-nats/developer) (Python, JavaScript, Go, Java, C#, Rust, and more). They all use the **same** server address, credentials file, and subjects you used above.

**Python example** (`pip install nats-py`):

```python
import asyncio, json
import nats

async def main():
    nc = await nats.connect(
        "nats://nats-cluster.wingbits.com:4222",
        user_credentials="prod-<CUSTOMER>-trial.creds",
    )
    subject = "<YOUR_ASSIGNED_SUBJECT>"

    async def on_message(msg):
        data = json.loads(msg.data)
        print(f"{data.get('h')}  lat={data.get('la')}  lon={data.get('lo')}")

    await nc.subscribe(subject, cb=on_message)
    await asyncio.Event().wait()  # keep listening

asyncio.run(main())
```

**Node.js example** (`npm install nats`):

```javascript
import { connect, credsAuthenticator } from "nats";
import { readFileSync } from "fs";

const nc = await connect({
  servers: "nats://nats-cluster.wingbits.com:4222",
  authenticator: credsAuthenticator(readFileSync("prod-<CUSTOMER>-trial.creds")),
});

const subject = "<YOUR_ASSIGNED_SUBJECT>";
const sub = nc.subscribe(subject);
for await (const msg of sub) {
  const data = JSON.parse(msg.string());
  console.log(data.h, data.la, data.lo);
}
```

***

## Troubleshooting

**`nats: command not found`** The tool didn't install. Re-run the install step for your OS, then close and reopen your terminal.

**`no such file or directory` mentioning your `.creds` file** Your terminal isn't in the same folder as the credentials file. Either move the `.creds` file into the folder your terminal is in, or use the full path to it, e.g. `--creds "/Users/you/Downloads/prod-<CUSTOMER>-trial.creds"`.

**`nats: error: nats: Authorization Violation`** The credentials were not accepted. Double-check that you're using the exact `.creds` file we sent and that the file still contains both the JWT and NKEY seed blocks. If it persists, contact us so we can check the credential.

**`Permissions Violation for Subscription` / `Subscription Violation`** The connection succeeded, but the subject is outside the credential's allowed scope. Copy the assigned subject from your onboarding email exactly, including the final wildcard. Do not substitute `flights.>`, `flights.full.>`, or another subject unless Wingbits has enabled it for your account.

Some client libraries use request/reply by creating an `_INBOX.*` subscription. That pattern is not allowed for a subscribe-only trial. Use the client's direct subscribe API instead of its request API.

**`Slow Consumer` warning** Your application is not processing messages as quickly as they arrive. Messages may already have been dropped by the client library. Follow the [production consumer checklist](#production-consumer-checklist): keep the subscription handler lightweight, move slower work to a bounded worker queue, and monitor the client's pending and dropped-message counters. If the condition persists, Wingbits may close the connection; see **Repeated disconnects** below.

**Repeated disconnects** Run the minimal `nats sub` command from Step 4. If the CLI connection remains stable, check your integration's connection lifecycle and reconnect settings. If both the CLI and your integration disconnect, check for network, firewall, NAT, or idle-timeout issues. A slow consumer can also be disconnected, so check for a `Slow Consumer` warning, growing queue depth, or blocked subscription handler before treating this as a network problem. Wingbits may close a connection that does not drain data quickly enough in order to protect stream latency and performance for other customers.

**It connects, but no flights appear**

* Confirm that the command uses the exact assigned subject, including its final wildcard.
* Remember that a region-scoped feed may be quiet when no aircraft are inside the covered area.
* If your account includes general network subjects, try `flights.full.>` for more frequent updates.
* Confirm with us which subjects and coverage your account is allowed to see.

**`connection refused` / timeout** Your network may be blocking outbound port **4222**. Check with your IT team, or try from a different network to confirm.

***

## Need help?

Reply to your onboarding email or reach out to your Wingbits contact. Tell us:

* What command you ran
* The exact message you got back
* The assigned subject you used
* Your client library and version
* Whether the minimal `nats sub` command works

and we'll get you sorted quickly.

Happy tracking! ✈️

— The Wingbits Team
