SEARCH ASTROLOGY API DOCS

Home
API Reference

Introduction

This reference is your key to a complete understanding of Astrology API.

If this is your first time at AstrologyAPI, we recommend beginning with Getting Started Guide.

Conventions

The base URL to send all API requests is https://api.astrologyapi.com/v1/. HTTPS is required for all API requests.

The Astrology API follows RESTful conventions when possible, with most operations performed via POST requests on resources. Request and response bodies are encoded as JSON.

Code samples & SDKs

Samples requests and responses are shown for each endpoint. Requests are shown using the AstrologyAPI JavaScript SDK, and cURL. These samples make it easy to copy, paste, and modify as you build your integration.

Astrology API SDKs are open-source projects that you can install to easily start building. You may also choose any other language or library that allows you to make HTTP requests.

Authentication

Requests use the HTTP Authorization header to both authenticate and authorize operations.

The Astrology API accepts Basic Auth in this header. Basic Auth uses username and password. This is provided to you when you sign up at AstrologyAPI. User Id is the username and API Key is the password.

This Authorization header is to be passed along with each request.

You can use AstrologyAPI SDK or our Postman collection to make it easy to send the authorization header.

Using Postman

Code Sample

<?php

// Set the URL to send the request to
$url = 'https://json.astrologyapi.com/v1/sun_sign_prediction/daily/aries';

// Set the credentials
$username = 'userid';
$password = 'api_key';

// Encode the credentials in base64
$auth = base64_encode($username . ':' . $password);

// Initialize a cURL session
$ch = curl_init();

// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Set the Authorization header
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Basic ' . $auth
]);

// Execute the request
$response = curl_exec($ch);

// Close the cURL session
curl_close($ch);

// Print the response
echo $response;

Error Codes

Responses from the API use HTTP response codes are used to indicate general classes of success and error. Error responses contain more detail about the error in the response body, in the code and message properties.

Indian Astrology API
Western Astrology API
Horoscope API
PDF Reports API
Tarot API