Stars API
The Stars API provides key statistics for thousands of stars discovered in the known universe.
From 9,702 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 343ms | 390ms | 436ms | 837ms | 1062ms |
Didn't find what you were looking for? Suggest an improvement
/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.
nameoptionalThe name of the star. Note that many of the star names contain Greek characters.
constellationoptionalThe constellation that the star belongs to.
min_apparent_magnitudeoptionalMinimum apparent magnitude brightness of the star.
max_apparent_magnitudeoptionalMaximum apparent magnitude brightness of the star.
min_absolute_magnitudeoptionalMinimum absolute magnitude brightness of the star.
max_absolute_magnitudeoptionalMaximum absolute magnitude brightness of the star.
min_distance_light_yearoptionalMinimum distance the star is from Earth in light years.
max_distance_light_yearoptionalMaximum distance the star is from Earth in light years.
offsetoptionalNumber of results to offset for pagination.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON array of star objects, each containing the following fields, or an error if the request is unsuccessful.
nameThe name of the star.
constellationThe constellation that the star belongs to.
right_ascensionThe right ascension coordinate of the star.
declinationThe declination coordinate of the star.
apparent_magnitudeThe apparent magnitude (brightness as seen from Earth) of the star.
absolute_magnitudeThe absolute magnitude (intrinsic brightness) of the star.
distance_light_yearThe distance from Earth in light years.
spectral_classThe spectral classification of the star.
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/stars?name=vegaHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/stars?name=vega" \
-H "X-Api-Key: YOUR_API_KEY"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.
Frequently Asked Questions
Can I use the Stars API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Stars API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Stars API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Stars API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.How do I look up a specific star or all stars in a constellation?
Pass thenameparameter to find a star by name (note that many star names contain Greek characters), or use theconstellationparameter to return stars belonging to a given constellation; at least one parameter (other thanoffset) is required on each request. For related celestial data, check out the Planets API.What fields does the Stars API return for each star?
Each star object includes itsname,constellation, celestial coordinates (right_ascensionanddeclination), brightness asapparent_magnitudeandabsolute_magnitude,distance_light_yearfrom Earth, and itsspectral_class. If a request is unsuccessful, an error is returned instead, which you can decode using our error codes reference.Can I filter stars by brightness or distance from Earth?
Yes, you can narrow results usingmin_apparent_magnitude/max_apparent_magnitude,min_absolute_magnitude/max_absolute_magnitude, andmin_distance_light_year/max_distance_light_yearto target specific brightness or distance ranges. Browse the full set of available tools in our API catalog.How many results does the Stars API return, and how do I get more?
Each request to the/v1/starsendpoint returns at most 30 star objects, so to retrieve additional matches use theoffsetparameter across multiple API calls for pagination. For higher usage volumes, check our pricing plans.