Skip to main content

Updated since filter

  • September 14, 2022
  • 16 replies
  • 2112 views

Samuel

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.

16 replies

shadmickelberry
  • Participating Frequently
  • September 14, 2022

Hello,

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
        
      }
    }

Samuel
  • Author
  • New Participant
  • September 15, 2022

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.


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • September 15, 2022

Hello @Samuel and welcome to the community!

I hope you like it here 💪

Indeed that is the case. You can not use a parameter to filter using the update date as a criteria.

Having said that, I have added your case as a vote into a request for this feature.

Let us know if you have any other questions!

Cheers,
Matias


  • Participating Frequently
  • January 2, 2023

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...

Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • January 3, 2023

Hello @TomUK and thank you for sharing that!

I have added your vote towards this request 🙂

Cheers,
Matias


  • Participating Frequently
  • January 4, 2023

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 👍

query = """
query activity_logs($from: ISO8601DateTime, $board_page: Int, $log_page: Int) {
  boards(page: $board_page, limit: 100) {
    activity_logs(from: $from, page: $log_page, limit: 100) {
      id
      data
      entity
    }
  }
}
"""
variables = {"from": "2023-01-01T00:00:00", "board_page": 1, "log_page": 1}

Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • January 5, 2023

Thank you for the correction @TomUK !


GCavin
  • Participating Frequently
  • January 7, 2023

@Matias.Monday Where can we vote for this request?


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • January 8, 2023

Hi @GCavin,

Right here!

I have added your vote 🙂


DanielHai
Forum|alt.badge.img
  • monday.com Team Member
  • March 12, 2024

Hi Everyone

I am excited to share that you can now filter based on the last updated date in the API, regardless of wether it is a board column or not!

The key to doing so is using the "UPDATED_AT" compare attribute!

Here is an example of how to get all items that were updated in the current date

query {
  boards(ids: 1234567890) {
    items_page (query_params: {rules: [{column_id: "__last_updated__", compare_value: ["TODAY"], operator:any_of, compare_attribute:"UPDATED_AT"}]}) {
      items {
        id
        name
      }
    }
  }
}

Happy Coding!


  • New Participant
  • May 20, 2024

Hi @DanielHai is there something similar for filtering by created_at field? I want to do a query like created_at >= '2024-03-12 11:15'


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • May 21, 2024

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:

query {
  boards(ids: 1234567890) {
    items_page(
      query_params: {rules: [ {
        column_id: "date__1", 
        compare_value: ["EXACT", "2023-05-05"], 
        operator: greater_than_or_equals}]}
    ) {
      items {
        id
        name
      }
    }
  }
}

Of course you would need to get the creation date of all existing items as well to put that in the date column.

Let me know if you have any other questions!

Cheers,
Matias


  • New Participant
  • November 19, 2024

@DanielHai Can we have a timestamp as compare_value for last_updated instead of ‘TODAY’, ‘YESTERDAY’ etc?


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • November 21, 2024

Hello there @aditya.mandavi,

Are you referring to something like this:

query {
  boards(ids: [1234567890]) {
    items_page(
      query_params: {rules: [ { 
        column_id: "date", 
        compare_value: ["EXACT", "2023-07-01"], 
        operator: any_of}]}
    ) {
      items {
        id
        name
      }
    }
  }
}

?

Looking forward to hearing from you 😀

Cheers,
Matias


  • Participating Frequently
  • December 2, 2024

Hi @Matias.Monday,

I believe what he meant is this:
Query items with last_updated >= timestamp (datetime/epoch timestamp)

Would that be possible?


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 2, 2024

Oh, wait,

Or is it something like:

query {
  boards(ids: [1234567890]) {
    items_page(
      query_params: {rules: [ { 
        column_id: "date", 
        compare_value: ["LAST_UPDATED"], 
        operator: any_of}]}
    ) {
      items {
        id
        name
      }
    }
  }
}

?

If so, it is not possible at the moment.