> For the complete documentation index, see [llms.txt](https://docs.scraperapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scraperapi.com/ai-parser/endpoints/create-a-parser.md).

# Create a Parser

Create a new parser based on example URLs

```bash
POST https://aiparser.scraperapi.com/parsers
```

**Request body**

```json
{
  "name": "Quotes Scraper",
  "api_key": "API_KEY",
  "urls": [
    "http://quotes.toscrape.com/page/1/",
    "http://quotes.toscrape.com/page/2/",
    "http://quotes.toscrape.com/page/3/"
  ],
  //optional
  "scraper_params": {
    "country_code": "us"
  },
  //optional
  "fields": [
    {
      "name": "quotes.text",
      "description": "The full quote text",
      "type": "string"
    },
    {
      "name": "quotes.author",
      "description": "Product price in USD",
      "type": "number"
    }
  ]
}
```

***

<table><thead><tr><th width="205.888916015625">Field</th><th width="115.66650390625" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td align="center">Yes</td><td>Name identifier for the generated parser.</td></tr><tr><td><code>api_key</code></td><td align="center">Yes</td><td>Your ScraperAPI API Key.</td></tr><tr><td><code>urls</code></td><td align="center">Yes</td><td>1-3 example URLs of the same type.</td></tr><tr><td><code>scraper_params</code></td><td align="center">No</td><td>ScraperAPI parameters to be used when fetching the example pages - see <a href="#supported-scraperapi-parameters">supported parameters</a>.</td></tr><tr><td><code>fields</code></td><td align="center">No</td><td>Predefined fields to guide generation. Each supports <strong>name</strong>, <strong>description</strong>, <strong>type</strong> (<code>string</code>, <code>number</code>, <code>array</code>), and an optional CSS or XPath <strong>selector</strong>. Use dot notation for nested fields (e.g. "<code>products.name</code>")</td></tr></tbody></table>

**Response**

```json
{
    "id": "parser_id",
    "version": 0
}
```

The parser starts generating **asynchronously**. Poll `GET /parsers/{id}` to check status.

{% hint style="success" %}
**Tips for Example URLs**

* **Use the same URL types** - three product pages, not a product page + a category page.
* **Pick Variations** - items with and without sales prices, in-stock and out-of-stock, etc. to teach the parser edge cases.
* **Make sure they are accessible** - if the URLs require JavaScript rendering, set `render=true` in `scraper_params`.
  {% endhint %}

### Supported ScraperAPI parameters

These can be set in `scraper_params` when creating the parser, and used as query params when calling `/parse`

<table><thead><tr><th width="265.7037353515625">Parameter</th><th width="112.7037353515625">Type</th><th width="325.1324462890625">Description</th></tr></thead><tbody><tr><td><code>render</code></td><td>Boolean</td><td>Enables JavaScript rendering</td></tr><tr><td><code>country_code</code></td><td>String</td><td>Two-letter country code (e.g. US)</td></tr><tr><td><code>premium</code></td><td>Boolean</td><td>Use residential proxies</td></tr><tr><td><code>session_number</code></td><td>Integer</td><td>Maintain the same IP across requests</td></tr><tr><td><code>keep_headers</code></td><td>Boolean</td><td>Preserve custom headers you send</td></tr><tr><td><code>device_type</code></td><td>String</td><td><code>desktop</code> or <code>mobile</code></td></tr><tr><td><code>ultra_premium</code></td><td>Boolean</td><td>Use advanced unblocking mechanisms</td></tr><tr><td><code>follow_redirect</code></td><td>Boolean</td><td>Follow HTTP redirects (default <code>true</code>)</td></tr><tr><td><code>retry_404</code></td><td>Boolean</td><td>Retry 404 responses</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.scraperapi.com/ai-parser/endpoints/create-a-parser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
