Flightaware API client for Go using Protocol Buffers and gRPC https://godoc.org/go.pedge.io/flightaware/go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
go
proto
.dockerignore
Dockerfile
LICENSE
Makefile
README.md
circle.yml
protoeasy.yaml

README.md

CircleCI Go Report Card GoDoc MIT License

Note the custom import path!

import (
  "go.pedge.io/flightaware/go"
)

Flightaware is a package that exposes the data from http://flightaware.com/commercial/flightxml.

The WSDL definition is translated into proto/flightaware.proto and go/flightaware.gen.go. The protobuf file produces go/flightaware.pb.go and go/flightaware.pb.gw.go. Therefore, the whole package is basically generated.

You need to get a Flightaware API key to use this package.

The APIClient interface is the main entry point for callers of this library. Authorization is attached the the context.

The APIServer could be run in the future if libraries were generated off the proto definition for other languages, as a relayer to the Flightaware API.

This is extremely new, I just wrote this on December 4th, 2015. Please try it out and report issues, cleanup is needed.

Note that the Firehose API and push notifications are not implemented yet.

Example

import (
	"fmt"

	"go.pedge.io/flightaware/go"
	"go.pedge.io/proto/http"
	"golang.org/x/net/context"
)

func do(username string, apiKey string) error {
	basicAuth := protohttp.BasicAuth{
		Username: username,
		Password: apiKey,
	}
	response, err := flightaware.DefaultLocalAPIClient.FlightInfo(
		basicAuth.NewContext(context.Background()),
		&flightaware.FlightInfoRequest{
			Ident: "AUA87",
		},
	)
	if err != nil {
		return err
	}
	if response != nil && response.FlightInfoResult != nil {
		for _, flightStruct := range response.FlightInfoResult.Flights {
			fmt.Println(flightStruct.Aircrafttype) // usually a 767
		}
	}
	return nil
}

Future Work

Please contact me if you want to help out!