Skip to content

Commit a88ecae

Browse files
authored
Merge pull request #30 from mondaycom/feature/michaelim/fetch-updates-incrementaly
Enhance UpdateModule with date filtering and incremental fetch
2 parents 5cd2a08 + 3807b6b commit a88ecae

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
setup(
1717
name="monday-api-python-sdk", # Required
18-
version="1.4.8", # Required
18+
version="1.5.0", # Required
1919
description="A Python SDK for interacting with Monday's GraphQL API", # Optional
2020
long_description=long_description, # Optional
2121
long_description_content_type="text/markdown", # Optional (see note above)

src/monday_sdk/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
API_URL = "https://api.monday.com/v2"
2-
API_VERSION = "2025-07"
2+
API_VERSION = "2026-01"
33
TOKEN_HEADER = "Authorization"
44
MAX_COMPLEXITY = 10000000 # Monday's API complexity limit per minute
55

src/monday_sdk/modules/updates.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ def fetch_updates_for_item(self, item_id, limit=100) -> MondayApiResponse:
2424
query = get_updates_for_item_query(item_id=item_id, limit=limit)
2525
return self.client.execute(query)
2626

27-
def fetch_board_updates_page(self, board_id, limit=100, page=1) -> List[Update]:
28-
query = get_updates_for_board(board_id, limit, page)
27+
def fetch_board_updates_page(self, board_id, limit=100, page=1, from_date: Optional[str] = None, to_date: Optional[str] = None) -> List[Update]:
28+
"""
29+
Fetches a single page of updates from a board.
30+
31+
Note: from_date and to_date parameters require Monday API version 2026-01+
32+
"""
33+
query = get_updates_for_board(board_id, limit, page, from_date, to_date)
2934
response: MondayApiResponse = self.client.execute(query)
3035
return response.data.boards[0].updates
3136

@@ -64,4 +69,35 @@ def fetch_board_updates(
6469
all_updates.extend(updates)
6570
page += 1
6671

67-
return all_updates
72+
return all_updates
73+
74+
def fetch_board_updates_incremental(
75+
self,
76+
board_id: str,
77+
limit: int = 100,
78+
page: int = 1,
79+
from_date: Optional[str] = None,
80+
to_date: Optional[str] = None,
81+
) -> List[Update]:
82+
"""
83+
Fetches updates from a board using Monday's native incremental fetch API.
84+
Uses the API's built-in date filtering instead of client-side filtering.
85+
86+
**Requires API version 2026-01 or later**
87+
88+
Args:
89+
board_id: The board ID to fetch updates from
90+
limit: Maximum number of updates per page (default: 100)
91+
page: Page number to fetch (default: 1)
92+
from_date: Start date in ISO format (e.g., "2025-10-10T00:00:00Z")
93+
to_date: End date in ISO format (e.g., "2025-11-11T00:00:00Z")
94+
95+
Returns:
96+
List of Update objects
97+
98+
Note:
99+
The from_date and to_date parameters require Monday API version 2026-01+.
100+
If using an older API version, use fetch_board_updates() instead which
101+
provides client-side date filtering.
102+
"""
103+
return self.fetch_board_updates_page(board_id, limit, page, from_date, to_date)

src/monday_sdk/query_templates.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,19 @@ def get_updates_for_item_query(item_id, limit: int):
544544
return query
545545

546546

547-
def get_updates_for_board(board_id, limit: int, page=1):
547+
def get_updates_for_board(board_id, limit: int, page=1, from_date: Optional[str] = None, to_date: Optional[str] = None):
548+
# Build the updates parameters
549+
updates_params = f"limit: {limit}, page: {page}"
550+
551+
if from_date:
552+
updates_params += f', from_date: "{from_date}"'
553+
if to_date:
554+
updates_params += f', to_date: "{to_date}"'
555+
548556
query = """query
549557
{
550558
boards(ids: %s) {
551-
updates(limit: %s, page: %s) {
559+
updates(%s) {
552560
id,
553561
text_body,
554562
item_id,
@@ -562,8 +570,7 @@ def get_updates_for_board(board_id, limit: int, page=1):
562570
}
563571
}""" % (
564572
board_id,
565-
limit,
566-
page,
573+
updates_params,
567574
)
568575

569576
return query

0 commit comments

Comments
 (0)