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

# TypeSpec

> Type specification for return data on extraction-based methods

`TypeSpec` is used as an argument type for extraction-based methods on pages. It allows specifying the type of data to return after extraction.

**TypeSpec supports**:

* Pydantic models (for data validation and serialization)
* JSON Schema (for defining data structure and validation)
* Primitive types (`int`, `float`, `bool`, `str`)

**Usage example**

```python theme={null}
from pydantic import BaseModel
from typing import Optional
from datetime import datetime

class Article(BaseModel):
    title: str
    content: str
    author: str
    published_at: Optional[datetime] = None
    views: Optional[int] = 0

article = browser.extract("The article information", type_spec=Article)
print(article.title)
```
