Getting started overview
Getting started with ADS-B Exchange involves a sequence of steps to establish access to its flight data API. This includes registering an account, subscribing to a suitable data plan, acquiring an API key, and making an initial authenticated request. ADS-B Exchange provides access to Automatic Dependent Surveillance-Broadcast (ADS-B) data, which is a surveillance technology for tracking aircraft. The platform compiles this data from a global network of receivers (ADS-B Exchange data information).
The API offers endpoints for both real-time aircraft positions and historical flight data, supporting applications ranging from personal flight tracking to advanced aviation research (ADS-B Exchange API documentation). Developers can integrate this data into custom applications, dashboards, or analytical tools. A foundational understanding of RESTful API principles and JSON data structures is beneficial for efficient integration.
This guide provides a structured approach to quickly set up and execute your first API call, ensuring you can begin working with ADS-B Exchange data efficiently.
Quick Reference Guide
| Step | What to Do | Where |
|---|---|---|
| 1. Account Creation | Register for an ADS-B Exchange account. | ADS-B Exchange Data Page |
| 2. Subscription | Select an API data plan (e.g., Personal, Commercial). | ADS-B Exchange Pricing Page |
| 3. API Key Retrieval | Locate your unique API key in your account dashboard. | ADS-B Exchange Account Dashboard |
| 4. First Request | Construct and execute an API call using your API key. | API endpoint (e.g., https://adsbexchange.com/api/aircraft/v2/lat/XXX/lon/YYY/dist/ZZZ/) |
| 5. Data Processing | Parse the JSON response and extract relevant flight data. | Your application logic |
Create an account and get keys
To access the ADS-B Exchange API, you must first create an account and subscribe to an appropriate data plan. The platform offers various tiers, including a free option for personal feeders and paid plans for broader API access, starting at $10/month for personal use (ADS-B Exchange pricing details). Commercial and enterprise tiers are also available, tailored to higher data volumes and update frequencies.
Account Registration
- Navigate to the Data Page: Go to the official ADS-B Exchange data access page.
- Choose a Plan: Review the available data plans. For initial development, you might consider the 'Personal API Access' tier or explore the free options if you are contributing data.
- Complete Registration: Follow the prompts to create your account. This typically involves providing an email address and setting a password.
- Confirm Email: Check your email for a verification link to activate your account.
Obtaining Your API Key
Once your account is active and you have subscribed to a paid API tier, your unique API key will be generated and made available in your account dashboard.
- Log In: Access your ADS-B Exchange account using your newly created credentials.
- Locate API Key Section: Within your dashboard, look for a section labeled 'API Keys' or 'Developer Access'. The exact location may vary slightly based on updates to the ADS-B Exchange interface.
- Copy Your Key: Your API key will be displayed. It is a long alphanumeric string. Copy this key securely, as it will be used to authenticate all your API requests. Treat your API key as sensitive information to prevent unauthorized access to your usage quota (OAuth 2.0 Bearer Token usage).
Store your API key in a secure manner, such as environment variables, rather than embedding it directly in your code, especially for production applications.
Your first request
With your API key in hand, you can now make your first request to the ADS-B Exchange API. This example demonstrates how to retrieve real-time aircraft data within a specified geographical area.
API Endpoint Structure
The ADS-B Exchange API primarily uses RESTful principles. A common endpoint for real-time data looks like this:
GET https://adsbexchange.com/api/aircraft/v2/lat/{latitude}/lon/{longitude}/dist/{distance}/
Where:
{latitude}: The central latitude of the search area (e.g., 34.05).{longitude}: The central longitude of the search area (e.g., -118.25).{distance}: The radius in nautical miles from the center point (e.g., 20).
Authentication
Your API key must be included in the request headers for authentication. The ADS-B Exchange API expects the key in an api-auth header.
Example Request (Python)
This Python example uses the requests library to query aircraft within a 20 nautical mile radius of Los Angeles (latitude 34.05, longitude -118.25).
import requests
import os
# Replace with your actual API key, ideally from environment variables
API_KEY = os.getenv("ADSB_EXCHANGE_API_KEY", "YOUR_ADSB_EXCHANGE_API_KEY")
if API_KEY == "YOUR_ADSB_EXCHANGE_API_KEY":
print("Warning: Please set your ADSB_EXCHANGE_API_KEY environment variable or replace the placeholder.")
BASE_URL = "https://adsbexchange.com/api/aircraft/v2"
# Define search parameters
latitude = 34.05
longitude = -118.25
distance = 20 # Nautical miles
# Construct the URL
url = f"{BASE_URL}/lat/{latitude}/lon/{longitude}/dist/{distance}/"
# Set the headers with your API key
headers = {
"api-auth": API_KEY,
"Accept": "application/json"
}
print(f"Making request to: {url}")
try:
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx)
data = response.json()
# Process the response
if data and 'ac' in data:
print(f"Successfully retrieved {len(data['ac'])} aircraft records.")
for aircraft in data['ac'][:5]: # Print details for the first 5 aircraft
print(f" Flight: {aircraft.get('flight', 'N/A')}, "
f"Squawk: {aircraft.get('squawk', 'N/A')}, "
f"Lat: {aircraft.get('lat', 'N/A')}, "
f"Lon: {aircraft.get('lon', 'N/A')}, "
f"Alt: {aircraft.get('alt_baro', 'N/A')}ft")
else:
print("No aircraft data found in the response or unexpected format.")
print(data) # Print full response for debugging
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err} - {response.text}")
except requests.exceptions.ConnectionError as conn_err:
print(f"Connection error occurred: {conn_err}")
except requests.exceptions.Timeout as timeout_err:
print(f"Request timed out: {timeout_err}")
except requests.exceptions.RequestException as req_err:
print(f"An error occurred: {req_err}")
except ValueError:
print("Failed to parse JSON response.")
Example Request (JavaScript using Fetch API)
This JavaScript example demonstrates a similar request using the browser's Fetch API or Node.js with a suitable polyfill. Remember to secure your API key when deploying client-side applications.
const API_KEY = "YOUR_ADSB_EXCHANGE_API_KEY"; // In production, manage this securely, e.g., via a backend proxy
const latitude = 34.05;
const longitude = -118.25;
const distance = 20; // Nautical miles
const url = `https://adsbexchange.com/api/aircraft/v2/lat/${latitude}/lon/${longitude}/dist/${distance}/`;
fetch(url, {
method: 'GET',
headers: {
'api-auth': API_KEY,
'Accept': 'application/json'
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data && data.ac) {
console.log(`Successfully retrieved ${data.ac.length} aircraft records.`);
data.ac.slice(0, 5).forEach(aircraft => {
console.log(
` Flight: ${aircraft.flight || 'N/A'}, ` +
`Squawk: ${aircraft.squawk || 'N/A'}, ` +
`Lat: ${aircraft.lat || 'N/A'}, ` +
`Lon: ${aircraft.lon || 'N/A'}, ` +
`Alt: ${aircraft.alt_baro || 'N/A'}ft`
);
});
} else {
console.log("No aircraft data found in the response or unexpected format.");
console.log(data); // Log full response for debugging
}
})
.catch(error => {
console.error('Error during API call:', error);
});
Common next steps
After successfully making your first request, several common next steps can enhance your integration with the ADS-B Exchange API:
- Explore Other Endpoints: The API offers various endpoints beyond real-time aircraft data. Investigate options for historical data, specific flight details, or airport-centric queries (ADS-B Exchange API reference). Understanding the full range of available data allows for more comprehensive applications.
- Implement Error Handling: Robust applications require thorough error handling. Implement checks for HTTP status codes (e.g., 401 for unauthorized, 404 for not found, 500 for server errors) and network issues. The examples above include basic error handling, but consider more specific responses based on API error messages.
- Optimize Data Retrieval: For applications requiring frequent updates, consider the rate limits associated with your API plan. Implement caching strategies where appropriate to reduce redundant requests and manage your quota efficiently. The API documentation specifies acceptable refresh intervals for different data types.
- Parameterization and Filtering: Learn to use additional query parameters to filter results more precisely. This might include filtering by specific aircraft type, flight number, or altitude range. This reduces the amount of data transferred and processed, enhancing application performance.
- Integrate with a Frontend/Backend: Depending on your project, integrate the retrieved data into a user interface (using JavaScript frameworks like React or Vue) or process it further in a backend service (using Python, Node.js, Java, etc.) for storage, analysis, or presentation.
- Monitor Usage: Regularly check your API usage against your subscription limits in your ADS-B Exchange account dashboard to avoid service interruptions.
Troubleshooting the first call
Encountering issues during your first API call is common. Here's a guide to common problems and their solutions:
1. 401 Unauthorized Error
- Problem: The API returns a
401 Unauthorizedstatus code. This indicates that your request was not authenticated correctly. - Solution:
- API Key Validity: Double-check that your API key is correct and has not expired or been revoked. Copy it directly from your ADS-B Exchange account dashboard.
- Header Name: Ensure the header name is exactly
api-auth(case-sensitive). - Subscription Status: Verify that your API subscription is active and has not exceeded its usage limits or expired.
- Typos: Check for any typographical errors in the API key itself or in the header.
2. 403 Forbidden Error
- Problem: The API returns a
403 Forbiddenstatus code. This often means your account lacks the necessary permissions for the requested resource. - Solution:
- Plan Tier: Confirm that your current subscription plan supports access to the specific endpoint or data volume you are requesting. Some advanced data or higher query rates may require a higher-tier subscription.
- IP Whitelisting: If you have configured IP whitelisting for your API key, ensure that the IP address from which you are making the request is on the approved list.
3. Network or Connection Errors
- Problem: Errors such as
ConnectionError,Timeout, or no response. - Solution:
- Internet Connectivity: Verify your internet connection is stable.
- Firewall/Proxy: Check if a firewall or proxy server is blocking outbound connections from your development environment to
adsbexchange.com. - DNS Resolution: Ensure that
adsbexchange.comresolves correctly to an IP address. - API Server Status: Check the official ADS-B Exchange channels (e.g., website, social media) for any announcements regarding API downtime or maintenance.
4. Invalid JSON Response or Empty Data
- Problem: The API returns a non-JSON response, or the JSON is empty or malformed.
- Solution:
- Endpoint URL: Verify that the URL is correctly formed, including latitude, longitude, and distance parameters. Ensure no trailing slashes or incorrect characters.
- Parameter Values: Check that the latitude, longitude, and distance values are within valid ranges.
- API Documentation: Consult the ADS-B Exchange API documentation for the expected response format for the specific endpoint you are querying.
- No Data in Area: It's possible there are no aircraft in the specified geographical area and radius at that moment. Try a different location or a larger radius.
5. Rate Limit Exceeded
- Problem: Receiving errors related to exceeding rate limits (e.g.,
429 Too Many Requests). - Solution:
- Check Plan Limits: Review the rate limits defined by your API subscription tier (ADS-B Exchange data plans).
- Implement Delays: Introduce delays between your API calls, especially if you are making multiple requests in quick succession.
- Caching: Cache API responses whenever possible to avoid repetitive requests for static or slowly changing data.
- Upgrade Plan: If your application genuinely requires higher request volumes, consider upgrading your API subscription.