> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Zenrows HTTP API serves Fetch and Extract (extract=auto) at https://api.zenrows.com/v1/, Crawl at https://api.zenrows.com/v1/crawls, and Batch at https://async.api.zenrows.com/v1. Fetch, Extract, Crawl and Batch are described in OpenAPI 3.1 at https://www.zenrows.com/openapi.json and listed in the RFC 9727 API catalog at https://www.zenrows.com/.well-known/api-catalog. Every endpoint also has its own page under /api-reference with its schema. Use the spec for exact parameter names and types. Crawl's endpoints, parameters and errors are also at https://docs.zenrows.com/crawl/endpoints.md. To call Zenrows from an agent, connect the MCP server at https://mcp.zenrows.com/mcp. To search these docs from an agent, connect the docs MCP server at https://docs.zenrows.com/mcp. Agent skills for Zenrows are published at https://github.com/ZenRows/cli and install with `npx skills add ZenRows/cli`.

# Making your first request with the Node.js SDK

> Make your first request with the Zenrows Node.js SDK in a few lines of code.

This guide makes a single GET request with the Zenrows Node.js SDK: create a client, send the request, read the response.

> [!NOTE]
>
> Haven't installed the SDK yet? Follow [Installation](https://docs.zenrows.com/fetch/sdk/nodejs/installation.md) first.

## Basic usage

**1. Create a client**

Import `ZenRows` and instantiate it with your API key:

```javascript theme={null} theme={"theme":"css-variables"}
const { ZenRows } = require("zenrows");

const client = new ZenRows("YOUR_ZENROWS_API_KEY");
```

**2. Send a GET request**

Call `client.get()` with the URL you want to scrape:

```javascript theme={null} theme={"theme":"css-variables"}
const { ZenRows } = require("zenrows");

const client = new ZenRows("YOUR_ZENROWS_API_KEY");
const url = "https://www.scrapingcourse.com/ecommerce/";

(async () => {
  const response = await client.get(url);
  const html = await response.text();

  console.log(html);
})();
```

`response` is a standard `fetch` `Response` object.

> [!TIP]
>
> See [The Response Object](https://docs.zenrows.com/fetch/sdk/nodejs/response-object.md) for everything available on it.

**3. Add request parameters**

Pass a config object as the second argument to enable Fetch features like JavaScript rendering or Premium Proxies:

```javascript theme={null} theme={"theme":"css-variables"}
const { ZenRows } = require("zenrows");

const client = new ZenRows("YOUR_ZENROWS_API_KEY");
const url = "https://www.scrapingcourse.com/ecommerce/";

(async () => {
  const response = await client.get(url, {
    js_render: true,
    premium_proxy: true,
    proxy_country: "us",
  });

  const html = await response.text();

  console.log(html);
})();
```

> [!TIP]
>
> The config object accepts every parameter documented in the [Fetch setup guide](https://docs.zenrows.com/fetch/setup.md), including `extract`, `css_extractor`, `wait_for`, `block_resources`, and `outputs`. They all work exactly the same way through the SDK.

**4. Check the result**

Since the SDK doesn't throw an exception on non-2xx responses, always check the status before using the content:

```javascript theme={null} theme={"theme":"css-variables"}
if (response.ok) {
  const html = await response.text();
  console.log(html);
} else {
  console.log(`Request failed with status ${response.status}: ${await response.text()}`);
}
```

See [Error Handling and Retries](https://docs.zenrows.com/fetch/sdk/nodejs/error-handling-and-retries.md) for how to configure automatic retries so you don't have to handle every transient failure manually.

## Troubleshooting

* **`response.status` is `401` or similar auth error**: Double-check your API key was copied correctly from the Zenrows Request Playground with no extra whitespace. See [`AUTH002`](https://docs.zenrows.com/api-error-codes#auth002-invalid-api-key).

  [Open the Playground](https://app.zenrows.com/fetch)

* **The response body is empty or looks like an error page, not the target site**: The target likely needs `js_render: true` and/or `premium_proxy: true`. See [`REQS002`](https://docs.zenrows.com/api-error-codes#reqs002-request-requirements-unsatisfied).

* **`await response.text()` hangs or the script never finishes**: Make sure the call is wrapped in an `async` function and awaited; the SDK doesn't have a `timeout` option, so a hung request will wait indefinitely unless your own code aborts it (e.g. with `AbortController`).

* **`429 Too Many Requests`**: You've hit your plan's concurrency or rate limit. See [Concurrency](https://docs.zenrows.com/fetch/sdk/nodejs/async-concurrency.md).

## Pricing

Cost depends on the config you send, not on the SDK itself:

| Configuration | Credits per request |
| - | - |
| Basic request (no `js_render`/`premium_proxy`) | 1 |
| `js_render: true` | 5 |
| `premium_proxy: true` | 10 |
| `js_render: true` + `premium_proxy: true` | 25 |

Only successful requests are billed. See [Zenrows Pricing](https://docs.zenrows.com/first-steps/pricing.md) for exact per-plan rates.

## FAQ (Frequently Asked Questions)

> [accordion] Do I need a config object for every request?
>
> No, the config argument is optional. `client.get(url)` alone works for public pages with no anti-bot protection.

> [accordion] Why doesn't a failed request throw an exception?
>
> By design, the SDK resolves with the `Response` object even for error status codes, matching how native `fetch` behaves. Check `response.ok` or `response.status` yourself. See [Error Handling and Retries](https://docs.zenrows.com/fetch/sdk/nodejs/error-handling-and-retries.md).

> [accordion] Can I reuse the same client for multiple requests?
>
> Yes. Create one `ZenRows` instance and call `.get()`/`.post()` on it as many times as needed, there's no need to recreate it per request.

## What's next

> [card] [POST Requests](https://docs.zenrows.com/fetch/sdk/nodejs/post-put-requests.md)
>
> Submit forms or data payloads.

> [card] [Concurrency](https://docs.zenrows.com/fetch/sdk/nodejs/async-concurrency.md)
>
> Scrape many URLs in parallel.

> [card] [Custom Headers](https://docs.zenrows.com/fetch/sdk/nodejs/custom-headers.md)
>
> Forward specific headers to the target site.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.