The Stars API provides key statistics for thousands of stars discovered in the known universe.
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.
At least one of the following parameters (other than offset
) is required.
name
optionalThe name of the star. Note that many of the star names contain Greek characters.
constellation
optionalThe constellation that the star belongs to.
min_apparent_magnitude
optionalMinimum apparent magnitude brightness of the star.
max_apparent_magnitude
optionalMaximum apparent magnitude brightness of the star.
min_absolute_magnitude
optionalMinimum absolute magnitude brightness of the star.
max_absolute_magnitude
optionalMaximum absolute magnitude brightness of the star.
min_distance_light_year
optionalMinimum distance the star is from Earth in light years.
max_distance_light_year
optionalMaximum distance the star is from Earth in light years.
offset
optionalNumber of results to offset for pagination.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/stars?name=vega
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"
}
]
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.