Output Types
API allows you to specify output types for your attributes in all endpoints.
Attributes Format
Attributes should be defined as a list (array) of objects, where each object has a name and description field:
"attributes": [
{
"name": "title",
"description": "News title"
},
{
"name": "points",
"description": "Number of points"
}
]Note: The older map format (
{"title": "News title"}) is deprecated and will be removed in a future version. Please use the list format shown above.
Adding Data Types
You can specify data types for each attribute by adding a type field:
"attributes": [
{
"name": "title",
"description": "Title of the article",
"type": "string"
},
{
"name": "points",
"description": "Number of points",
"type": "integer"
}
]Available Data Types
You can use one of the following data types:
| Type value | Output | Example |
|---|---|---|
any | Model can return any type (default) | - |
string | Text value | Hello World |
integer | Integer number | 1 |
number | Floating point number | 1.23 |
bool | Boolean value (true or false) | true |
list | List of values | ["hello", "world"] |
Example with Extractor
Full request example for extract:
curl https://api.parsera.org/v1/extract \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <YOUR_API_KEY>' \
--data '{
"url": "https://news.ycombinator.com/",
"attributes": [
{
"name": "title",
"description": "Title of the article",
"type": "string"
},
{
"name": "points",
"description": "Number of points",
"type": "integer"
}
]
}'Example with Scrapers
You can also use output types with scrapers. Add output types in your scraper generation request:
curl https://api.parsera.org/v1/scrapers/generate \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <YOUR_API_KEY>' \
--data '{
"template_id": "ycombinator",
"url": "https://news.ycombinator.com/",
"attributes": [
{
"name": "title",
"description": "Title of the article",
"type": "string"
},
{
"name": "points",
"description": "Number of points",
"type": "integer"
}
]
}'