|
| 1 | +# @roxyapi/sdk — Agent Guide |
| 2 | + |
| 3 | +TypeScript SDK for RoxyAPI. 8 spiritual/metaphysical domains, 113 endpoints, one API key. Zero runtime dependencies. |
| 4 | + |
| 5 | +> Before writing any code with this SDK, read `docs/llms-full.txt` in this package for the complete method reference with examples. |
| 6 | +
|
| 7 | +## Install and initialize |
| 8 | + |
| 9 | +```typescript |
| 10 | +import { createRoxy } from '@roxyapi/sdk'; |
| 11 | + |
| 12 | +const roxy = createRoxy(process.env.ROXY_API_KEY!); |
| 13 | +``` |
| 14 | + |
| 15 | +`createRoxy` sets the base URL (`https://roxyapi.com/api/v2`) and auth header automatically. Every method returns `{ data, error, response }`. |
| 16 | + |
| 17 | +## Domains |
| 18 | + |
| 19 | +Type `roxy.` to see all 10 namespaces: |
| 20 | + |
| 21 | +| Namespace | Methods | What it covers | |
| 22 | +|-----------|---------|----------------| |
| 23 | +| `roxy.astrology` | 23 | Western astrology: natal charts, horoscopes, synastry, moon phases, transits | |
| 24 | +| `roxy.vedicAstrology` | 42 | Vedic/Jyotish: birth charts, dashas, nakshatras, panchang, KP system | |
| 25 | +| `roxy.tarot` | 10 | 78-card Rider-Waite-Smith: spreads, daily pulls, yes/no, Celtic Cross | |
| 26 | +| `roxy.numerology` | 13 | Life path, expression, soul urge, personal year, karmic analysis | |
| 27 | +| `roxy.crystals` | 12 | Crystal healing properties, zodiac/chakra pairings, birthstones | |
| 28 | +| `roxy.iching` | 9 | I Ching: 64 hexagrams, trigrams, coin casting, daily readings | |
| 29 | +| `roxy.angelNumbers` | 4 | Angel number meanings, pattern analysis, daily guidance | |
| 30 | +| `roxy.dreams` | 5 | Dream symbol dictionary (2,000+ symbols) | |
| 31 | +| `roxy.location` | 3 | City geocoding for birth chart coordinates | |
| 32 | +| `roxy.usage` | 1 | API usage stats and subscription info | |
| 33 | + |
| 34 | +## Critical patterns |
| 35 | + |
| 36 | +### GET endpoints — use `path` for URL parameters |
| 37 | + |
| 38 | +```typescript |
| 39 | +// Path params go in { path: { ... } } |
| 40 | +const { data } = await roxy.astrology.getDailyHoroscope({ |
| 41 | + path: { sign: 'aries' }, |
| 42 | +}); |
| 43 | + |
| 44 | +const { data } = await roxy.crystals.getCrystal({ |
| 45 | + path: { slug: 'amethyst' }, |
| 46 | +}); |
| 47 | +``` |
| 48 | + |
| 49 | +### POST endpoints — use `body` for request data |
| 50 | + |
| 51 | +Most valuable endpoints (charts, spreads, calculations) are POST: |
| 52 | + |
| 53 | +```typescript |
| 54 | +// Birth chart — requires date, time, coordinates |
| 55 | +const { data } = await roxy.astrology.generateNatalChart({ |
| 56 | + body: { |
| 57 | + date: '1990-01-15', |
| 58 | + time: '14:30:00', |
| 59 | + latitude: 28.6139, |
| 60 | + longitude: 77.209, |
| 61 | + }, |
| 62 | +}); |
| 63 | + |
| 64 | +// Tarot spread |
| 65 | +const { data } = await roxy.tarot.castCelticCross({ |
| 66 | + body: { question: 'What should I focus on?' }, |
| 67 | +}); |
| 68 | + |
| 69 | +// Numerology |
| 70 | +const { data } = await roxy.numerology.calculateLifePath({ |
| 71 | + body: { year: 1990, month: 1, day: 15 }, |
| 72 | +}); |
| 73 | +``` |
| 74 | + |
| 75 | +### Error handling |
| 76 | + |
| 77 | +```typescript |
| 78 | +const { data, error, response } = await roxy.astrology.getDailyHoroscope({ |
| 79 | + path: { sign: 'aries' }, |
| 80 | +}); |
| 81 | + |
| 82 | +if (error) { |
| 83 | + // error is { error: string } on 4xx/5xx |
| 84 | + console.error(error); |
| 85 | + return; |
| 86 | +} |
| 87 | +// data is fully typed here |
| 88 | +console.log(data.sign, data.overview); |
| 89 | +``` |
| 90 | + |
| 91 | +### Query parameters |
| 92 | + |
| 93 | +```typescript |
| 94 | +const { data } = await roxy.crystals.searchCrystals({ |
| 95 | + query: { q: 'amethyst' }, |
| 96 | +}); |
| 97 | + |
| 98 | +const { data } = await roxy.dreams.searchDreamSymbols({ |
| 99 | + query: { q: 'flying' }, |
| 100 | +}); |
| 101 | +``` |
| 102 | + |
| 103 | +## Common tasks |
| 104 | + |
| 105 | +| Task | Code | |
| 106 | +|------|------| |
| 107 | +| Daily horoscope | `roxy.astrology.getDailyHoroscope({ path: { sign } })` | |
| 108 | +| Birth chart (Western) | `roxy.astrology.generateNatalChart({ body: { date, time, latitude, longitude } })` | |
| 109 | +| Birth chart (Vedic) | `roxy.vedicAstrology.generateBirthChart({ body: { date, time, latitude, longitude } })` | |
| 110 | +| Compatibility score | `roxy.astrology.calculateCompatibility({ body: { person1, person2 } })` | |
| 111 | +| Tarot daily card | `roxy.tarot.getDailyCard({ body: { date } })` | |
| 112 | +| Celtic Cross reading | `roxy.tarot.castCelticCross({ body: { question } })` | |
| 113 | +| Life Path number | `roxy.numerology.calculateLifePath({ body: { year, month, day } })` | |
| 114 | +| Full numerology chart | `roxy.numerology.generateNumerologyChart({ body: { date, name } })` | |
| 115 | +| Crystal by zodiac | `roxy.crystals.getCrystalsByZodiac({ path: { sign } })` | |
| 116 | +| I Ching reading | `roxy.iching.castReading()` | |
| 117 | +| Angel number meaning | `roxy.angelNumbers.getAngelNumber({ path: { number: '1111' } })` | |
| 118 | +| Dream symbol lookup | `roxy.dreams.getDreamSymbol({ path: { id: 'flying' } })` | |
| 119 | +| Find city coordinates | `roxy.location.searchCities({ query: { q: 'Mumbai' } })` | |
| 120 | +| Check API usage | `roxy.usage.getUsageStats()` | |
| 121 | + |
| 122 | +## Location helper |
| 123 | + |
| 124 | +Most chart endpoints need `latitude` and `longitude`. Use the location API to geocode: |
| 125 | + |
| 126 | +```typescript |
| 127 | +const { data: cities } = await roxy.location.searchCities({ |
| 128 | + query: { q: 'Mumbai, India' }, |
| 129 | +}); |
| 130 | +const city = cities[0]; |
| 131 | +// Use city.latitude and city.longitude in chart requests |
| 132 | +``` |
| 133 | + |
| 134 | +## What NOT to do |
| 135 | + |
| 136 | +- Do not call endpoints with raw `fetch` — use the typed SDK methods |
| 137 | +- Do not hardcode the base URL — `createRoxy` sets it |
| 138 | +- Do not expose the API key client-side — call from server/API routes only |
| 139 | +- Do not guess method names — type `roxy.domain.` and use autocomplete |
| 140 | +- Parameters are `{ path }`, `{ body }`, or `{ query }` — not positional arguments |
| 141 | + |
| 142 | +## Links |
| 143 | + |
| 144 | +- Full method reference: `docs/llms-full.txt` (bundled in this package) |
| 145 | +- Interactive API docs: https://roxyapi.com/api-reference |
| 146 | +- Pricing and API keys: https://roxyapi.com/pricing |
| 147 | +- MCP setup for AI agents: https://roxyapi.com/docs/mcp |
0 commit comments