🌍 Astrocartography API and ✋ Palmistry API are now live. Ship them in your app today.Get Started

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

FieldTypeDescription
namestringName of the user.
genderstringGender of the user.
daynumberBirth day (1-31).
monthnumberBirth month (1-12).
yearnumberBirth year.
hournumberBirth hour (0-23).
minnumberBirth minute (0-59).
latnumberLatitude of birth location.
lonnumberLongitude of birth location.
tzonenumberTimezone offset from UTC in hours.
placestringBirth place.
chart_stylestringChart style. Allowed values: NORTH_INDIAN, SOUTH_INDIAN, EAST_INDIAN.
languagestringPDF language. See supported languages below.

Branding fields

FieldTypeDescription
footer_linkstringFooter/domain link.
logo_urlstringCompany logo URL.
company_namestringCompany name.
company_infostringCompany information. Should be less than 500 characters.
domain_urlstringFull company domain URL.
company_emailstringCompany email.
company_landlinestringCompany landline number.
company_mobilestringCompany 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: 'support@yourcompany.com',
  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.

English (en)Hindi (hi)Bengali (bn)Marathi (mr)Tamil (ta)Telugu (te)Kannada (kn)Malayalam (ml)
Never put your API key in client-side code. Generate PDFs from your server, not a browser, so the key stays on your side.

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.