NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

Stars API

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

(4.1)

From 9,702 users

2,600+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
343ms390ms436ms837ms1062ms

Similar APIs

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.

  • 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.

Response

A JSON array of star objects, each containing the following fields, or an error if the request is unsuccessful.

  • name

    The name of the star.

  • constellation

    The constellation that the star belongs to.

  • right_ascension

    The right ascension coordinate of the star.

  • declination

    The declination coordinate of the star.

  • apparent_magnitude

    The apparent magnitude (brightness as seen from Earth) of the star.

  • absolute_magnitude

    The absolute magnitude (intrinsic brightness) of the star.

  • distance_light_year

    The distance from Earth in light years.

  • spectral_class

    The spectral classification of the star.

Sample Request Live Demo!

name
constellation
min_apparent_magnitude
max_apparent_magnitude
min_absolute_magnitude

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=vega

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      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 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

  • 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.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • 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.
  • 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.
  • Pass the name parameter to find a star by name (note that many star names contain Greek characters), or use the constellation parameter to return stars belonging to a given constellation; at least one parameter (other than offset) is required on each request. For related celestial data, check out the Planets API.
  • Each star object includes its name, constellation, celestial coordinates (right_ascension and declination), brightness as apparent_magnitude and absolute_magnitude, distance_light_year from Earth, and its spectral_class. If a request is unsuccessful, an error is returned instead, which you can decode using our error codes reference.
  • Yes, you can narrow results using min_apparent_magnitude/max_apparent_magnitude, min_absolute_magnitude/max_absolute_magnitude, and min_distance_light_year/max_distance_light_year to target specific brightness or distance ranges. Browse the full set of available tools in our API catalog.
  • Each request to the /v1/stars endpoint returns at most 30 star objects, so to retrieve additional matches use the offset parameter across multiple API calls for pagination. For higher usage volumes, check our pricing plans.