# The search endpoint doesn't seem to work

**URL:** <https://forum.frame.io/t/the-search-endpoint-doesnt-seem-to-work/845>\
**Category:** Help\
**Tags:** javascript, api\
**Created:** [October 31, 2023, 10:57am UTC](https://forum.frame.io/t/the-search-endpoint-doesnt-seem-to-work/845 "2023-10-31T10:57:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bg44](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bg44](https://forum.frame.io/u/bg44)\
**Post date:** [October 31, 2023, 10:57am UTC](https://forum.frame.io/t/the-search-endpoint-doesnt-seem-to-work/845/1 "2023-10-31T10:57:27Z")

</div>

Hello guys,

after exchanging a lot of messages with the support, they recommended to post my problem here.

I’m trying to use the search endpoint. I want to find all folders that have “\_Final” included in their name. I followed the API specification, the documentation and the support feedback, it doesn’t matter what I do, it doesn’t work. All I get are empty arrays.

=\> That looks as I don’t have the necessary permissions, but I enabled every permission.  
=\> However I specified the query (\_final, Final, \_FINAL, FiNaL), I receive empty arrays.  
=\> You can see that I filter for team\_id. I get empty arrays, whether I filter for it or not.

Here are two approaches I tried:

This is the first approach, where I query all projects to retrieve its ID. After that I loop through the projects and search for folders that match the „\_Final“ Query. I do that, because the folders I want to query have „\_Final“ in their name.

```plaintext
  // === APPROACH 1 ===

  /*
   * 1. Get all projects
   * 2. For each project, get all folders that match the query
   */

  const projectQuery = new URLSearchParams({
    "filter[archived]": "all",
  }).toString();

  const teamId = process.env.FRAME_IO_TEAM_ID;
  const response = await fetch(
    `https://api.frame.io/v2/teams/${teamId}/projects?${projectQuery}`,
    {
      method: "GET",
      headers: {
        Authorization: "Bearer " + process.env.FRAME_IO_KEY,
      },
    }
  );
  const projectData = await response.text();
  const projects = JSON.parse(projectData);

  for (let project of projects) {
    const resp = await fetch(`https://api.frame.io/v2/search/library`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${process.env.FRAME_IO_KEY}`,
      },
      body: JSON.stringify({
        account_id: process.env.FRAME_IO_ACCOUNT_ID,
        q: "_FINAL",
        filter: {
          asset_type: {
            op: "eq",
            value: "folder",
          },
          project_id: {
            op: "eq",
            value: project.id,
          },
          team_id: {
            op: "eq",
            value: process.env.FRAME_IO_TEAM_ID,
          },
        },
      }),
    });

    const data = await resp.json();
    console.log(project.id, data);
  }

```

The second approach is much simpler. I am searching for the folders that match the „\_final“ query:

```plaintext
  // === APPROACH 2 ===

  /*
   * 2. Gett all folders that match the query
   */

  const resp = await fetch(`https://api.frame.io/v2/search/library`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${process.env.FRAME_IO_KEY}`,
      },
      body: JSON.stringify({
        account_id: process.env.FRAME_IO_ACCOUNT_ID,
        q: "_FINAL",
        filter: {
          asset_type: {
            op: "eq",
            value: "folder",
          },
          team_id: {
            op: "eq",
            value: process.env.FRAME_IO_TEAM_ID,
          }
        }
      }),
    });

```

**Either your API is broken, or I can only filter for the exact name. I don’t have any other ideas.**

I hope you guys can help me.

Cheers,  
Ben
