Planets API

The Planets API provides key statistics for thousands of planets and exoplanets discovered in the known universe.

/v1/planets GET

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.


Parameters

At least one of the following parameters (other than offset) must be set:

  • name  optional

    The name of the planet.

  • min_mass  optional

    Minimum mass of the planet in Jupiters (1 Jupiter = 1.898 × 1027 kg).

  • max_mass  optional

    Maximum mass of the planet in Jupiters (1 Jupiter = 1.898 × 1027 kg).

  • min_radius  optional

    Minimum average radius of the planet in Jupiters (1 Jupiter = 69911 km).

  • max_radius  optional

    Maximum average radius of the planet in Jupiters (1 Jupiter = 69911 km).

  • min_period  optional

    Minimum orbital period of the planet in Earth days.

  • max_period  optional

    Maximum orbital period of the planet in Earth days.

  • min_temperature  optional

    Minimum average surface temperature of the planet in Kelvin.

  • max_temperature  optional

    Maximum average surface temperature of the planet in Kelvin.

  • min_distance_light_year  optional

    Minimum distance the planet is from Earth in light years.

  • max_distance_light_year  optional

    Maximum distance the planet is from Earth in light years.

  • min_semi_major_axis  optional

    Minimum semi major axis of planet in astronomical units (AU).

  • max_semi_major_axis  optional

    Maximum semi major axis of planet in astronomical units (AU).

  • offset  optional

    Number of results to offset for pagination.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

name
https://api.api-ninjas.com/v1/planets?name=Neptune

Sample Response

JSON
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 } ]

Code Examples

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.