Skip to content

Commit 64b6d0c

Browse files
authored
Merge pull request #20 from macrocosm-os/gen_1824_update_examples_for_DU_v1_9_75
GEN-1824: Changes based on Data Universe update to OnDemandData in v1.9.75 release
2 parents b4d1101 + 47dee16 commit 64b6d0c

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ print(polled_response)
8585

8686
SN13 is focused on large-scale data collection. With the OnDemandAPI, you can run precise, real-time queries against platforms like X (Twitter) and Reddit (YouTube forthcoming).
8787

88+
As of data-universe release [v1.9.75](https://github.com/macrocosm-os/data-universe/releases/tag/v1.9.75):
89+
- All keywords in an OnDemandData request will be present in the returned post/comment data.
90+
- For Reddit requests, the first keyword in the list corresponds to the requested subreddit, and subsequent keywords are treated as normal.
91+
8892
Use the synchronous `Sn13Client` to query historical or current data based on users, keywords, and time range.
8993

9094
### Query Example
@@ -95,12 +99,12 @@ import macrocosmos as mc
9599
client = mc.Sn13Client(api_key="<your-api-key>", app_name="my_app")
96100

97101
response = client.sn13.OnDemandData(
98-
source='X', # or 'Reddit'
99-
usernames=["@nasa"], # Optional, up to 5 users
100-
keywords=["galaxy"], # Optional, up to 5 keywords
101-
start_date='2025-04-15', # Defaults to 24h range if not specified
102-
end_date='2025-05-15', # Defaults to current time if not specified
103-
limit=1000 # Optional, up to 1000 results
102+
source='X', # or 'Reddit'
103+
usernames=["@nasa"], # Optional, up to 5 users
104+
keywords=["galaxy"], # Optional, up to 5 keywords
105+
start_date='2025-04-15', # Defaults to 24h range if not specified
106+
end_date='2025-05-15', # Defaults to current time if not specified
107+
limit=1000 # Optional, up to 1000 results
104108
)
105109

106110
print(response)

examples/sn13_on_demand_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""
22
Example of using the SN13 On Demand Data Streaming service with Macrocosmos SDK.
3+
4+
As of data-universe release v1.9.75:
5+
- All keywords in the OnDemandData request will be present in the returned post/comment data.
6+
- For Reddit requests, the first keyword in the list corresponds to the requested subreddit, and subsequent keywords are treated as normal.
37
"""
48

59
import os

examples/sn13_on_demand_data_async.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"""
22
Example demonstrating concurrent async operations with the SN13 On Demand Data service.
33
Shows how multiple requests can be processed simultaneously in an async context.
4+
5+
As of data-universe release v1.9.75:
6+
- All keywords in the OnDemandData request will be present in the returned post/comment data.
7+
- For Reddit requests, the first keyword in the list corresponds to the requested subreddit, and subsequent keywords are treated as normal.
48
"""
59

610
import os
@@ -59,9 +63,9 @@ async def main():
5963
"request_id": 2,
6064
},
6165
{
62-
"source": "x",
66+
"source": "reddit",
6367
"usernames": ["ISS", "ESA"],
64-
"keywords": ["galaxy", "universe", "cosmos"],
68+
"keywords": ["r/space", "universe"],
6569
"request_id": 3,
6670
},
6771
]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "macrocosmos"
3-
version = "1.1.1"
3+
version = "1.1.2"
44
description = "The official Python SDK for Macrocosmos"
55
readme = "README.md"
66
license = "Apache-2.0"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)