Metadata API Intermediate

#DDQ2025-07 Tableau Metadata API (Intermediate)

How do you use variables and filter in the Metadata API?

J

Jordan Woods

Author

2025-07-30T11:19:02
5 min read
preview.png

Welcome to the DataDev Quest Challenge for July 2025! This challenge is designed to teach you
how to use the Metadata API to query content on your site.

Challenge Overview

Objective:

Apply filters, variables, and page through Tableau Metadata API results.

Why this challenge?

Some information about your site is only accessible through the Metadata API, or more easily accessed this way. It uses a different query language, GraphQL, to access that information. Learning how to filter using GraphQL to get only what you want and use variables to make it more dynamic eases usability in the future

Learning Goals

  • Become familiar with GraphQL
  • Learn how to use the graphiql web interface
  • Be familiar with how to read the JSON output

Submission Guidelines

  • Source Code: Publish your project publicly in your GitHub profile
  • Add README: Include any setup instructions and describe how to run the program.
  • Video of Solution: Include a video of your solution in the README file. You can publish it on YouTube and embed the iframe, or save the video file in the repository’s root directory
  • Comments: Ensure your code is well-commented
  • Submission: Submit your challenge in the following forms

Additional Resources


Getting Started

The first step is to get and set up your Tableau Developer Sandbox. Cristian Saavedra Desmoineaux has a Medium Post that provides a step-by-step guide to configuring it.

1. In your Tableau Cloud Site, go to Explore

and check if there is a project named Samples. If not, you will have to publish a workbook of your own. Superstore will work for this challenge.

2. How to navigate to the GraphiQL interface?

You can get there two ways. First is by Going to External Assets in the left hand navigation then by clicking on Query metadata (GraphiQL) in the upper right of the page.

The second method is to go there directly once signed into your site by replacing the entire path of your URL with /metadata/graphiql. If you are on the developer sandbox, for example, it would be https://10ax.online.tableau.com/metadata/graphiql/. You should see an interface that looks like this:

The GraphiQL interface consists of three panes:

  • The left most pane is where you write your GraphQL query.
  • The middle pane is where the results are displayed.
  • The left hand side is the documentation.

In the documentation pane, under “Root Types” is the type “Query.” Clicking on “Query” will then display all of the various “root” nodes that you can have for your query.

For our example, lets construct a workbook query. The structure of a GraphQL query is as follows:

CODE
# The word query is required, as is a name without spaces (example ddq_workbooks), and the curly braces.
query ddq_workbooks {

}

You can scroll down (or search) and click on “workbooks” to see more information about workbooks:

Let’s update our query to include the workbook node:

CODE
query ddq_workbooks {
  workbooks{
    # What fields do you want out?
  }
}

The nice thing about GraphQL is you can ask it to give you only the fields that you are actually interested in.

Now its time to learn about using GraphQL variables and filters. It is easy to miss in the bottom left the collapsed “QUERY VARIABLES” pane. Click on that to expand it.

The nice thing about the filters are that they tell you explicitly what data type the expect. If the type is in square brackets, e.g. [String], it expects an array/list of strings.

To use a variable, you have to pass your query a top level directive indicating what the name of the variable you will be using is, and it’s data type.

To get the results paginated though, you need to ensure that the response has a “pageInfo” key in the response, and not all objects return pageInfo. The Documentation Explorer in the GraphiQL interface has all of the details over what is there and how you can access it. Also take a look at Tableau’s Metadata API documentation for an example of how to pass the limiting constraints for a paginated request.


Challenge

Now that you know some basics about how the Metadata API and GraphQL work and can be accessed, your challenge is to write a query that retrieves details about a workbook of your choosing and its IDs, the owner’s ID, and the name of the project it is in.

Do you have a problem you’ve previously solved with the REST API, but it takes multiple queries?

How can you do it in one here?


Extra Challenge

Do you want to learn more? As suggested by my friend Cristian Saavedra Desmoineaux, one nice thing that is easy to do with Tableau Metadata API is to get the list of published Data Sources and the connected workbooks related, as the following image:

How do you get it with a query using the Tableau Metadata API?


Solutions

CODE
# Use a filter to retrieve only specific objects
# Use aliases for clarity in the output
query ddq_intermediate($wb_name: String) {
  workbooks(filter: {name: $wb_name}) {
    name
    projectName
    luid
    description
    owner {
      owner_name:name
      owner_id:luid
    }
    site {
      site_id:luid
      site_name:name
    }
  }
}
CODE
# Get published data sources and all connected workbooks
query get_published_datasources
{
  publishedDatasources{
    luid,
    name,
    projectName,
    downstreamWorkbooks{
      luid,
      name,
      projectLuid,
      projectName,
      owner {
        id,
        name,
        username
      },
    }
  }
}

Who am I?

I am Jordan Woods, a Tableau DataDev Ambassador and co-founder of DataDevQuest. I am passionate about data, Python, and automation. You can contact me on LinkedIn.

Jordan Woods Headshot

Special Thanks to Cristian Saavedra Desmoineaux and Anya Prosvetova!