# Use RoxyAPI with n8n

> Automate a daily horoscope bot, a Life Path calculator, or a Vedic kundli workflow on [n8n](https://n8n.io/) in under 20 minutes. Self-hosted or cloud, both work.

n8n is a visual workflow builder for automating anything that talks to an API. It is the open source alternative to Zapier and Make, with a proper HTTP Request node, a growing AI Agent system, and self-hosted and cloud options. If you wanted Zapier but hit the "no custom code" wall, n8n is probably what you wanted.

## What you can build on n8n

- Daily horoscope email from a Schedule trigger to Gmail or Slack
- Webhook-powered Life Path calculator any no-code form can POST to
- Tarot card of the day delivered to a Slack or Discord channel
- AI astrology chatbot where the LLM picks between horoscope and natal chart tools on its own
- Vedic kundli on Form Trigger submit, rendered to a Google Docs PDF and emailed
- Dream journal with PostgreSQL storage and auto-interpretation reply
- Weekly horoscope roundup loop across all 12 signs

## What you need, 30 seconds

1. A Roxy API key. Get one on the [pricing page](/pricing).
2. An n8n instance. Cloud, Docker self-host, Railway, Render, or npm install all work identically.
3. Three to five minutes.

**Tip: If you have a curl command and want a working node in seconds, skip to the Import cURL path below. It is the fastest way from zero to a live Roxy call on n8n.**

## Step 1, connect your first endpoint

n8n offers two paths. Import cURL for quick tests. A reusable Header Auth credential for anything you run on a schedule.


### Import cURL

1. Drop an **HTTP Request** node on the canvas.
2. Click **Import cURL** on the Parameters tab.
3. Paste:
   ```bash
   curl "https://roxyapi.com/api/v2/astrology/horoscope/aries/daily" \
     -H "X-API-Key: YOUR_KEY"
   ```
4. Click **Import**. n8n fills in method, URL, and headers.
5. Click **Execute Node**.

**Warning: Import cURL hardcodes the key in the node. Fine for quick tests. For production, switch to the credential path below.**

### Header Auth credential

The standard path for production workflows.

1. Drop an HTTP Request node, scroll to **Authentication**.
2. Pick **Generic Credential Type**, then **Header Auth**.
3. Click **Create New Credential**.
4. **Name** `X-API-Key`. **Value** paste your key from [your account](/account).
5. Rename the credential itself to `RoxyAPI key` for readability.
6. Save. The key is encrypted inside n8n and never appears in node UI, execution logs, or exported workflow JSON.
7. Every future HTTP Request node picks the credential from a dropdown.

### AI Agent tool

The power path. Any HTTP Request node wired to the Tools input of an AI Agent becomes a callable tool for the LLM.

1. Drop an **AI Agent** node. Connect a chat model (OpenAI, Anthropic, Groq, Ollama, whatever).
2. Connect an **HTTP Request** node to the **Tools** input on the AI Agent.
3. In that node, set the URL with a `$fromAI` expression:
   ```
   https://roxyapi.com/api/v2/astrology/horoscope/{{ $fromAI("sign") }}/daily
   ```
4. Use the `RoxyAPI key` credential.
5. Give the tool a clear **Name** and **Description** so the agent knows when to call it.
6. Add one tool per domain you want the agent to handle.


## Step 2, ship a useful feature

Here is the full flow for a daily horoscope email. Schedule fires at 8 AM. HTTP fetches the horoscope. Gmail sends the email.

1. **Schedule Trigger** at 08:00 daily.
2. **HTTP Request** node with URL `https://roxyapi.com/api/v2/astrology/horoscope/aries/daily`, Header Auth credential.
3. **Gmail Send** with subject `Your daily horoscope` and body `{{ $json.overview }}` plus `{{ $json.luckyNumber }}`.

For a POST endpoint that takes birth data:


### HTTP Request node JSON body

1. **Method** `POST`.
2. **URL** `https://roxyapi.com/api/v2/astrology/natal-chart`.
3. Turn on **Send Body**, **Body Content Type** `JSON`, **Specify Body** `Using JSON`.
4. Paste:
   ```json
   {
     "date": "{{ $json.birth_date }}",
     "time": "{{ $json.birth_time }}",
     "latitude": {{ $json.birth_lat }},
     "longitude": {{ $json.birth_lng }},
     "timezone": "{{ $json.timezone }}"
   }
   ```

`date` is `YYYY-MM-DD`. `time` is `HH:MM:SS`. `timezone` accepts an IANA identifier (`"America/New_York"`) or a decimal number (`5.5`). IANA is preferred because the server resolves it to the DST-correct offset for the request date.

### curl preview

```bash
curl -X POST "https://roxyapi.com/api/v2/astrology/natal-chart" \
  -H "X-API-Key: $ROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "1990-05-12",
    "time": "14:30:00",
    "latitude": 40.7128,
    "longitude": -74.0060,
    "timezone": "America/New_York"
  }'
```

### TypeScript SDK

If you later move logic to a Code node or a custom n8n Node:

```typescript
import { createRoxy } from '@roxyapi/sdk';
const roxy = createRoxy(process.env.ROXY_API_KEY!);
const { data } = await roxy.astrology.generateNatalChart({
  body: {
    date: '1990-05-12',
    time: '14:30:00',
    latitude: 40.7128,
    longitude: -74.0060,
    timezone: 'America/New_York',
  },
});
```


Every field of the response (`sign`, `overview`, `luckyNumber`, `energyRating`) is mappable in any downstream node via the n8n expression editor. The `planets` field is an array of `{ name, sign, degree, house, ... }` objects: use the **Item Lists** node to split it out, or an expression like `{{$json.planets.filter(p => p.name === 'Sun')[0].sign}}` to pick the Sun sign inline.

## Step 3, scale to the full surface

Adding the next endpoint is the same pattern: drop another HTTP Request node, change the URL and body, the credential is reused automatically. Three places to pick the next one:

- **[API reference](/api-reference)** has a pre-filled test key. Try a call in the browser, copy the curl, paste into the **Import cURL** button in n8n for a configured node in seconds.
- **Domain guides** for which endpoints to call in what order:
  - [Western Astrology](/docs/guides/astrology), [Vedic Astrology](/docs/guides/vedic-astrology), [Tarot](/docs/guides/tarot), [Numerology](/docs/guides/numerology), [I Ching](/docs/guides/iching), [Dreams](/docs/guides/dreams)
- **Most-used endpoints** that fit n8n workflows: [`GET /astrology/horoscope/{sign}/daily`](/api-reference#tag/western-astrology/GET/astrology/horoscope/{sign}/daily), [`POST /astrology/natal-chart`](/api-reference#tag/western-astrology/POST/astrology/natal-chart), [`POST /vedic-astrology/birth-chart`](/api-reference#tag/vedic-astrology/POST/vedic-astrology/birth-chart), [`POST /vedic-astrology/panchang/detailed`](/api-reference#tag/vedic-astrology/POST/vedic-astrology/panchang/detailed), [`POST /tarot/spreads/three-card`](/api-reference#tag/tarot/POST/tarot/spreads/three-card), [`POST /numerology/life-path`](/api-reference#tag/numerology/POST/numerology/life-path), [`POST /biorhythm/daily`](/api-reference#tag/biorhythm/POST/biorhythm/daily).

## Caching in n8n

n8n does not cache HTTP responses. For daily content use an n8n Data Table (built-in, currently beta) or a PostgreSQL table with a date key. Check the store first, call Roxy on miss, write the response back.

## Gotchas

- **Backend-only key.** n8n runs on your server or cloud tenant. The key never reaches a browser. Still, use the Header Auth credential path for anything beyond a test, so the value is not in exports or logs.
- **Timezone.** Prefer IANA strings (`"America/New_York"`). Decimal offsets like `-5` are accepted but do not handle daylight saving. The server resolves IANA to the DST-correct offset for the request date.
- **Rate limits.** Every Roxy plan has daily and monthly caps. Add a **Wait** node before tight loops, use batching on the HTTP Request node, or cache daily content in a Data Table.
- **No native RoxyAPI node.** Use Generic Credential Type, Header Auth, with `X-API-Key` as the name. If you want a first-class node, reply to your onboarding email.
- **ECONNREFUSED self-hosted.** Your n8n container cannot reach `roxyapi.com`. Check outbound HTTPS, firewall rules for port 443, and DNS.
- **Wrong method.** 405 responses include an `allow` array listing valid methods. Switch the method and retry.

## What to build next

- The [astrology guide](/docs/guides/astrology) and [Vedic astrology guide](/docs/guides/vedic-astrology) cover endpoint ordering for chatbot and kundli workflows.
- The [Make integration](/docs/integrations/make) and [Zapier integration](/docs/integrations/zapier) cover similar patterns on adjacent platforms.
- The [AI chatbot tutorial](/docs/tutorials/ai-chatbot) is the reference for wiring multiple domains into an AI Agent.
- Browse the [API reference](/api-reference) for every endpoint across 12 domains.
