Rocket launch API data
There are few publicly available datasets with detailed rocket launch information. Two that I found are LL2 (free) and RocketLaunch.Live (USD 3/monthly). I thought it'll be an interesting exercise to export launch data from an API to see what insights and charts could be created.
I went with the RocketLaunch.Live API simply because I discovered it first while trying to find launch datasets. The API has 7 entities:
- Companies
- Launches
- Locations
- Missions
- Pads
- Tags
- Vehicles
Connecting to the API using a Python script is fairly straightforward:
def get_response(self,url):
for q in range(10):
try:
r = requests.get(url,timeout=10) # Sending GET request to the endpoint/url with a timeout of 10 seconds
js_response = r.json() # retrieve JSON from the response for further parsing
return js_response
except:
pass
Parsing the JSON response is a little more tricky, as the API only returns 25 elements per call. The response is also nested, with the first portion of the payload containing metadata that we don't need:
"valid_auth": true,
"count": 25,
"limit": 25,
"total": 4483,
"last_page": 180,
"result": [
{
"id": 3477,
"cospar_id": "",
"sort_date": "-287326017",
"name": "Tiros 2",
"provider": {
"id": 12,
"name": "U.S. Air Force",
"slug": "u-s-air-force"
},
"vehicle": {
"id": 137,
"name": "Thor-Delta",
"company_id": 147,
"slug": "thor-delta"
},
"pad": {
"id": 90,
"name": "SLC-17A",
"location": {
"id": 62,
"name": "Cape Canaveral SFS",
"state": "FL",
"statename": "Florida",
"country": "United States",
"slug": "cape-canaveral-sfs"
}
},
"missions": [
{
"id": 5310,
"name": "Tiros 2",
"description": null
}
],
"mission_description": null,
"launch_description": "A U.S. Air Force Thor-Delta rocket launched the Tiros 2 mission on Wednesday, November 23, 1960 at 11:13 AM (UTC).",
"win_open": null,
"t0": "1960-11-23T11:13Z",
"win_close": null,
"est_date": {
"month": null,
"day": null,
"year": null,
"quarter": null
},
"date_str": "Nov 23 1960",
"tags": [],
"slug": "tiros-2",
"weather_summary": null,
"weather_temp": null,
"weather_condition": null,
"weather_wind_mph": null,
"weather_icon": null,
"weather_updated": null,
"quicktext": "Thor-Delta - Tiros 2 - Nov 23 1960 (estimated) - https://rocketlaunch.live/launch/tiros-2 for info/stream",
"media": [],
"result": 1,
"suborbital": false,
"modified": "2023-04-02T22:29:36+00:00"
}
First we use a python library that can flatten a JSON:
from flatten_json import flatten
flat_json = flatten(js_response) # Using flatten function imported from flatten_json to flatten JSON
We can then use a custom function to take in a flattened JSON and generate a dict for each flattened row's variables (what will become our CSV columns). We then iterate through the dict and write to a CSV file:
def convert_to_rows(self,flat_json):
n = 0
dct = {}
for key in flat_json: # Reading the key from flattened JSON
if 'result_' in key:
key_name = key.split('_',2)[-1] # Pull the key name from the key and remove the object number from the key, result[120].spacecraft.name becomes spacecraft.name
if f'result_{n}' in key:
if n not in dct: # Putting the data into the dictionary result item wise
dct[n] = {key_name:flat_json[key]}
else:
dct[n][key_name] = flat_json[key]
else:
n+=1
dct[n] = {key_name:flat_json[key]}
for row in dct: # Going through each item in dct
sub_row = []
for col in self.columns: # Pulling info for each columns
if col in dct[row]:
sub_row.append(dct[row][col]) # Adding to row
else:
sub_row.append('NA') # If a column doesn't exist write NA
self.rows.append(sub_row) # Append the row to self.rows for further processing
def write_to_csv(self,csv_name):
This gives us our full dataset for all rocket launches since 1930:

To visualize the data, we load our CSV into Datawrapper and first create a table for EDA (you can try filtering to only SpaceX launches by searching for 'SpaceX' below):
To validate that our data is reliable, we can compare RocketLaunch's 2024 launch numbers with secondary sources. On average Space Stats reports a -5% discrepancy, while NASA's discrepancy on average is -7%. Overall, the numbers are directionally aligned with minor absolute differences, so I'm comfortable using this data to describe general launch trends.
2024 | RocketLaunch.Live | Space Stats | NASA |
---|---|---|---|
Global | 292 | 263 | 259 |
USA | 162 | 158 | 164 |
SpaceX | 143 | 132 | 133 |
Finally, we can visualize the API data to look at overall trends (chart is interactive):
Areas for improvement are to automate the data export to Google Sheets and use Datawrapper's Sheets import feature. This will keep the data fresh and updated daily on a recurring schedule.
Stack: VSCode, Python, Excel, Datawrapper
Code: GitHub