Is there a way to get ALL BOARDS via the API without passing any ID?

Is there a way to get the result of the query below but without passing an “ID” for the board?

{
boards(ids: 2110384567) {
items_page(
limit: 500
query_params: {rules: [{column_id: “controle_de_tempo”, compare_value: [1]}]}
) {
cursor
items {
id
name
column_values {
… on TimeTrackingValue {
history {
ended_at
started_at
started_user_id
}
}
}
}
}
}
}

I want to execute this query without having to specify an ID, i want to return the result for all my boards.
In the previous API version this was possible.

{
  boards(limit: 100, page: 1){
    id
  }
}

Then you can just query for page 2 and so on. This will get you the IDs of all the boards. You can then do a boards(ids: 123123123){items_page... query for each board ID like you showed in your original post.

You may be able to do it by just omitting arguments of boards in your original query (no parenthesis part), but I would discourage this even if it works because you can’t parallelize getting the items from boards that way.

Also you may not be aware, but column_values(types: time_tracking) (without quotes around time_tracking because it is an enum not string) will filter it to return only time tracking columns. You can specify an array of column types to return as well. I thought this might be of value for you if youre trying to just return time tracking column and not everything else (returning unneeded columns will slow things down considerably).

1 Like

Hi Cody, thanks for your help!

Do you know if it is possible to filter a column by the id?
The idea of filtering by column_values is really useful, but I also need to filter by column id.

of course! here is a partial query: column_values(ids: ["columnId1", "columnId2"]){id,type,value} you can use it within your regular query.

you can also use graphql variables, which is recommended - though this is a very abbreviated example (it wont work by itself), you can find details on how to use graphql variables at the link below.

column_values(ids: $columnIds){id,type,value}

1 Like

Thanks again! You helped me a lot already.

Let me ask you another question. In the previuos version of the API I was doing the pagination using only the “page” argument.
Now I saw that there is this “cursor”.
I’m a bit confused, now I’ll need to use both? page and cursor?

The cursor is for paging items_page only - you can also after the initial request use “next_items_page” so you don’t need to retrieve the board each time.

query {
  next_items_page (limit: 50, cursor: "MSw5NzI4MDA5MDAsaV9YcmxJb0p1VEdYc1VWeGlxeF9kLDg4MiwzNXw0MTQ1NzU1MTE5") {
    cursor
    items {
      id
      name
    }
  }
}

For paging root fields (boards, users, etc.) you still use limit and page.

But to paginate items_page (when getting items from a specific board) you need to use cursor. This is because items_page caches the IDs so it knows where to start - with the old method it has to retrieve all the IDs repeatedly and find the first one to start from. Much less efficient on large numbers of pages.

Paginating boards for example is often not even needed - unless you have more than 100 boards. But dealing with items is always a large set, so a more efficient pagination was needed.

What you want to do is first get all your IDs with the boards query I shared first. Then iterate the query you first posted with those board IDs (individually).

1 Like

Thanks Again!

{
  boards(limit: 25, page:1 ") {
    id
    workspace_id
    name
  }
}

Do you know if there is a way to filter the query above by specific workspaces?

I saw in the documentation the query below, but I dind’t find a way to use both queries combined

query {
  workspaces (ids: 1234567) {
    id
    name
    kind
    description
  }
}

Unfortunately at this time, the API does not reveal the boards within a workspace. You can find the workspace a board belongs to, but not what boards belong to a workspace.

Got it.

My client have a lot of boards and the API connection is returning an timeout. As I cannot filter by board (the client want to sell all of them), I was planning to filter by workspace (he only needs 2 of 5).

Now I’m lost on how to solve that :face_with_diagonal_mouth:

What happens with this simplest of queries?

boards(limit: 25, page: 2) {
 id
}

Also are you setting API-Version 2023-10 in the header still?

The query that I’m using:

{
  boards(limit: 100, page: 1) {
    id
    items_page(limit: 500) {
      cursor
      items {
        id
        name
        column_values(ids: [\#(0022)controle_de_tempo\#(0022), \#(0022)n_meros8\#(0022), \#(0022)status_1\#(0022)]) {
          id
          text
          ... on TimeTrackingValue {
            history {
              ended_at
              started_at
              started_user_id
            }
          }
        }
      }
    }
    workspace_id
    name
  }
}

I’m doing a pagination into the Page parameter.
After that, I’m getting the items that return a cursor <> blank and executing this query for those:

{
  next_items_page(
    limit: 500
    cursor: \#(0022)" & Text.From(Pg) & "\#(0022)
  ) {
      cursor
      items {
        id
        name
        column_values(ids: [\#(0022)controle_de_tempo\#(0022), \#(0022)n_meros8\#(0022), \#(0022)status_1\#(0022)]) {
          id
          text
          ... on TimeTrackingValue {
            history {
              ended_at
              started_at
              started_user_id
            }
          }
        }
      }
    }
  }

Ah, yes this is guaranteed to fail, you are definitely going to get too many results for one query because it repeats the items_page for all 100 boards. You only want do items_page for one board at a time. You will not be able to do this in a single query.

First do queries like this:

{
  boards (limit: 100, page: 1){
    id
    workspace_id
  }
}

Now you can filter the boards by workspace_id, and map the ids to an array of board Ids to iterate through, running the following query for each board ID (and then the next_items_page query with the cursor until you get all items for each board).

{
  boards(ids: "123123123") {
    id
    items_page(limit: 500) {
      cursor
      items {
        id
        name
        column_values(ids: ["controle_de_tempo", "n_meros8", "status_1")]) {
          id
          text
          ... on TimeTrackingValue {
            history {
              ended_at
              started_at
              started_user_id
            }
          }
        }
      }
    }
  }
}
1 Like