🛫☀️🌦
Latest worldwide aviation weather and airport data, delivered via GraphQL
metar.gg is a server written in Go that provides a GraphQL API, for querying the latest METARs, TAFs, airports and runways. It imports airport data from OurAirports.com and METAR and TAF data from NOAA.
You can either host it yourself or use the hosted version of this API available at rapidapi.com. The hosted version imports airport data every 7 days and weather data every 5 minutes, and retains the weather data for 7 days.
- Imports Airports, METARs and TAFs
- Hashing, for duplicate detection
- Syncs all Airport Data and removes old ones
- Timezone data for airports
- Generate a sitemap for all airports with a weather station
- GraphQL API
- Unit Conversion API
- Airport vicinity search
- Next METAR Time Prediction
- Search API
- Pagination
- Go
- GraphQL
- MySQL Database
- ent: Entity framework for Go
- gqlgen: GraphQL server library for Go
- gin: Web framework for Go
- Optional: Axiom for logging data ingestion
The easiest way to run the server is by using the Docker image. You only need to provide it with a MySQL database and off you go! 🛫
See .env.example
to see what environment variables are required.
You can also easily compile the server yourself and run the binary.
See the Dockerfile
for an example of how to compile the server.
The GraphQL API is available at /graphql
. You can use introspection to see what queries are available.
You can either use the builtin CRON_* environment Variables (see .env.example
) or use the HTTP API to trigger the imports.
With the environment variables you are not dependent on another system, because the app will trigger the imports itself.
The server also has a few triggers to start the data import from the sources mentioned above. Those can be triggered via HTTP POST requests to:
- POST
/import/airports
: Imports airport data - POST
/import/weather
: Imports weather data - POST
/clean
: Gets rid of old weather data see.env.example
for theWEATHER_DATA_RETENTION_DAYS
variable - POST
/sitemap
: Generate sitemap asynchronously - GET
/health
: Health check endpoint
❗️Send the requests including the secret (from the ADMIN_SECRET
env variable) in the Authorization
header.
In every case, the server will respond with a 204 No content
if the import was successfully triggered. You can use some kind of cron service to trigger these endpoints at your desired intervals.
The airport data is synced, while the weather data is will only be added and not automatically removed. You can use the /clean
endpoint to remove old weather data.
- Clone the repository
- Run
go mod download
to download the dependencies - Set up the environment variables in a .env file, see
.env.example
- Run
docker-compose up -d
to start the database - Run
go run main.go
to start the server
Execute code generation with
go generate ./...
PRs are welcome! Please make sure to run go generate ./...
before committing.