The Planets API provides key statistics for thousands of planets and exoplanets discovered in the known universe.
https://api.api-ninjas.com/v1/planets
Get a list of planets matching specified parameters. Returns at most 30 results. To access more than 30 results, use the offset
parameter to offset results in multiple API calls.
At least one of the following parameters (other than offset
) must be set:
name
optionalThe name of the planet.
min_mass
optionalMinimum mass of the planet in Jupiters (1 Jupiter = 1.898 × 1027 kg).
max_mass
optionalMaximum mass of the planet in Jupiters (1 Jupiter = 1.898 × 1027 kg).
min_radius
optionalMinimum average radius of the planet in Jupiters (1 Jupiter = 69911 km).
max_radius
optionalMaximum average radius of the planet in Jupiters (1 Jupiter = 69911 km).
min_period
optionalMinimum orbital period of the planet in Earth days.
max_period
optionalMaximum orbital period of the planet in Earth days.
min_temperature
optionalMinimum average surface temperature of the planet in Kelvin.
max_temperature
optionalMaximum average surface temperature of the planet in Kelvin.
min_distance_light_year
optionalMinimum distance the planet is from Earth in light years.
max_distance_light_year
optionalMaximum distance the planet is from Earth in light years.
min_semi_major_axis
optionalMinimum semi major axis of planet in astronomical units (AU).
max_semi_major_axis
optionalMaximum semi major axis of planet in astronomical units (AU).
offset
optionalNumber of results to offset for pagination.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/planets?name=Neptune
Headers
X-Api-Key
Log in or sign up to get your API Key
1
2
3
4
5
6
7
8
9
10
11
12
13
[
{
"name": "Neptune",
"mass": 0.0537,
"radius": 0.346,
"period": 59800,
"semi_major_axis": 30.07,
"temperature": 72,
"distance_light_year": 0.000478,
"host_star_mass": 1,
"host_star_temperature": 6000
}
]
1
2
3
4
5
6
7
8
import requests
name = 'Neptune'
api_url = 'https://api.api-ninjas.com/v1/planets?name={}'.format(name)
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.