Guides
Generate your first PDF report
The PDF API turns birth details into a finished horoscope document. You send the birth data plus your branding in one request. The server generates the PDF and returns the URL to download it. There is no separate poll and no webhook. One request, one response, and the pdf_url comes back in that same response. See the full list of guides for other ways to build with the API.
Prerequisites
- Node.js 18 or later. It ships with a global
fetch, so you need no packages. - An AstrologyAPI user ID and API key from your dashboard.
- Optionally, your company logo hosted at a public URL if you want it on the PDF.
The request
Send a POST to https://pdf.astrologyapi.com/v1/basic_horoscope_pdf with HTTP Basic auth. Your user ID is the username and your API key is the password. The body is JSON. Every field below is required, including the branding fields. Omitting a required field fails the request.
Birth details
| Field | Type | Description |
|---|---|---|
name | string | Name of the user. |
gender | string | Gender of the user. |
day | number | Birth day (1-31). |
month | number | Birth month (1-12). |
year | number | Birth year. |
hour | number | Birth hour (0-23). |
min | number | Birth minute (0-59). |
lat | number | Latitude of birth location. |
lon | number | Longitude of birth location. |
tzone | number | Timezone offset from UTC in hours. |
place | string | Birth place. |
chart_style | string | Chart style. Allowed values: NORTH_INDIAN, SOUTH_INDIAN, EAST_INDIAN. |
language | string | PDF language. See supported languages below. |
Branding fields
| Field | Type | Description |
|---|---|---|
footer_link | string | Footer/domain link. |
logo_url | string | Company logo URL. |
company_name | string | Company name. |
company_info | string | Company information. Should be less than 500 characters. |
domain_url | string | Full company domain URL. |
company_email | string | Company email. |
company_landline | string | Company landline number. |
company_mobile | string | Company mobile number. |
Send the request
This runs on Node 18 or later with the global fetch, no packages. It builds the Basic auth header, posts the full body, throws on a non-ok response, and logs the pdf_url on success. Set USER_ID and API_KEY from your dashboard.
// Node 18+ (global fetch). No external packages.
// USER_ID and API_KEY come from your AstrologyAPI dashboard.
const USER_ID = 'USER_ID'
const API_KEY = 'API_KEY'
const ENDPOINT = 'https://pdf.astrologyapi.com/v1/basic_horoscope_pdf'
const AUTH =
'Basic ' + Buffer.from(USER_ID + ':' + API_KEY).toString('base64')
async function generatePdf(body) {
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: {
Authorization: AUTH,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
})
if (!res.ok) {
throw new Error('Request failed: ' + res.status + ' ' + res.statusText)
}
return res.json()
}
generatePdf({
// Birth details. Every field is required.
name: 'Ajeet',
gender: 'male',
day: 15,
month: 8,
year: 1990,
hour: 10,
min: 30,
lat: 39.9526,
lon: -75.1652,
tzone: -5,
place: 'Mumbai,Maharashtra India',
chart_style: 'NORTH_INDIAN',
language: 'en',
// Branding fields. These are required too.
footer_link: 'https://www.yourcompany.com',
logo_url: 'https://www.yourcompany.com/logo.png',
company_name: 'Your Company Pvt. Ltd.',
company_info: 'Your company description, under 500 characters.',
domain_url: 'https://www.yourcompany.com',
company_email: '[email protected]',
company_landline: '+91 22 1234 5678',
company_mobile: '+91 98765 43210',
})
.then((result) => console.log(result.pdf_url))
.catch((err) => {
console.error(err.message)
process.exit(1)
})The response is the finished PDF's location. That is the entire shape.
{
"status": true,
"pdf_url": "https://s3.amazonaws.com/astrologyapi-pdfs/sample_horoscope.pdf"
}Branding options
The branding fields listed above control what appears on the generated PDF: your logo, company name, contact details, and footer link. This lets you white-label the report so it reads as your own product, not a third-party document.
Supported languages
Set language to one of these codes.
Other report types
This guide covers the basic horoscope PDF. The API has nine other report types: gemstone, mini horoscope, pro horoscope, pro numerology, match making, life forecast, synastry, solar return, and natal horoscope. They are documented at the PDF reference. If you want a PDF without writing code, the dashboard has a PDF generator that produces the same reports from a form.
Want to deliver this PDF through a chat bot instead of a web app? The Telegram bot guide follows the same server-side request pattern. Before you send real users' PDFs in production, work through the production checklist.