|
| 1 | +# roxy-sdk (Python) Agent Guide |
| 2 | + |
| 3 | +Python SDK for RoxyAPI. Multi-domain spiritual and metaphysical intelligence API. One API key, 10 domains, sync and async support. |
| 4 | + |
| 5 | +## Install and initialize |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install roxy-sdk |
| 9 | +``` |
| 10 | + |
| 11 | +```python |
| 12 | +from roxy_sdk import create_roxy |
| 13 | + |
| 14 | +roxy = create_roxy("your-api-key") |
| 15 | +``` |
| 16 | + |
| 17 | +`create_roxy` sets the base URL (`https://roxyapi.com/api/v2`) and auth header automatically. Returns a `Roxy` instance with namespaced domain properties. |
| 18 | + |
| 19 | +## Domains |
| 20 | + |
| 21 | +Type `roxy.` to see all available namespaces: |
| 22 | + |
| 23 | +| Namespace | What it covers | |
| 24 | +|-----------|----------------| |
| 25 | +| `roxy.astrology` | Western astrology: natal charts, horoscopes, synastry, moon phases, transits, compatibility | |
| 26 | +| `roxy.vedic_astrology` | Vedic/Jyotish: birth charts, dashas, nakshatras, panchang, KP system, doshas, yogas | |
| 27 | +| `roxy.tarot` | Rider-Waite-Smith deck: spreads, daily pulls, yes/no, Celtic Cross, custom layouts | |
| 28 | +| `roxy.numerology` | Life path, expression, soul urge, personal year, karmic analysis, compatibility | |
| 29 | +| `roxy.crystals` | Crystal healing properties, zodiac/chakra pairings, birthstones, search | |
| 30 | +| `roxy.iching` | I Ching: hexagrams, trigrams, coin casting, daily readings | |
| 31 | +| `roxy.angel_numbers` | Angel number meanings, pattern analysis, daily guidance | |
| 32 | +| `roxy.dreams` | Dream symbol dictionary and interpretations | |
| 33 | +| `roxy.location` | City geocoding for birth chart coordinates | |
| 34 | +| `roxy.usage` | API usage stats and subscription info | |
| 35 | + |
| 36 | +## Critical patterns |
| 37 | + |
| 38 | +### Sync calls (default) |
| 39 | + |
| 40 | +```python |
| 41 | +horoscope = roxy.astrology.get_daily_horoscope(sign="aries") |
| 42 | +card = roxy.tarot.draw_cards(count=3) |
| 43 | +life_path = roxy.numerology.calculate_life_path(year=1990, month=1, day=15) |
| 44 | +``` |
| 45 | + |
| 46 | +### Async calls (append _async) |
| 47 | + |
| 48 | +Every sync method has an async variant with `_async` suffix: |
| 49 | + |
| 50 | +```python |
| 51 | +horoscope = await roxy.astrology.get_daily_horoscope_async(sign="aries") |
| 52 | +card = await roxy.tarot.draw_cards_async(count=3) |
| 53 | +``` |
| 54 | + |
| 55 | +### POST endpoints (charts, spreads, calculations) |
| 56 | + |
| 57 | +Most chart and calculation endpoints require date, time, and coordinates: |
| 58 | + |
| 59 | +```python |
| 60 | +chart = roxy.astrology.generate_natal_chart( |
| 61 | + date="1990-01-15", |
| 62 | + time="14:30:00", |
| 63 | + latitude=28.6139, |
| 64 | + longitude=77.209, |
| 65 | +) |
| 66 | + |
| 67 | +vedic = roxy.vedic_astrology.generate_birth_chart( |
| 68 | + date="1990-01-15", |
| 69 | + time="14:30:00", |
| 70 | + latitude=28.6139, |
| 71 | + longitude=77.209, |
| 72 | +) |
| 73 | + |
| 74 | +celtic = roxy.tarot.cast_celtic_cross(question="What should I focus on?") |
| 75 | + |
| 76 | +numerology = roxy.numerology.generate_numerology_chart( |
| 77 | + full_name="John Doe", |
| 78 | + year=1990, |
| 79 | + month=1, |
| 80 | + day=15, |
| 81 | +) |
| 82 | +``` |
| 83 | + |
| 84 | +### Error handling |
| 85 | + |
| 86 | +Errors raise `RoxyAPIError` with `error` (message), `code` (machine-readable), and `status_code` attributes: |
| 87 | + |
| 88 | +```python |
| 89 | +from roxy_sdk import create_roxy, RoxyAPIError |
| 90 | + |
| 91 | +try: |
| 92 | + result = roxy.astrology.get_daily_horoscope(sign="invalid") |
| 93 | +except RoxyAPIError as e: |
| 94 | + print(e.code) # "validation_error" |
| 95 | + print(e.error) # "Invalid sign" |
| 96 | + print(e.status_code) # 400 |
| 97 | +``` |
| 98 | + |
| 99 | +Error codes: `validation_error`, `api_key_required`, `invalid_api_key`, `subscription_not_found`, `subscription_inactive`, `not_found`, `rate_limit_exceeded`, `internal_error`. |
| 100 | + |
| 101 | +## Common tasks |
| 102 | + |
| 103 | +| Task | Code | |
| 104 | +|------|------| |
| 105 | +| Daily horoscope | `roxy.astrology.get_daily_horoscope(sign="aries")` | |
| 106 | +| Birth chart (Western) | `roxy.astrology.generate_natal_chart(date, time, latitude, longitude)` | |
| 107 | +| Birth chart (Vedic) | `roxy.vedic_astrology.generate_birth_chart(date, time, latitude, longitude)` | |
| 108 | +| Compatibility score | `roxy.astrology.calculate_compatibility(person1, person2)` | |
| 109 | +| Tarot daily card | `roxy.tarot.get_daily_card()` | |
| 110 | +| Celtic Cross reading | `roxy.tarot.cast_celtic_cross(question="...")` | |
| 111 | +| Draw tarot cards | `roxy.tarot.draw_cards(count=3)` | |
| 112 | +| Life Path number | `roxy.numerology.calculate_life_path(year, month, day)` | |
| 113 | +| Full numerology chart | `roxy.numerology.generate_numerology_chart(full_name=, year=, month=, day=)` | |
| 114 | +| Crystal by zodiac | `roxy.crystals.get_crystals_by_zodiac(sign="aries")` | |
| 115 | +| Crystal search | `roxy.crystals.search_crystals(q="amethyst")` | |
| 116 | +| I Ching reading | `roxy.iching.cast_reading()` | |
| 117 | +| Angel number meaning | `roxy.angel_numbers.get_angel_number(number="1111")` | |
| 118 | +| Dream symbol lookup | `roxy.dreams.get_dream_symbol(id="flying")` | |
| 119 | +| Find city coordinates | `roxy.location.search_cities(q="Mumbai")` | |
| 120 | +| Check API usage | `roxy.usage.get_usage_stats()` | |
| 121 | + |
| 122 | +## Location helper |
| 123 | + |
| 124 | +Most chart endpoints need `latitude` and `longitude`. Use the location API to geocode: |
| 125 | + |
| 126 | +```python |
| 127 | +result = roxy.location.search_cities(q="Mumbai, India") |
| 128 | +city = result["cities"][0] |
| 129 | +# Use city["latitude"] and city["longitude"] in chart requests |
| 130 | +``` |
| 131 | + |
| 132 | +## Gotchas |
| 133 | + |
| 134 | +- **All parameters are keyword arguments.** Use `sign="aries"` not positional `"aries"`. |
| 135 | +- **Async methods end with `_async`.** Every sync method has a matching async variant. |
| 136 | +- **Do not expose API keys client-side.** Call Roxy from server code only. |
| 137 | +- **Chart endpoints need coordinates.** Use `roxy.location.search_cities()` to get lat/lng. |
| 138 | +- **Date format is `YYYY-MM-DD`, time is `HH:MM:SS`.** Both are strings. |
| 139 | +- **Errors raise `RoxyAPIError`.** Catch it and check `e.code`, `e.error`, and `e.status_code`. |
| 140 | +- **Switch on `code`, not `error`.** The `code` field is stable. The `error` message may change. |
| 141 | + |
| 142 | +## Links |
| 143 | + |
| 144 | +- Interactive API docs: https://roxyapi.com/api-reference |
| 145 | +- Pricing and API keys: https://roxyapi.com/pricing |
| 146 | +- MCP for AI agents: https://roxyapi.com/docs/mcp |
| 147 | +- TypeScript SDK: https://www.npmjs.com/package/@roxyapi/sdk |
0 commit comments