I would like to know if this is still true: Filter API by Date
That I can’t filter items based on their updated at date.
Use case: I’ll build an app to extract data from Monday and send it to a database to be used in power bi. So if it was possible to filter the items by the update at date, I would get for sure just the data that I need to create/update in the database.
I believe the referenced answer is still the case.
One suggestion would be to add the ‘newest_first: true’ attribute. While not exactly what you were looking for you should be able to achieve your goal. You’d have to update the limit and possibly paginate until you come across a data point that is before your last request.
query {
items (newest_first: true) {
id name updated_at
}
}
Yeah, but I guess it would not work. Let’s say I have an item that was created one year ago and has just been updated. It would not be considered by this filter newest_first. I would still need to get all items from board and test for the updated_at anyway.
Hi @Samuel, I also shared your question and found that there is an indirect workaround available, if you query Activity Logs, which does have a timestamp argument, and then parse the item IDs from the response, as described here, see also the example below.
@Matias.Monday please also add my vote for Monday to provide this feature directly. It encourages inefficient use of computational resources on both sides, and it is unusual for an API not to offer this feature. It presents an obstacle to the timely and frequent synchronisation of data in Monday with other systems, an objective which is becoming increasingly important to modern businesses.
Here’s an example in Python, of how to obtain the IDs for items which have been updated since a given time.
import json
import requests
def flatten_list(input_list):
return [item for sublist in input_list for item in sublist]
# Prepare GraphQL query to list activity logs for all boards
query = (
"query activity_logs($from: ISO8601DateTime $page: Int)"
"{boards{activity_logs(from: $from page: $page){id data entity}}}"
)
variables = {"from": "2023-01-01T00:00:00", "page": 1}
response = requests.get(
url="https://api.monday.com/v2",
json={"query": query, "variables": variables},
headers={"Authorization": "Bearer ***"},
)
# Prepare response data
response_data = response.json()
activity_logs = flatten_list(
[board["activity_logs"] for board in response_data["data"]["boards"]]
)
if activity_logs: # if list is not empty
# Filter for board and pulse (AKA item) objects
boards = [
json.loads(al["data"])
for al in activity_logs
if al["entity"] == "board"
]
pulses = [
json.loads(al["data"])
for al in activity_logs
if al["entity"] == "pulse"
]
# Extract and deduplicate IDs for boards and items
board_ids: set[int] = set([b["board_id"] for b in boards])
# Note there seem to be two possible schemas for the
# pulse object, but both contain the item ID
pulse_ids: set[int] = set(
[
*[p["pulse_id"] for p in pulses if "pulse_id" in p],
*[p["pulse"]["id"] for p in pulses if "pulse" in p],
]
)
# Further requests can now be made using those IDs...
Here’s a slight correction to the code above, as you’ll need to paginate through each page of activity logs, for each page of boards, until the responses return no data
Hello there @anant_m and welcome to the community!
There is no parameter for filtering according to the creation of the item.
But as a workaround, you can create an automation in your board that sets a date column to TODAY when an item is created, and then you can use a query like this one: