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

# Olostep Python SDK

> Officiële Python SDK om gegevens van het web te zoeken, extraheren en structureren

<Note>
  **PyPI Pakket**: [olostep](https://pypi.org/project/olostep/) | **Vereisten**: Python 3.11+
</Note>

## Installatie

<CodeGroup>
  ```bash pip theme={null}
  pip install olostep
  ```

  ```bash pip3 theme={null}
  pip3 install olostep
  ```

  ```bash poetry theme={null}
  poetry add olostep
  ```

  ```bash uv theme={null}
  uv pip install olostep
  ```
</CodeGroup>

## Authenticatie

Verkrijg je API-sleutel van het [Olostep Dashboard](https://www.olostep.com/dashboard/).

## Snel Starten

De SDK biedt twee clientopties afhankelijk van je gebruikssituatie:

<CardGroup cols={2}>
  <Card title="Sync Client (`Olostep`)" href="/sdks/python#sync-client-olostep" icon="sync">
    Beste voor: Scripts en eenvoudige gebruikssituaties waar je voorkeur geeft aan blokkerende operaties.<br /><br />
    De sync client biedt een eenvoudigere, blokkerende interface die gemakkelijker te gebruiken is als je nieuw bent met async/await.
  </Card>

  <Card title="Async Client (`AsyncOlostep`)" href="/sdks/python#async-client-asyncolostep" icon="zap">
    Beste voor: Productietoepassingen en het afhandelen van veel gelijktijdige verzoeken.<br /><br />
    De async client biedt niet-blokkerende operaties en is de aanbevolen keuze voor productietoepassingen die een hoge doorvoer nodig hebben.
  </Card>
</CardGroup>

# Sync Client (Olostep)

De sync client (`Olostep`) biedt een blokkerende interface die perfect is voor scripts en eenvoudige gebruikssituaties.

```python theme={null}
from olostep import Olostep

# Geef de API-sleutel op door de 'api_key' parameter door te geven of
# door de OLOSTEP_API_KEY omgevingsvariabele in te stellen

# De sync client beheert automatisch het resourcebeheer
# Geen expliciete sluiting nodig - resources worden opgeruimd na elke operatie
client = Olostep(api_key="YOUR_REAL_KEY")
scrape_result = client.scrapes.create(url_to_scrape="https://example.com")
```

### Basis Web Scraping

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Eenvoudig scrapen
result = client.scrapes.create(url_to_scrape="https://example.com")
print(f"Gescrapet {len(result.html_content)} karakters")

# Meerdere formaten
result = client.scrapes.create(
    url_to_scrape="https://example.com",
    formats=["html", "markdown"]
)
print(f"HTML: {len(result.html_content)} chars")
print(f"Markdown: {len(result.markdown_content)} chars")
```

### Batchverwerking

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Verwerk meerdere URL's efficiënt
batch = client.batches.create(
    urls=[
        "https://www.google.com/search?q=python",
        "https://www.google.com/search?q=javascript",
        "https://www.google.com/search?q=typescript"
    ]
)

# Wacht op voltooiing en verwerk resultaten
for item in batch.items():
    content = item.retrieve(["html"])
    print(f"Verwerkt {item.url}: {len(content.html_content)} bytes")
```

### Slim Web Crawlen

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Crawlen met intelligente filtering
crawl = client.crawls.create(
    start_url="https://www.bbc.com",
    max_pages=100,
    include_urls=["/articles/**", "/blog/**"],
    exclude_urls=["/admin/**"]
)

for page in crawl.pages():
    content = page.retrieve(["html"])
    print(f"Gecrawled: {page.url}")
```

### Site Mapping

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Haal alle links van een website op
maps = client.maps.create(url="https://example.com")

# Verkrijg alle ontdekte URL's
urls = []
for url in maps.urls():
    urls.append(url)
    if len(urls) >= 10:  # Limiet voor demo
        break

print(f"Gevonden {len(urls)} URL's")
```

### AI-gestuurde Antwoorden

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Verkrijg antwoorden van webpagina's met behulp van AI
answer = client.answers.create(
    task="Wat is het hoofdonderwerp van https://example.com?"
)
print(f"Antwoord: {answer.answer}")
```

# Async Client (AsyncOlostep)

De async client (`AsyncOlostep`) is de aanbevolen client voor high-performance toepassingen, backend services, en wanneer je veel gelijktijdige verzoeken moet afhandelen.

```python theme={null}
from olostep import AsyncOlostep

# Geef de API-sleutel op door de 'api_key' parameter door te geven of
# door de OLOSTEP_API_KEY omgevingsvariabele in te stellen

# RESOURCEBEHEER
# ==============
# De SDK ondersteunt twee gebruikspatronen voor resourcebeheer:

# 1. Context Manager (Aanbevolen voor eenmalig gebruik):
#    Behandelt automatisch resource-opruiming
async with AsyncOlostep(api_key="YOUR_REAL_KEY") as client:
    scrape_result = await client.scrapes.create(url_to_scrape="https://example.com")
# Transport wordt hier automatisch gesloten

# 2. Expliciete Sluiting (Voor langlopende services):
#    Vereist handmatige resource-opruiming
client = AsyncOlostep(api_key="YOUR_REAL_KEY")
try:
    scrape_result = await client.scrapes.create(url_to_scrape="https://example.com")
finally:
    await client.close()  # Handmatig het transport sluiten
```

### Basis Web Scraping

```python theme={null}
import asyncio
from olostep import AsyncOlostep

async def main():
    async with AsyncOlostep(api_key="your-api-key") as client:
        # Eenvoudig scrapen
        result = await client.scrapes.create(url_to_scrape="https://example.com")
        print(f"Gescrapet {len(result.html_content)} karakters")

        # Meerdere formaten
        result = await client.scrapes.create(
            url_to_scrape="https://example.com",
            formats=["html", "markdown"]
        )
        print(f"HTML: {len(result.html_content)} chars")
        print(f"Markdown: {len(result.markdown_content)} chars")

asyncio.run(main())
```

### Batchverwerking

```python theme={null}
import asyncio
from olostep import AsyncOlostep

async def main():
    async with AsyncOlostep(api_key="your-api-key") as client:
        # Verwerk meerdere URL's efficiënt
        batch = await client.batches.create(
            urls=[
                "https://www.google.com/search?q=python",
                "https://www.google.com/search?q=javascript",
                "https://www.google.com/search?q=typescript"
            ]
        )

        # Wacht op voltooiing en verwerk resultaten
        async for item in batch.items():
            content = await item.retrieve(["html"])
            print(f"Verwerkt {item.url}: {len(content.html_content)} bytes")

asyncio.run(main())
```

### Slim Web Crawlen

```python theme={null}
import asyncio
from olostep import AsyncOlostep

async def main():
    async with AsyncOlostep(api_key="your-api-key") as client:
        # Crawlen met intelligente filtering
        crawl = await client.crawls.create(
            start_url="https://www.bbc.com",
            max_pages=100,
            include_urls=["/articles/**", "/blog/**"],
            exclude_urls=["/admin/**"]
        )

        async for page in crawl.pages():
            content = await page.retrieve(["html"])
            print(f"Gecrawled: {page.url}")

asyncio.run(main())
```

### Site Mapping

```python theme={null}
import asyncio
from olostep import AsyncOlostep

async def main():
    async with AsyncOlostep(api_key="your-api-key") as client:
        # Haal alle links van een website op
        maps = await client.maps.create(url="https://example.com")

        # Verkrijg alle ontdekte URL's
        urls = []
        async for url in maps.urls():
            urls.append(url)
            if len(urls) >= 10:  # Limiet voor demo
                break

        print(f"Gevonden {len(urls)} URL's")

asyncio.run(main())
```

### AI-gestuurde Antwoorden

```python theme={null}
import asyncio
from olostep import AsyncOlostep

async def main():
    async with AsyncOlostep(api_key="your-api-key") as client:
        # Verkrijg antwoorden van webpagina's met behulp van AI
        answer = await client.answers.create(
            task="Wat is het hoofdonderwerp van https://example.com?"
        )
        print(f"Antwoord: {answer.answer}")

asyncio.run(main())
```

## SDK Referentie

### Methode Structuur

Beide SDK-clients bieden dezelfde schone, pythonische interface georganiseerd in logische namespaces:

| Namespace  | Doel                   | Belangrijkste Methoden          |
| ---------- | ---------------------- | ------------------------------- |
| `scrapes`  | Enkel URL-extractie    | `create()`, `get()`             |
| `batches`  | Multi-URL verwerking   | `create()`, `info()`, `items()` |
| `crawls`   | Website doorlopen      | `create()`, `info()`, `pages()` |
| `maps`     | Linkextractie          | `create()`, `urls()`            |
| `answers`  | AI-gestuurde extractie | `create()`, `get()`             |
| `retrieve` | Inhoud ophalen         | `get()`                         |

Elke operatie retourneert stateful objecten met ergonomische methoden voor vervolgoperaties.

## Foutafhandeling

Vang alle SDK-fouten op met behulp van de basis-exceptieklasse:

```python theme={null}
from olostep import Olostep, Olostep_BaseError

client = Olostep(api_key="your-api-key")

try:
    result = client.scrapes.create(url_to_scrape="https://example.com")
except Olostep_BaseError as e:
    print(f"Er is een fout opgetreden: {type(e).__name__}")
    print(f"Foutmelding: {e}")
```

Voor gedetailleerde foutafhandelingsinformatie, inclusief de volledige exceptiehiërarchie en gedetailleerde foutafhandelingsopties, zie [Gedetailleerde Foutafhandeling](/sdks/python#detailed-error-handling).

## Automatische Herhalingen

De SDK probeert automatisch opnieuw bij tijdelijke fouten (netwerkproblemen, tijdelijke serverproblemen) op basis van de `RetryStrategy` configuratie. Je kunt het herhalingsgedrag aanpassen door een `RetryStrategy` instantie door te geven bij het maken van de client:

```python theme={null}
from olostep import Olostep, RetryStrategy

retry_strategy = RetryStrategy(
    max_retries=3,
    initial_delay=1.0,
    jitter_min=0.2,
    jitter_max=0.8
)

client = Olostep(api_key="your-api-key", retry_strategy=retry_strategy)
result = client.scrapes.create("https://example.com")
```

Voor gedetailleerde herhalingsconfiguratie-opties en best practices, zie [Retry Strategy](/sdks/python#retry-strategy-configuration).

## Geavanceerde Functies

### Slimme Invoercoërcie

De SDK behandelt intelligent verschillende invoerformaten voor maximaal gemak:

```python theme={null}
from olostep import Olostep, Country

client = Olostep(api_key="your-api-key")

# Formaten: string, lijst of enum
client.scrapes.create(url_to_scrape="https://example.com", formats="html")
client.scrapes.create(url_to_scrape="https://example.com", formats=["html", "markdown"])

# Landen: hoofdletterongevoelige strings of enums
client.scrapes.create(url_to_scrape="https://example.com", country="us")
client.scrapes.create(url_to_scrape="https://example.com", country=Country.US)

# Lijsten: enkele waarden of lijsten
client.batches.create(urls="https://example.com")    # Enkele URL
client.batches.create(urls=["https://a.com", "https://b.com"])  # Meerdere URL's
```

### Geavanceerde Scraping Opties

```python theme={null}
from olostep import Olostep, Format, Country, WaitAction, FillInputAction

client = Olostep(api_key="your-api-key")

# Volledige controle over scraping gedrag
result = client.scrapes.create(
    url_to_scrape="https://news.google.com/",
    wait_before_scraping=3000,
    formats=[Format.HTML, Format.MARKDOWN],
    remove_css_selectors=["script", ".popup"],
    actions=[
        WaitAction(milliseconds=1500),
        FillInputAction(selector="searchbox", value="olostep")
    ],
    parser="@olostep/google-news",
    country=Country.US,
    remove_images=True
)
```

### Caching

Standaard haalt elke scrape-aanvraag de pagina vers op (`max_age=0`). Geef `max_age` door om een recent resultaat met dezelfde parameters opnieuw te gebruiken en de responstijd te verbeteren. Waarde is in **seconden**; het maximum is 7 dagen (`604800`). Zie [Caching](/features/scrapes#caching) voor details.

```python theme={null}
# Opt-in voor caching: accepteer resultaten tot 1 dag (86400 seconden) oud
result = client.scrapes.create(
    url_to_scrape="https://example.com",
    formats=["markdown"],
    max_age=86400
)
```

### Batchverwerking met Aangepaste ID's

```python theme={null}
from olostep import Olostep, Country

client = Olostep(api_key="your-api-key")

batch = client.batches.create([
    {"url": "https://www.google.com/search?q=python", "custom_id": "search_1"},
    {"url": "https://www.google.com/search?q=javascript", "custom_id": "search_2"},
    {"url": "https://www.google.com/search?q=typescript", "custom_id": "search_3"}
],
country=Country.US,
parser="@olostep/google-search"
)

# Verwerk resultaten op aangepaste ID
# Bij gebruik van een parser, haal JSON-inhoud op in plaats van HTML
for item in batch.items():
    if item.custom_id == "search_2":
        content = item.retrieve(["json"])
        print(f"Zoekresultaat: {content.json_content}")
```

### Intelligente Crawling

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Crawlen met intelligente filtering
crawl = client.crawls.create(
    start_url="https://www.bbc.com",
    max_pages=1000,
    max_depth=3,
    include_urls=["/articles/**", "/news/**"],
    exclude_urls=["/ads/**", "/tracking/**"],
    include_external=False,
    include_subdomain=True,
)

for page in crawl.pages():
    content = page.retrieve(["html"])
    print(f"Gecrawled: {page.url}")
```

### Site Mapping met Filters

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Haal alle links op met geavanceerde filtering
maps = client.maps.create(
    url="https://www.bbc.com",
    include_subdomain=True,
    include_urls=["/articles/**", "/news/**"],
    exclude_urls=["/ads/**", "/tracking/**"]
)

# Verkrijg gefilterde URL's
urls = []
for url in maps.urls():
    urls.append(url)

print(f"Gevonden {len(urls)} relevante URL's")
```

### Antwoorden Ophalen

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Maak eerst een antwoord aan
created_answer = client.answers.create(
    task="Wat is het hoofdonderwerp van https://example.com?"
)

# Haal het vervolgens op met behulp van de ID
answer = client.answers.get(answer_id=created_answer.id)
print(f"Antwoord: {answer.answer}")
```

### Inhoud Ophalen

```python theme={null}
from olostep import Olostep

client = Olostep(api_key="your-api-key")

# Haal inhoud op met retrieve ID
result = client.retrieve.get(retrieve_id="ret_123")

# Haal meerdere formaten op
result = client.retrieve.get(retrieve_id="ret_123", formats=["html", "markdown", "text", "json"])
```

## Logging

Schakel logging in om problemen op te sporen:

```python theme={null}
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("olostep")
logger.setLevel(logging.INFO)  # Gebruik DEBUG voor gedetailleerde output
```

**Logniveaus**: `INFO` (aanbevolen), `DEBUG` (gedetailleerd), `WARNING`, `ERROR`

## Retry Strategie Configuratie

De `RetryStrategy` klasse bepaalt hoe de Olostep SDK omgaat met tijdelijke API-fouten door middel van automatische herhalingen met exponentiële backoff en jitter. Dit helpt om betrouwbare werking te garanderen in productieomgevingen waar tijdelijke netwerkproblemen, snelheidslimieten en serveroverbelasting intermitterende fouten kunnen veroorzaken.

### Standaardgedrag

Standaard gebruikt de SDK de volgende herhalingsconfiguratie:

* **Maximale herhalingen**: 5 pogingen
* **Initiële vertraging**: 2 seconden
* **Backoff**: Exponentieel (2^poging)
* **Jitter**: 10-90% van vertraging (willekeurig)

Dit betekent:

* Poging 1: Onmiddellijk
* Poging 2: \~2-3.6s vertraging
* Poging 3: \~4-7.2s vertraging
* Poging 4: \~8-14.4s vertraging
* Poging 5: \~16-28.8s vertraging

Maximale duur: \~57 seconden voor alle herhalingen (in het slechtste geval)

### Aangepaste Configuratie

```python theme={null}
from olostep import AsyncOlostep, RetryStrategy

# Maak aangepaste retry strategie
retry_strategy = RetryStrategy(
    max_retries=3,
    initial_delay=1.0,
    jitter_min=0.2,  # 20% minimale jitter
    jitter_max=0.8,  # 80% maximale jitter
)

# Gebruik met client
async with AsyncOlostep(
    api_key="your-api-key",
    retry_strategy=retry_strategy
) as client:
    result = await client.scrapes.create("https://example.com")
```

### Wanneer Herhalingen Plaatsvinden

De SDK probeert automatisch opnieuw bij:

* **Tijdelijke serverproblemen** (`OlostepServerError_TemporaryIssue`)
* **Timeout reacties** (`OlostepServerError_NoResultInResponse`)

Andere fouten (authenticatie, validatie, resource niet gevonden, enz.) falen onmiddellijk zonder herhaling.

### Transport vs Oproeper Herhalingen

De SDK heeft twee herhalingslagen:

1. **Transportlaag**: Behandelt netwerk-niveau verbindingsfouten (DNS, timeouts, enz.)
2. **Oproeperlaag**: Behandelt API-niveau tijdelijke fouten (gecontroleerd door `RetryStrategy`)

Beide lagen zijn onafhankelijk en hebben aparte configuratie. De totale maximale duur is de som van beide lagen.

### Berekenen van Maximale Duur

```python theme={null}
retry_strategy = RetryStrategy(max_retries=5, initial_delay=2.0)
max_duration = retry_strategy.max_duration()
print(f"Maximale oproepduur: {max_duration:.2f}s")
```

### Configuratievoorbeelden

Hier zijn enkele voorbeelden van hoe je de retry strategie kunt configureren voor verschillende gebruikssituaties.

#### Conservatieve Strategie

```python theme={null}
# Minder herhalingen, kortere vertragingen
retry_strategy = RetryStrategy(
    max_retries=3,
    initial_delay=1.0,
    jitter_min=0.2,
    jitter_max=0.8
)
# Maximale duur: ~12.6s
```

#### Agressieve Strategie

```python theme={null}
# Meer herhalingen voor kritieke operaties
retry_strategy = RetryStrategy(
    max_retries=10,
    initial_delay=0.5
)
# Maximale duur: ~969.75s
```

#### Geen Herhalingen (Snel Falen)

```python theme={null}
# Schakel herhalingen uit voor onmiddellijke foutfeedback
retry_strategy = RetryStrategy(max_retries=0)

client = AsyncOlostep(api_key="your-api-key", retry_strategy=retry_strategy)
```

#### Hoge Doorvoer Strategie

```python theme={null}
# Geoptimaliseerd voor hoge-volume operaties
retry_strategy = RetryStrategy(
    max_retries=2,
    initial_delay=0.5,
    jitter_min=0.1,
    jitter_max=0.3  # Lagere jitter voor meer voorspelbare timing
)
# Maximale duur: ~1.95s
```

### Begrijpen van Jitter

Jitter voegt randomisatie toe om "thundering herd" problemen te voorkomen wanneer veel clients tegelijkertijd opnieuw proberen. De jitter wordt als volgt berekend:

```python theme={null}
base_delay = initial_delay * (2 ** attempt)
jitter_range = base_delay * (jitter_max - jitter_min)
jitter = random.uniform(base_delay * jitter_min, base_delay * jitter_min + jitter_range)
final_delay = base_delay + jitter
```

Bijvoorbeeld, met `initial_delay=2.0`, `jitter_min=0.1`, `jitter_max=0.9`:

* Poging 0: base=2.0s, jitter=0.2-1.8s, final=2.2-3.8s
* Poging 1: base=4.0s, jitter=0.4-3.6s, final=4.4-7.6s
* Poging 2: base=8.0s, jitter=0.8-7.2s, final=8.8-15.2s

### Best Practices

#### Voor Productietoepassingen

```python theme={null}
# Gebalanceerde aanpak voor productie
retry_strategy = RetryStrategy(
    max_retries=5,
    initial_delay=2.0,
    jitter_min=0.1,
    jitter_max=0.9
)
```

#### Voor Ontwikkeling/Testen

```python theme={null}
# Snelle feedback voor ontwikkeling
retry_strategy = RetryStrategy(
    max_retries=2,
    initial_delay=0.5,
    jitter_min=0.1,
    jitter_max=0.3
)
```

#### Voor Batch Operaties

```python theme={null}
# Conservatief voor grote batchtaken
retry_strategy = RetryStrategy(
    max_retries=3,
    initial_delay=1.0,
    jitter_min=0.2,
    jitter_max=0.8
)
```

### Monitoring en Debugging

De SDK logt retry-informatie op het DEBUG-niveau:

```
DEBUG: Tijdelijk probleem, opnieuw proberen in 2.34s
DEBUG: Geen resultaat in reactie, opnieuw proberen in 4.67s
```

Schakel debug logging in om retry-gedrag te monitoren:

```python theme={null}
import logging
logging.getLogger("olostep").setLevel(logging.DEBUG)
```

### Foutafhandeling

Wanneer alle herhalingen zijn uitgeput, wordt de oorspronkelijke fout opgeworpen:

```python theme={null}
try:
    result = await client.scrapes.create("https://example.com")
except OlostepServerError_TemporaryIssue as e:
    print(f"Mislukt na alle herhalingen: {e}")
    # Behandel de permanente mislukking
```

### Prestatieoverwegingen

* **Geheugen**: Elke herhalingspoging gebruikt extra geheugen voor request/response objecten
* **Tijd**: Totale operatietijd kan aanzienlijk langer zijn met herhalingen ingeschakeld
* **API Limieten**: Herhalingen tellen mee voor je API-gebruiksbeperkingen
* **Netwerk**: Meer netwerkverkeer door herhalingspogingen

Kies je retry strategie op basis van de vereisten van je toepassing voor betrouwbaarheid versus prestaties.

## Gedetailleerde Foutafhandeling

### Exceptiehiërarchie

De Olostep SDK biedt een uitgebreide exceptiehiërarchie voor verschillende faalscenario's. Alle excepties erven van `Olostep_BaseError`.

Er zijn drie hoofdtypen fouten die direct erven van `Olostep_BaseError`:

1. **`Olostep_APIConnectionError`** - Netwerk-niveau verbindingsfouten
2. **`OlostepServerError_BaseError`** - Fouten veroorzaakt door de API-server
3. **`OlostepClientError_BaseError`** - Fouten veroorzaakt door de client SDK

### Waarom Verbinding Fouten Apart Zijn

`Olostep_APIConnectionError` is apart van serverfouten omdat het netwerk-niveau fouten vertegenwoordigt die optreden voordat de API het verzoek kan verwerken. Dit zijn transportlaagproblemen (DNS of HTTP-fouten, timeouts, verbinding geweigerd, enz.) in plaats van API-niveau fouten. HTTP-statuscodes (4xx, 5xx) worden beschouwd als API-reacties en worden gecategoriseerd als serverfouten, zelfs als ze problemen aangeven.

```
Olostep_BaseError
├── Olostep_APIConnectionError
├── OlostepServerError_BaseError
│   ├── OlostepServerError_TemporaryIssue
│   │   ├── OlostepServerError_NetworkBusy
│   │   └── OlostepServerError_InternalNetworkIssue
│   ├── OlostepServerError_RequestUnprocessable
│   │   ├── OlostepServerError_ParserNotFound
│   │   └── OlostepServerError_OutOfResources
│   ├── OlostepServerError_BlacklistedDomain
│   ├── OlostepServerError_FeatureApprovalRequired
│   ├── OlostepServerError_AuthFailed
│   ├── OlostepServerError_CreditsExhausted
│   ├── OlostepServerError_InvalidEndpointCalled
│   ├── OlostepServerError_ResourceNotFound
│   ├── OlostepServerError_NoResultInResponse
│   └── OlostepServerError_UnknownIssue
└── OlostepClientError_BaseError
    ├── OlostepClientError_RequestValidationFailed
    ├── OlostepClientError_ResponseValidationFailed
    ├── OlostepClientError_NoAPIKey
    ├── OlostepClientError_AsyncContext
    ├── OlostepClientError_BetaFeatureAccessRequired
    └── OlostepClientError_Timeout
```

### Aanbevolen Foutafhandeling

Voor de meeste gebruikssituaties, vang de basisfout op en print de foutnaam:

```python theme={null}
from olostep import AsyncOlostep, Olostep_BaseError

try:
    result = await client.scrapes.create(url_to_scrape="https://example.com")
except Olostep_BaseError as e:
    print(f"Er is een fout opgetreden: {type(e).__name__}")
    print(f"Foutmelding: {e}")
```

Deze aanpak vangt alle SDK-fouten op en biedt duidelijke informatie over wat er misging. De foutnaam (bijv. `OlostepServerError_AuthFailed`) is beschrijvend genoeg om het probleem te begrijpen.

### Gedetailleerde Foutafhandeling

Als je meer specifieke foutafhandeling nodig hebt, vang dan de specifieke fouttypen direct op. **Vermijd het gebruik van `OlostepServerError_BaseError` of `OlostepClientError_BaseError`** - deze basisklassen geven alleen aan wie de fout heeft veroorzaakt (server vs client), niet wie verantwoordelijk is voor het oplossen ervan. Dit is een implementatiedetail die niet helpt bij foutafhandelingslogica.

In plaats daarvan, vang specifieke fouttypen op die het eigenlijke probleem aangeven:

```python theme={null}
from olostep import (
    AsyncOlostep,
    Olostep_BaseError,
    Olostep_APIConnectionError,
    OlostepServerError_AuthFailed,
    OlostepServerError_CreditsExhausted,
    OlostepClientError_NoAPIKey,
)

try:
    result = await client.scrapes.create(url_to_scrape="https://example.com")
except Olostep_APIConnectionError as e:
    print(f"Netwerkfout: {type(e).__name__}")
except OlostepServerError_AuthFailed:
    print("Ongeldige API-sleutel")
except OlostepServerError_CreditsExhausted:
    print("Credits uitgeput")
except OlostepClientError_NoAPIKey:
    print("API-sleutel niet opgegeven")
except Olostep_BaseError as e:
    print(f"Er is een fout opgetreden: {type(e).__name__}")
```

## Configuratie

### Omgevingsvariabelen

| Variabele              | Beschrijving                | Standaard                    |
| ---------------------- | --------------------------- | ---------------------------- |
| `OLOSTEP_API_KEY`      | Je API-sleutel              | Vereist                      |
| `OLOSTEP_BASE_API_URL` | API basis URL               | `https://api.olostep.com/v1` |
| `OLOSTEP_API_TIMEOUT`  | Verzoek time-out (seconden) | `150`                        |

## Hulp Krijgen

* [Volledige Documentatie](https://docs.olostep.com)
* [Community Slack](https://join.slack.com/t/olostep-users/shared_invite/zt-2pn2ce0uu-~591qIdhAfJy~LXCWQS5UQ)
* [Ondersteuning Email](mailto:info@olostep.com)

## Bronnen

<CardGroup cols={2}>
  <Card title="PyPI Pakket" icon="python" href="https://pypi.org/project/olostep/">
    Bekijk op PyPI
  </Card>

  <Card title="Verkrijg API-sleutel" icon="key" href="https://www.olostep.com/auth">
    Meld je gratis aan
  </Card>
</CardGroup>
