A secure, production-ready Cloudflare Worker that relays requests to the APRS.fi API
APRS (Automatic Packet Reporting System) is a digital communications system used by amateur radio operators to share real-time information including:
- GPS coordinates and vehicle tracking
- Weather station data
- Telemetry from sensors
- Text messaging
- Emergency beacons
| Feature | Description |
|---|---|
| API Key Protection | Your APRS.fi API key is stored securely as a Cloudflare Worker secret |
| CORS Enabled | Use directly from web browsers without CORS issues |
| Request Validation | Validates parameters before calling the upstream API |
| Response Caching | 30-second cache reduces API load and improves response times |
| Error Handling | Graceful error messages with proper HTTP status codes |
| Health Check | /health endpoint for monitoring service status |
| Timeout Protection | 10-second timeout prevents hanging requests |
| Edge Network | Deployed on Cloudflare's global network for low latency |
Click the Deploy button above. You'll need to:
- Authorize with your Cloudflare account
- Set the
APRS_API_KEYsecret (get your key at aprs.fi) - Deploy!
That's it - your worker will be live at https://your-worker.workers.dev
# Clone the repository
git clone https://github.com/bcanata/aprs-api-relay.git
cd aprs-api-relay
# Install dependencies
npm install
# Login to Cloudflare
npx wrangler login
# Set your APRS.fi API key as a secret
echo "your-api-key-here" | npx wrangler secret put APRS_API_KEY
# Deploy
npm run deploy# Health check
curl https://your-worker.workers.dev/health
# Lookup a callsign
curl "https://your-worker.workers.dev/?what=loc&format=json&name=TA1ANW"
# Search near coordinates
curl "https://your-worker.workers.dev/?what=loc&format=json&lat=40.9935&lng=27.5983"
# Weather stations
curl "https://your-worker.workers.dev/?what=wx&format=json&lat=40.9935&lng=27.5983"// Works directly in the browser thanks to CORS!
const response = await fetch('https://your-worker.workers.dev/?what=loc&format=json&name=TA1ANW');
const data = await response.json();
console.log(data);const response = await fetch('https://your-worker.workers.dev/?what=loc&format=json&name=TA1ANW');
const data = await response.json();
console.log(data);The proxy accepts all standard APRS.fi API parameters. The apikey parameter is automatically added.
| Parameter | Required | Description |
|---|---|---|
what |
Yes | Query type: loc, wx, enter, or list |
name |
Conditional | Callsign or identifier (for loc queries) |
lat |
Conditional | Latitude (for location-based queries) |
lng |
Conditional | Longitude (for location-based queries) |
format |
No | Response format: json (default) or xml |
limit |
No | Maximum number of results |
See the APRS.fi API documentation for complete parameter reference.
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check and service info |
/health |
GET | Health check endpoint |
/?what=... |
GET | Proxy to APRS.fi API |
{
"command": "get",
"result": "ok",
"what": "loc",
"found": 1,
"entries": [
{
"name": "TA1ANW",
"lat": "40.99350",
"lng": "27.59833",
"type": "l",
"comment": "Test"
}
]
}# Install dependencies
npm install
# Run local development server
npm run dev
# Set up local environment variables
cp .dev.vars.example .dev.vars
# Edit .dev.vars and add your API key
# View logs from deployed worker
npm run tail| Variable | Description | Required |
|---|---|---|
APRS_API_KEY |
Your APRS.fi API key | Yes |
- API keys are stored as Cloudflare Worker secrets, never in code
- Client-provided API keys are stripped from requests
- 10-second timeout prevents resource exhaustion
- Only GET requests are allowed for API proxy calls
Set the secret:
echo "your-api-key" | npx wrangler secret put APRS_API_KEYEnsure you're passing the what parameter and required parameters for your query type.
The proxy has a 10-second timeout. If APRS.fi is slow, the request will fail gracefully.
MIT License - see LICENSE for details.