# n8n

> Call any tool from the built-in HTTP Request node and split the results into items.

No custom node needed. The built-in HTTP Request node calls any tool, and Split Out turns the results into items.

<Callout title="Before you start">
  You need an API key (it starts with `af_live_`). [Sign up](/login) with your email and you get
  2,000 free credits.
</Callout>

## 1. Import the request [#1-import-the-request]

Add an HTTP Request node, click Import cURL, paste this command and click Import. n8n fills in the method, URL, header and body.

n8n imports every body value as text, so a number like `maxResults` would arrive as "3". Step 3 fixes that by switching the body to JSON.

```bash title="cURL"
curl -X POST https://pullwire.dev/api/v1/tools/youtube-transcripts/runs \
  -H "x-api-key: YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{"videos":["https://www.youtube.com/watch?v=jNQXAC9IVRw"],"maxResults":3}'
```

## 2. Keep your key in a credential [#2-keep-your-key-in-a-credential]

Under Authentication pick Generic Credential Type → Header Auth and create a credential with Name `x-api-key` and your key as Value. Then remove the `x-api-key` row from Send Headers, so the key is not stored in the workflow.

## 3. Map your own input [#3-map-your-own-input]

With Send Body on, set Body Content Type to JSON and Specify Body to Using JSON, then paste the body below. Drag fields from earlier nodes into it, for example a video URL from a sheet.

```json title="JSON body"
{
  "videos": [
    "{{ $json.videoUrl }}"
  ],
  "maxResults": 3
}
```

## 4. One item per result [#4-one-item-per-result]

The answer has a `run` (status, credits used) and a `results` list. Add a Split Out node with Fields To Split Out set to `results` to get one item per result.

```json title="Answer (SAMPLE)"
{
  "run": {
    "id": "…",
    "status": "succeeded",
    "resultsCount": 1,
    "creditsUsed": 1,
    "error": null
  },
  "results": [
    {
      "…": "one object per result, fields depend on the tool"
    }
  ]
}
```

The values above are a SAMPLE: real answers carry real IDs and all fields of the tool.

## 5. Bigger jobs [#5-bigger-jobs]

Add `?async=1` to the URL. Then a Wait node, then a second HTTP Request node (GET) to `/api/v1/runs/{{ $json.run.id }}/results` with the same credential.

## Good to know [#good-to-know]

- The call waits up to 25 seconds for the results. For bigger jobs add `?async=1` to the URL: you get a run id back right away and fetch the results a bit later.
- Errors come back with a code, e.g. `INSUFFICIENT_CREDITS` (402) or `INVALID_INPUT` (400).
