Skip to content

Commit

Permalink
paging: more example to flare sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Aug 15, 2024
1 parent e4b34eb commit c34aee9
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions docs/introduction/paging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,19 @@ These are end-to-end examples in various programming languages.

<AccordionGroup>

<Accordion title="Python Example">
<Accordion title="Python SDK Example">
```python
import os
import requests
import time

from flareio import FlareApiClient


api_key = os.environ.get("FLARE_API_KEY")
if not api_key:
raise Exception("Please provide an API key")

# Generate the API token.
token = requests.post(
"https://api.flare.io/tokens/generate",
headers={
"Authorization": api_key,
},
).json()["token"]
api_client = FlareApiClient(api_key=api_key)

from_: str | None = None
fetched_pages: int = 0
Expand All @@ -91,11 +86,8 @@ while True:
params["from"] = from_

# Fetch the next page
resp = requests.get(
resp = api_client.get(
"https://api.flare.io/leaksdb/v2/sources",
headers={
"Authorization": f"Bearer {token}",
},
params=params,
)
resp.raise_for_status()
Expand Down

0 comments on commit c34aee9

Please sign in to comment.