This is a client library for FlightAware's Firehose Flight Data Feed, a real-time data feed of global aircraft ADS-B positions and flight status.
This is an unofficial library and is not endorsed or supported by FlightAware.
This library is a work in progress! Currently only position
messages are supported.
To use Firehose, you'll need to set up API credentials. Log in to your FlightAware account and visit your Firehose Dashboard to view get your API key.
Once you have your credentials, you can use them in your project. Here's an example:
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/benburwell/firehose"
)
func main() {
// Open a basic connection to Firehose.
stream, err := firehose.Connect()
if err != nil {
log.Fatal(err)
}
// Initiate the stream
init := firehose.InitCommand{
// Get events starting from the present
Live: true,
// Provide your credentials
Username: os.Getenv("FIREHOSE_USERNAME"),
Password: os.Getenv("FIREHOSE_PASSWORD"),
// Specify the event types you want to receive
Events: []firehose.Event{firehose.PositionEvent},
}
if err := stream.Init(init.String()); err != nil {
log.Fatal(err)
}
for {
// Iterate over received messages from the stream
msg, err := stream.NextMessage(context.Background())
if err != nil {
log.Fatal(err)
}
switch m := msg.Payload.(type) {
case firehose.PositionMessage:
fmt.Printf("%s is at %sºN, %sºE\n", m.Ident, m.Lat, m.Lon)
}
}
}