You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to switch over to this library from the ProdPerfect/monday library and I wasn't able to get it working with even a simple example. I could do board.get_items() but if I added any of the columns it would either build the query incorrectly or time out. I don't have a huge data set (250 items with 50 columns), but I see Monday is clamping down on API resource limits pretty heavily as of next week [1] so I suspect there needs to be more control over exactly what is fetched.
This is what I ended up with, querying graphql directly:
importrequests# Define the column IDs we care about (and the corresponding label for those headings)MONDAY_COLS= (
("name", "Name"),
("text7", "Account code"),
("status", "Customer Status"),
("date5", "Loss Date"),
("loss_reason", "Loss Reason"),
("status7", "Product"),
("dropdown", "Sales Lead"),
("status35", "Attribution"),
("weblink8", "Server URL"),
("status65", "Currency"),
)
# Generic GraphQL helper (read only)defmonday_query(query):
api_url="https://api.monday.com/v2"headers= {"Authorization" : MONDAY_ACCESS_KEY}
data= {'query' : query}
r=requests.post(url=api_url, json=data, headers=headers)
returnr.json()
# Grab the column values for the Column IDs and Item IDs provideddefget_column_values_for_ids(ids, cols):
id_str=','.join(ids)
field_str=','.join([fieldforfield, _incols])
query="""{ items (limit: 100, ids: [%s]) { name column_values (ids: [%s]) { title id type text } } }"""% (id_str, field_str)
data=monday_query(query)
returndata['data']['items']
defget_items_from_monday(cols, board_id, logger=None):
all_items= []
page_no=1whileTrue:
items_query="""{ boards (ids: [%s]) { items (limit: 100, page: %s) { id } } }"""% (str(board_id), str(page_no))
res=monday_query(items_query)
items=res['data']['boards'][0]['items']
ids= [item['id'] foriteminitems]
ifnotids:
breaklogger(f"Fetching data for {len(ids)} items ...")
data=get_column_values_for_ids(ids, cols)
all_items.extend(data)
page_no+=1returnall_items
Specifically,
I'm limiting the columns that get returned with name column_values (ids: [%s]) {
I'm fetching 100 item IDs at a time, then fetching the column values for those 100 IDs (100 being the new maximum the Monday API allows you to fetch).
Given the new API limits, is more fine grained control over the data fetched something that you'd implement?
Hi there,
I'm trying to switch over to this library from the ProdPerfect/monday library and I wasn't able to get it working with even a simple example. I could do
board.get_items()
but if I added any of the columns it would either build the query incorrectly or time out. I don't have a huge data set (250 items with 50 columns), but I see Monday is clamping down on API resource limits pretty heavily as of next week [1] so I suspect there needs to be more control over exactly what is fetched.This is what I ended up with, querying graphql directly:
Specifically,
name column_values (ids: [%s]) {
Given the new API limits, is more fine grained control over the data fetched something that you'd implement?
Thanks for the work on the library to date.
[1] https://community.monday.com/t/adjustments-to-api-rate-limiting/18611
The text was updated successfully, but these errors were encountered: