Stars API

The Stars API provides key statistics for thousands of stars discovered in the known universe.

/v1/stars GET

https://api.api-ninjas.com/v1/stars

Get a list of stars 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) is required.

  • name  optional

    The name of the star. Note that many of the star names contain Greek characters.

  • constellation  optional

    The constellation that the star belongs to.

  • min_apparent_magnitude  optional

    Minimum apparent magnitude brightness of the star.

  • max_apparent_magnitude  optional

    Maximum apparent magnitude brightness of the star.

  • min_absolute_magnitude  optional

    Minimum absolute magnitude brightness of the star.

  • max_absolute_magnitude  optional

    Maximum absolute magnitude brightness of the star.

  • min_distance_light_year  optional

    Minimum distance the star is from Earth in light years.

  • max_distance_light_year  optional

    Maximum distance the star is from Earth in light years.

  • 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/stars?name=vega

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 [ { "name": "Vega", "constellation": "Lyra", "right_ascension": "18h 36m 56.19s", "declination": "+38° 46′ 58.8″", "apparent_magnitude": "0.03", "absolute_magnitude": "0.58", "distance_light_year": "25", "spectral_class": "A0Vvar" } ]

Code Examples

1 2 3 4 5 6 7 8 import requests name = 'vega' api_url = 'https://api.api-ninjas.com/v1/stars?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.