- Docs
- Build With Roxy
- SDK (TypeScript / Python)
SDK (TypeScript / Python)
Official Roxy SDKs for TypeScript and Python. Full type safety, IDE autocomplete, zero manual JSON parsing across all 10 domains and 130+ endpoints. Install the language you ship in, both SDKs stay in sync with the live OpenAPI spec.
- TypeScript:
@roxyapi/sdkon npm - Python:
roxy-sdkon PyPI
Install
npm install @roxyapi/sdk
bun add @roxyapi/sdk
pnpm add @roxyapi/sdk
yarn add @roxyapi/sdk
pip install roxy-sdk
uv add roxy-sdk
poetry add roxy-sdk
Quick start
Two lines to instantiate, one line per API call. createRoxy / create_roxy set the base URL, auth header, and SDK identification header automatically.
import { createRoxy } from '@roxyapi/sdk';
const roxy = createRoxy(process.env.ROXY_API_KEY!);
// Daily horoscope
const { data } = await roxy.astrology.getDailyHoroscope({
path: { sign: 'aries' },
});
// Numerology life path
const { data: lp } = await roxy.numerology.calculateLifePath({
body: { year: 1990, month: 1, day: 15 },
});
// Tarot Celtic Cross spread
const { data: reading } = await roxy.tarot.castCelticCross({
body: { question: 'What should I focus on this month?' },
});
from roxy_sdk import create_roxy
roxy = create_roxy("your-api-key")
# Daily horoscope
horoscope = roxy.astrology.get_daily_horoscope(sign="aries")
# Numerology life path
lp = roxy.numerology.calculate_life_path(year=1990, month=1, day=15)
# Tarot Celtic Cross spread
reading = roxy.tarot.cast_celtic_cross(question="What should I focus on this month?")
Never expose your API key in client-side code. Call Roxy from your server, API routes, serverless functions, or background workers only.
Authentication
Pass your API key on initialization. Get your API key at roxyapi.com/pricing, delivered instantly after checkout.
import { createRoxy } from '@roxyapi/sdk';
const roxy = createRoxy(process.env.ROXY_API_KEY!);
import os
from roxy_sdk import create_roxy
roxy = create_roxy(os.environ["ROXY_API_KEY"])
Domains
Each domain is a namespace on the roxy instance. TypeScript returns { data, error, response } per call. Python returns the decoded JSON directly and raises RoxyAPIError on failure.
| Namespace (TS / Python) | What it covers |
|---|---|
roxy.astrology | Western astrology: natal charts, horoscopes, synastry, transits, moon phases |
roxy.vedicAstrology / roxy.vedic_astrology | Vedic / Jyotish: kundli, panchang, dashas, nakshatras, doshas, KP system |
roxy.numerology | Life path, expression, soul urge, personal year, karmic lessons |
roxy.tarot | Daily card, custom draws, three-card, Celtic Cross, yes / no, love spread |
roxy.biorhythm | Daily check-in, multi-day forecast, critical days, compatibility |
roxy.iching | Daily hexagram, three-coin cast, 64 hexagrams, trigrams |
roxy.crystals | Crystal meanings, zodiac / chakra pairings, birthstone, search |
roxy.dreams | Dream symbol dictionary, interpretations |
roxy.angelNumbers / roxy.angel_numbers | Number meanings, universal digit-root lookup, daily |
roxy.location | City search for birth chart coordinates |
roxy.usage | API usage stats, remaining quota, subscription info |
Location first
Every chart, horoscope, panchang, dasha, dosha, navamsa, KP, synastry, compatibility, and natal endpoint needs latitude, longitude, and a timezone number. Call the location API first, then feed the result into the chart method.
The location response is a pagination envelope. Each city has both an IANA timezone string and a decimal utcOffset. Pass the utcOffset as the chart timezone.
const { data } = await roxy.location.searchCities({
query: { q: 'Mumbai, India' },
});
// Response: { total, limit, offset, cities: [...] }
const { latitude, longitude, timezone } = data.cities[0];
const { data: chart } = await roxy.vedicAstrology.generateBirthChart({
body: {
date: '1990-01-15',
time: '14:30:00',
latitude,
longitude,
timezone, // IANA string like "Asia/Kolkata" — server resolves DST for the chart date
},
});
result = roxy.location.search_cities(q="Mumbai, India")
# Response: { "total", "limit", "offset", "cities": [...] }
city = result["cities"][0]
chart = roxy.vedic_astrology.generate_birth_chart(
date="1990-01-15", time="14:30:00",
latitude=city["latitude"], longitude=city["longitude"],
timezone=city["timezone"], # IANA string; server resolves DST for the chart date
)
Chart endpoints accept timezone as either a decimal number (5.5 for IST, -5 for EST, 9 for Tokyo) or an IANA identifier ("Asia/Kolkata", "America/New_York"). IANA strings are resolved server-side to the DST-correct offset for the request date, so a January 1990 New York birth gets EST (-5) even when you geocoded the city in July. The utcOffset field on the Location response is a convenience decimal if you prefer numbers. Both forms produce identical charts.
Examples
Daily horoscope
const { data, error } = await roxy.astrology.getDailyHoroscope({
path: { sign: 'scorpio' },
});
if (error) {
console.error(error);
} else {
console.log(data.overview); // General daily forecast
console.log(data.love); // Love and relationship forecast
console.log(data.career); // Career outlook
}
horoscope = roxy.astrology.get_daily_horoscope(sign="scorpio")
print(horoscope["overview"]) # General daily forecast
print(horoscope["love"]) # Love and relationship forecast
print(horoscope["career"]) # Career outlook
Numerology life path
const { data } = await roxy.numerology.calculateLifePath({
body: { year: 1990, month: 1, day: 15 },
});
console.log(data.number); // e.g. 7
console.log(data.type); // "single" | "master"
result = roxy.numerology.calculate_life_path(year=1990, month=1, day=15)
print(result["number"]) # e.g. 7
print(result["type"]) # "single" | "master"
Vedic birth chart
The response groups planets by the rashi (sign) they occupy. Each rashi has a signs[] array (planets in that rashi, often empty) plus a top-level meta dict with every planet keyed by name.
const { data } = await roxy.vedicAstrology.generateBirthChart({
body: {
date: '1990-01-15',
time: '14:30:00',
latitude: 28.6139,
longitude: 77.209,
timezone: 5.5,
},
});
// Iterate rashis (aries..pisces) for the 12-sign chart
for (const rashi of ['aries', 'taurus', 'gemini'] as const) {
console.log(rashi, data[rashi].signs); // planets in this rashi
}
// Or look up any planet directly
console.log(data.meta.Sun.rashi); // "Capricorn"
console.log(data.meta.Moon.nakshatra); // nakshatra metadata
chart = roxy.vedic_astrology.generate_birth_chart(
date="1990-01-15", time="14:30:00",
latitude=28.6139, longitude=77.209, timezone=5.5,
)
# Iterate rashis for the 12-sign chart
for rashi in ["aries", "taurus", "gemini"]:
print(rashi, chart[rashi]["signs"])
# Or look up any planet directly
print(chart["meta"]["Sun"]["rashi"]) # "Capricorn"
print(chart["meta"]["Moon"]["nakshatra"]) # nakshatra metadata
Western natal chart
const { data } = await roxy.astrology.generateNatalChart({
body: {
date: '1990-01-15',
time: '14:30:00',
latitude: 28.6139,
longitude: 77.209,
timezone: 5.5,
},
});
console.log(data.planets.length); // 13 (incl. lunar nodes and Chiron)
console.log(data.houses.length); // 12
console.log(data.ascendant);
console.log(data.midheaven);
natal = roxy.astrology.generate_natal_chart(
date="1990-01-15", time="14:30:00",
latitude=28.6139, longitude=77.209, timezone=5.5,
)
print(len(natal["planets"])) # 13
print(len(natal["houses"])) # 12
print(natal["ascendant"])
print(natal["midheaven"])
Tarot daily card
const { data } = await roxy.tarot.getDailyCard({ body: { seed: 'user-123' } });
console.log(data.card.name); // e.g. "The Star"
console.log(data.dailyMessage); // concise daily guidance
console.log(data.card.meaning); // full card interpretation
card = roxy.tarot.get_daily_card(seed="user-123")
print(card["card"]["name"]) # e.g. "The Star"
print(card["dailyMessage"]) # concise daily guidance
print(card["card"]["meaning"]) # full card interpretation
Angel number lookup
const { data } = await roxy.angelNumbers.getAngelNumber({
path: { number: '1111' },
});
console.log(data.coreMessage); // Short divine message summary
console.log(data.meaning.spiritual); // Spiritual interpretation
console.log(data.meaning.love); // Love / relationship meaning
result = roxy.angel_numbers.get_angel_number(number="1111")
print(result["coreMessage"]) # Short divine message summary
print(result["meaning"]["spiritual"]) # Spiritual interpretation
print(result["meaning"]["love"]) # Love / relationship meaning
Check usage
const { data } = await roxy.usage.getUsageStats();
console.log(`${data.usedThisMonth} / ${data.requestsPerMonth} requests used`);
stats = roxy.usage.get_usage_stats()
print(f"{stats['usedThisMonth']} / {stats['requestsPerMonth']} requests used")
Multi-language responses
Interpretations are available in eight languages: English (en), Turkish (tr), German (de), Spanish (es), French (fr), Hindi (hi), Portuguese (pt), Russian (ru).
const { data } = await roxy.tarot.getDailyCard({
body: { date: '2026-04-22' },
query: { lang: 'es' },
});
card = roxy.tarot.get_daily_card(date="2026-04-22", lang="es")
Supported: astrology, vedicAstrology / vedic_astrology, numerology, tarot, biorhythm, iching, crystals, angelNumbers / angel_numbers. English-only: dreams, location, usage.
Async support
TypeScript is async by default (every method returns a Promise). Python ships an _async variant for every sync method, for asyncio, FastAPI, or any event loop.
// Already async — every method returns a Promise
const { data } = await roxy.astrology.getDailyHoroscope({ path: { sign: 'aries' } });
import asyncio
from roxy_sdk import create_roxy
async def main():
roxy = create_roxy("your-api-key")
horoscope = await roxy.astrology.get_daily_horoscope_async(sign="aries")
card = await roxy.tarot.get_daily_card_async()
print(horoscope, card)
asyncio.run(main())
Error handling
TypeScript returns { data, error, response } per call. Python raises RoxyAPIError. Both expose a stable code field you can branch on.
const { data, error } = await roxy.tarot.castYesNo({
body: { question: 'Should I take this opportunity?' },
});
if (error) {
switch (error.code) {
case 'validation_error':
console.error('Bad input:', error.error);
break;
case 'rate_limit_exceeded':
console.error('Monthly quota reached');
break;
default:
console.error('API error:', error.code, error.error);
}
} else {
console.log(data.answer); // "Yes" | "No" | "Maybe"
}
from roxy_sdk import create_roxy, RoxyAPIError
try:
result = roxy.tarot.cast_yes_no(question="Should I take this opportunity?")
print(result["answer"]) # "Yes" | "No" | "Maybe"
except RoxyAPIError as e:
if e.code == "validation_error":
print(f"Bad input: {e.error}")
elif e.code == "rate_limit_exceeded":
print("Monthly quota reached")
else:
print(f"API error: {e.code} {e.error}")
Error codes
| Status | Code | When |
|---|---|---|
| 400 | validation_error | Missing or invalid parameters. Check issues[] for per-field failures. |
| 401 | api_key_required | No API key provided |
| 401 | invalid_api_key | Key format invalid or tampered |
| 401 | subscription_not_found | Key references non-existent subscription |
| 401 | subscription_inactive | Subscription cancelled, expired, or suspended |
| 404 | not_found | Resource does not exist |
| 429 | rate_limit_exceeded | Monthly request quota reached |
| 500 | internal_error | Server error |
The code field is machine-readable and stable, safe to switch on. The error field is human-readable and may change wording.
TypeScript types
Every TypeScript request and response is fully typed. Your IDE shows all available methods, required parameters, and exact response shapes without opening the docs.
// TypeScript knows sign must be one of the 12 zodiac signs
const { data } = await roxy.astrology.getDailyHoroscope({
path: { sign: 'aries' }, // autocompletes all 12 options
});
// data is typed, no manual casting needed
console.log(data.date); // string
console.log(data.overview); // string
You can also import individual namespace classes or response types:
import { Astrology, type GetAstrologyHoroscopeBySignDailyResponse } from '@roxyapi/sdk';
Gotchas
Parameters are structured
TypeScript always uses { path: {...} }, { body: {...} }, or { query: {...} }. Python uses keyword arguments only (sign="aries"), never positional. Do not mix the two patterns.
Timezone accepts both IANA and decimal
Chart endpoints accept timezone as either a decimal (5.5, -5, 0) or an IANA identifier ("Asia/Kolkata", "America/New_York"). IANA is preferred because it is DST-resolved against the request's date, so historical birth charts pick the correct offset even when you geocoded the city today. Both city.timezone and city.utcOffset from the Location response work.
Location returns an envelope, not a bare array
data.cities[0] in TypeScript and result["cities"][0] in Python. The top-level object carries total, limit, offset for pagination. Same envelope pattern applies to tarot.listCards (data.cards), iching.listHexagrams (data.hexagrams), dreams.searchDreamSymbols (data.symbols), and crystals.searchCrystals / getCrystalsByZodiac / getCrystalsByChakra (data.crystals).
Date format is YYYY-MM-DD, time is HH:MM:SS
Both are strings. Time must include seconds, 14:30 will be rejected.
Do not guess method names
Type roxy.domain. and let autocomplete show methods. Names come from operationId in the OpenAPI spec, not URL paths. Examples: getDailyHoroscope (not dailyHoroscope), calculateLifePath (not lifePath), castCelticCross (not celticCross).
Chart endpoints need coordinates
Use the location API to geocode cities before any birth chart, synastry, panchang, KP, or natal method. Never hardcode a user's latitude, longitude, or timezone from memory.
Do not expose API keys client-side
Call Roxy from server code, API routes, serverless functions, or background workers only. Any key shipped to the browser is a leaked key.
Do not use raw fetch or requests
The SDK handles auth headers, base URL, SDK identification, and typed responses. Raw HTTP clients re-invent this and miss the type safety.
Python errors raise RoxyAPIError
Catch it and switch on e.code, not e.error (the error message text may change between releases, the code is stable).
TypeScript data and error are mutually exclusive
If error is set, data is undefined. Always check error first.
AI coding agents
Both SDKs ship AGENTS.md bundled in the package so AI agents (Claude Code, Cursor, GitHub Copilot, OpenAI Codex, Gemini CLI) read it directly from node_modules/@roxyapi/sdk/AGENTS.md or the installed Python package.
- Quickstart, critical patterns, common tasks reference, gotchas
- Field format table covering timezone decimals, date / time strings, nested person objects, enum values
- MCP tool name mapping for every REST endpoint
Also available: a remote MCP server per domain at https://roxyapi.com/mcp/{domain} (Streamable HTTP, no stdio / no self-hosting) for agents that speak the Model Context Protocol.
Links
- API Reference — browse all endpoints and try live calls
- Quickstart — your first API call in 60 seconds
- MCP Setup — connect AI agents to Roxy
- Starter Apps — full app templates to clone
- Pricing — get your API key
- TypeScript SDK on GitHub
- Python SDK on GitHub