Agents API (Deprecated)
⚠️ DEPRECATED: This API is deprecated and will be removed in a future version. Please migrate to the new Scrapers API which uses the
/v1/scrapers/*endpoints onapi.parsera.org.The new Scrapers API offers the same functionality with improved performance and a unified base URL.
Legacy Agents API
The legacy Agents API (agents.parsera.org) generates reusable custom scrapers which has 2 main steps:
- Call
generateto build scraper; - Call
scrapeto run this scraper on a specific URL.
generate
Request agent to build a new scraper:
curl https://agents.parsera.org/v1/generate \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <YOUR_API_KEY>' \
--data '{
"name": "hackernews",
"url": "https://news.ycombinator.com/",
"attributes": {
"title": "News title",
"points": "Number of points"
}
}'Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | - | Name of the agent |
url | string | - | Website URL |
prompt | string | "" | Prompt for initial scraping |
attributes | object | - | A map of name - description pairs of data fields to extract from the webpage. Also, you can specify Output Types. |
proxy_country | string | UnitedStates | Proxy country, see Proxy Countries |
cookies | array | Empty | Cookies to use during extraction, see Cookies |
scrape
Apply an existing scraper to the webpage:
curl https://agents.parsera.org/v1/scrape \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <YOUR_API_KEY>' \
--data '{
"name": "hackernews",
"url": "https://news.ycombinator.com/front?day=2024-09-11",
}'You can access pre-built agents by appending public/ to the name, for example public/crunchbase to access crunchbase agent.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | - | Name of the agent |
url | string | - | URL of the webpage to extract data from |
proxy_country | string | UnitedStates | Proxy country, see Proxy Countries |
cookies | array | Empty | Cookies to use during extraction, see Cookies |
list
List all available agents:
curl --location 'https://agents.parsera.org/v1/list' \
--header 'X-API-KEY: <YOUR_API_KEY>'remove
Remove existing agent:
curl --location 'https://agents.parsera.org/v1/remove' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <YOUR_API_KEY>' \
--data '{
"name": "hackernews"
}'Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | - | Name of the agent |
Migrating to Scrapers API
To migrate from the Agents API to the new Scrapers API:
- Use
api.parsera.orginstead ofagents.parsera.org - Replace
/v1/generatewith/v1/scrapers/generateand usetemplate_idinstead ofname - Replace
/v1/scrapewith/v1/scrapers/runand usetemplate_idinstead ofname - Replace
/v1/listwithGET /v1/scrapers - Update attributes format from map to list (see Output Types)
For complete documentation on the new API, see Scrapers API.