AstronomyAPI
v2
Search…
⌃K
🚀

Getting Started

Welcome to Astronomy API, a web API for retrieving astronomical information.

Obtaining an Application ID and a Secret

To make API calls, you will first need to create an account. Go to the Signup page to create your free account.
After creating an account, you must obtain an Application ID and an Application Secret key by clicking the "Create Application" button from your dashboard. You will be directed to the view application page for the application you just created.
The Application Secret is visible to you only once during application creation. Save it somewhere because there's no way to retrieve it back. If you lost your secret create a new application and delete the old application.
You will use the Application ID and the Application Secret to authenticate the Astronomy API with Basic Authentication.
You can view your Application ID later, by clicking the name of the specific application on the dashboard.
Be sure to set the Origin to the domain of the website when creating an application. If you're planning to use the API on a webpage. The API will respond with a Access Allow Origin header with the domain you provide.

Basic Authentication

When making API calls to endpoints which require authentication, you must use the credentials obtained above to create a hash. The algorithm to create the hash is very simple. Below are implementations on several commonly used languages.

JS

const hash = btoa(`${applicationId}:${applicationSecret}`);

PHP

$hash = base64_encode("$applicationId:$applicationSecret");
The generated hash must be provided in the API request's Authorization header, after the term Basic followed by a space.
"Authorization: Basic <hash>"
In an event of an authentication failure, a 403 Forbidden response will be returned to you. Successful requests always respond an HTTP code 200.

Sample curl request

curl --location --request GET 'https://api.astronomyapi.com/api/v2/bodies'
\ --header 'Authorization: Basic <hash>'
Last modified 4mo ago