Comment on page
Welcome to Astronomy API, a web API for retrieving astronomical information.
After creating an account, you must obtain an
Application IDand an
Application Secretkey by clicking the
"Create Application"button from your dashboard. You will be directed to the "View Application" page for the application you just created.
Application Secretis 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 IDand the
Application Secretto authenticate with the Astronomy API with Basic Authentication.
Be sure to set the
Originto 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 Originheader with the domain you provide.
This is needed if you're calling the API from a web page client since web browsers need CORS setup for remote requests to work.
When making API calls to endpoints requiring authentication, you must use the above credentials to create a string that must be used as the authentication string. The algorithm to create the string is very simple. Below are implementations of several commonly used languages.
const authString = btoa(`applicationId:applicationSecret`);
$authString = base64_encode("applicationId:applicationSecret");
userpass = "applicationId:applicationSecret"
authString = base64.b64encode(userpass.encode()).decode()
The encrypted string must be provided in the API request's
Authorizationheader, after the term
Basicfollowed by a space.
"Authorization: Basic YourAuthStringHere"
In an event of an authentication failure, a
403 Forbiddenresponse will be returned, which probably means you encrypted the string incorrectly, or your credentials are wrong.
Successful requests always respond with HTTP code
curl --location --request GET 'https://api.astronomyapi.com/api/v2/bodies'
\ --header 'Authorization: Basic YourAuthStringHere'