Skip to content

aeharding/tfr-scraper

Repository files navigation

tfr-scraper

AWS Lambda service that scrapes FAA Temporary Flight Restrictions (TFRs) and stores them in MongoDB for geo-querying.

Architecture

Two Lambda functions deployed via Serverless Framework:

  • scraper -- Runs every 15 minutes. Fetches the current TFR list and geometry from the FAA WFS GeoJSON endpoint, then retrieves detailed NOTAM data from the FAA NMS-API. Results are stored in MongoDB with a 2dsphere index.
  • query -- GET /api/tfr?lat=...&lon=...&radialDistance=... returns TFRs within the given radius (meters).

Prerequisites

Setup

1. Install dependencies

yarn install

2. Create config file

Create a config.prod.json in the project root (gitignored):

{
  "MONGODB_USER": "your-mongodb-user",
  "MONGODB_PASSWORD": "your-mongodb-password",
  "MONGODB_HOST": "your-cluster.mongodb.net",
  "NMS_API_HOST": "https://api-nms.aim.faa.gov",
  "NMS_API_KEY": "your-nms-api-key",
  "NMS_API_SECRET": "your-nms-api-secret"
}

For other stages, create config.<stage>.json (e.g. config.dev.json).

Deployment

npx serverless deploy --stage prod

To deploy to a different stage:

npx serverless deploy --stage dev

Invoking manually

Trigger the scraper on-demand:

npx serverless invoke --function scraper --stage prod

Test the query endpoint:

curl "https://<api-id>.execute-api.us-east-1.amazonaws.com/api/tfr?lat=38.85&lon=-77.04&radialDistance=50000"

About

Scrape TFRs and store them in MongoDB (with a geospatial index)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors