Skip to content

Commit 4279e6b

Browse files
committed
sdk: document scroll_events
1 parent 353f3c3 commit 4279e6b

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

docs/changelog/overview.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ This page lists changes to Flare's API.
1212
Release notes for the Flare Platform can be found on the [product documentation website](https://docs.flare.io/releases).
1313
</Note>
1414

15+
<Update label="2025-05-15" description="Python SDK - v1.2.0">
16+
Released version 1.2.0 of the
17+
[Python SDK <Icon icon="book" size={16} />](/sdk/python).
18+
19+
This release adds a new `scroll_events` method that can be used to retrieve events from the feed APIs
20+
without having to manage fetching events individually.
21+
22+
More information, including full examples, can be found in the
23+
[Python SDK documentation <Icon icon="book" size={16} />](/sdk/python).
24+
</Update>
25+
1526
<Update label="2025-11" description="API - November 2025">
1627
Added a [Global Search Credentials Endpoint <Icon icon="code" size={16} />](/api-reference/v4/endpoints/credentials-global-search).
1728
This new endpoint allows for searching in all of Flare's credentials and counts towards the Global Search quota.

docs/sdk/python.mdx

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ resp = client.get("/tokens/test")
5858
print(resp.json())
5959
```
6060

61-
## Paging Util
61+
## Paging Util - Generic
6262

6363
The `FlareApiClient` has a `scroll` method that can be used with endpoints that support the
6464
[Flare standard paging pattern <Icon icon="book" size={16} />](/concepts/paging).
6565

66-
```python Paging Util Example
66+
```python Paging Util - Generic Example
6767
import os
6868
import time
6969

@@ -102,6 +102,45 @@ for resp in api_client.scroll(
102102
print("The last value for 'next' was", last_from)
103103
```
104104

105+
## Paging Util - Event Feeds
106+
107+
The `FlareApiClient` has a `scroll_events` method that can be used with event feeds endpoints.
108+
The advantage of this method over `scroll` is that it also automates the fetching of individual events.
109+
110+
```python Paging Util - Event Feeds Example
111+
import datetime
112+
113+
from flareio import FlareApiClient
114+
115+
116+
api_client = FlareApiClient.from_env()
117+
118+
from_timestamp: str = (
119+
datetime.datetime.now(tz=datetime.timezone.utc) - datetime.timedelta(hours=1)
120+
).isoformat()
121+
122+
for event, next in api_client.scroll_events(
123+
method="POST",
124+
pages_url="/firework/v4/events/global/_search",
125+
events_url="/firework/v2/activities/",
126+
json={
127+
"size": 10,
128+
"order": "asc",
129+
"from": None,
130+
"filters": {
131+
"type": ["chat_message"],
132+
"estimated_created_at": {"gte": from_timestamp},
133+
},
134+
"query": {
135+
"type": "query_string",
136+
"query_string": "hello",
137+
},
138+
},
139+
):
140+
print(f"Full event data: {event}")
141+
print(f"The next execution could resume using from={next}")
142+
```
143+
105144
## Custom Session
106145

107146
The `FlareApiClient` can be initialized with a custom `requests.Session`. This allows, for example,

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ python-frontmatter==1.1.0
55
requests==2.32.5
66
pytest==8.4.2
77
types-requests==2.32.4.20250913
8-
flareio>=1.1.0
8+
flareio>=1.2.0

0 commit comments

Comments
 (0)