This is a client library forFlightAware's Firehose Flight Data Feed,a real-time data feed of global aircraft ADS-B positions and flight status.
This is anunofficiallibrary and is not endorsed or supported by FlightAware.
This library is a work in progress!Currently onlyposition
messages are supported.
To use Firehose, you'll need to set up API credentials. Log in to your FlightAware account and visit yourFirehose Dashboardto view get your API key.
Once you have your credentials, you can use them in your project. Here's an example:
packagemain
import(
"context"
"fmt"
"log"
"os"
"github.com/benburwell/firehose"
)
funcmain() {
// Open a basic connection to Firehose.
stream,err:=firehose.Connect()
iferr!=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},
}
iferr:=stream.Init(init.String());err!=nil{
log.Fatal(err)
}
for{
// Iterate over received messages from the stream
msg,err:=stream.NextMessage(context.Background())
iferr!=nil{
log.Fatal(err)
}
switchm:=msg.Payload.(type) {
casefirehose.PositionMessage:
fmt.Printf("%s is at %sºN, %sºE\n",m.Ident,m.Lat,m.Lon)
}
}
}