### Query response example Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_start.html Example response for the query example. The response returns only the data specified in the same shape as the query. ```json { "data": { "databases": [ { "name": "adventureworks", "tables": [ { "name": "AWBuildVersion" } ] }, { "name": "adventureworks", "tables": [ { "name": "SalesTerritory" }, { "name": "Department" }, { "name": "Culture" }, { "name": "Address" }, { "name": "Product" } ] }, { "name": "adventureworks", "tables": [ { "name": "CustomerAddress" }, { "name": "Address" }, { "name": "Customer" } ] } ] } } ``` -------------------------------- ### Query example: databases filter Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_start.html Example query that filters databases by name and returns the database name and its table names. ```graphql query useMetadataApiToQueryOrdersDatabases{ databases (filter: {name: "adventureworks"}){ name tables{ name } } } ``` -------------------------------- ### Response for basic GraphQL query Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_examples.html Example response for the basic GraphQL query, showing that GraphQL returns data in a similar shape as the query itself. ```json "data": { "hello": "world" }, ``` -------------------------------- ### GET request with querystring Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_start.html Example URI and querystring for submitting a GraphQL query using GET. The query is URL-encoded in the query parameter. ```http https://tableau.example.com/api/metadata/graphql?query=query%20myquery%7Bdatabases%7Bname%20id%7D%7D' ``` -------------------------------- ### Basic GraphQL query with query root object Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_examples.html A minimal GraphQL query that starts with the required `query` root object and requests the `hello` object. The response shape mirrors the query structure. ```graphql query { hello } ``` -------------------------------- ### Cursor pagination: second page Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_examples.html Retrieves the next page of published data sources using the cursor pagination method. The after parameter should be set to the endCursor value from the previous query; the example shows after: null as a placeholder. ```graphql query PaginatedQueryCursorPage2 { publishedDatasourcesConnection(first: 10, after: null, orderBy: {field: NAME, direction: ASC}) { nodes { name } pageInfo { hasNextPage endCursor } } } ``` -------------------------------- ### Type-specific tags query results Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_model.html Example output of the type-specific tags query, returning tags metadata for WorkbookA. ```graphql { tags { workbooks { { id: "A", name: "WorkbookA" } { id: "B", name: null } } } ``` -------------------------------- ### Enable Metadata API with tsm maintenance metadata-services enable Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_start.html Run this command as an admin on the initial node (where TSM is installed) to enable the Metadata API on Tableau Server. It begins initial ingestion and creates a new index of metadata; subsequent runs replace the previous index. Note that it stops and starts some services, temporarily disabling functionality such as Recommendations. ```bash tsm maintenance metadata-services enable ``` -------------------------------- ### Query databases and tables on the site Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_examples.html Queries the Metadata API to list all databases and tables on the site, returning their id and name attributes. Use this to identify the types of database and table assets available. ```graphql query getDatabasesOnMySite{ databases { id name } } query getTablesTablesOnMySite{ tables { id name } } ``` -------------------------------- ### GET /api/metadata/graphql Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_start.html Submit a GraphQL query to the Metadata API using HTTP GET with the query as a URL-encoded querystring parameter. ```APIDOC ## GET /api/metadata/graphql ### Description Submit a GraphQL query to the Metadata API using HTTP GET with the query as a URL-encoded querystring parameter. ### Method GET ### Endpoint `http:///api/metadata/graphql` ### Query Parameters - **query** (string) - Required - The GraphQL query, URL-encoded. ### Request Example ``` https://tableau.example.com/api/metadata/graphql?query=query%20myquery%7Bdatabases%7Bname%20id%7D%7D ``` ### Response #### Success Response (200) Returns the data in the shape of the query. #### Response Example ```json { "data": { "databases": [ { "name": "adventureworks", "tables": [ { "name": "AWBuildVersion" } ] } ] } } ``` ``` -------------------------------- ### Cursor pagination: first page Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_examples.html Retrieves the first ten published data sources using the cursor pagination method. The cursor method is faster than offset for large lists. The pageInfo attribute returns hasNextPage and endCursor; hasNextPage is true only if more pages exist after the given orderBy and first parameters, and endCursor should be saved for the next query. ```graphql query PaginatedQueryCursorPage1 { publishedDatasourcesConnection(first: 10, orderBy: {field: NAME, direction: ASC}) { nodes { name } pageInfo { hasNextPage endCursor } } } ``` -------------------------------- ### Offset pagination: first page Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_examples.html Retrieves the first ten published data sources using the offset pagination method. The offset method allows larger queries but may affect performance as the query grows. The pagination format is (first: , offset: ). ```graphql query PaginatedQueryOffsetPage1 { publishedDatasourcesConnection(first: 10, offset: 0) { nodes { name } } } ``` -------------------------------- ### Tags query obfuscated results Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_model.html Example output of the tags query using asset attribute, showing obfuscated results with null names. ```graphql { tags { assets { { id: "A", name: null } { id: "B", name: null } } } } ``` -------------------------------- ### Query that produces FieldUndefined error for dataQualityWarnings.asset Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_errors.html This query produces a FieldUndefined error because dataQualityWarnings.asset points to the CanHaveLabels interface, which does not have a dataQualityWarnings field. Use this example to reproduce the error described in the documentation. ```graphql query myQuery { dataQualityWarnings { asset { dataQualityWarnings { message } } } } ``` -------------------------------- ### databasesConnection Source: https://help.tableau.com/current/api/metadata_api/en-us/reference/query.doc.html Fetches databases with support for pagination. Accepts filter, sort order, permission mode, and pagination arguments. ```APIDOC ## Query: databasesConnection ### Description Fetches databases with support for pagination. ### Arguments - **filter** (Database_Filter) - Optional - Filter by GraphQL field and given value. - **orderBy** (DatabaseSortOrder) - Optional - Sort by given fields. The sort orders defined first in the list will take priority. If there are no given sort orders or a tie on the final sorted field then the resulting set will be sorted by ID in ascending order. - **permissionMode** (PermissionMode) - Optional - Results filtering mode. - **after** (String) - Optional - The cursor to receive the next page of objects. If no cursor is supplied it will start at the beginning of the list. Offset can not be set at the same time. This is the preferred API to use if possible as it is faster. - **first** (Int) - Optional - Maximum number of objects to be returned in a page. The default is 100. - **offset** (Int) - Optional - The number of entries to offset the start of the page by. If no offset is supplied it will start at the beginning of the list. After can not be set at the same time. ### Return Type DatabasesConnection! ``` -------------------------------- ### binFieldsConnection Source: https://help.tableau.com/current/api/metadata_api/en-us/reference/query.doc.html Fetches BinFields with support for pagination. ```APIDOC ## binFieldsConnection ### Description Fetches BinFields with support for pagination. ### Arguments - **filter** (BinField_Filter) - Optional - Filter by GraphQL field and given value. - **orderBy** (BinFieldSortOrder) - Optional - Sort by given fields. The sort orders defined first in the list will take priority. If there are no given sort orders or a tie on the final sorted field then the resulting set will be sorted by ID in ascending order. - **permissionMode** (PermissionMode) - Optional - Results filtering mode. - **after** (String) - Optional - The cursor to receive the next page of objects. If no cursor is supplied it will start at the beginning of the list. Offset can not be set at the same time. This is the preferred API to use if possible as it is faster. - **first** (Int) - Optional - Maximum number of objects to be returned in a page. The default is 100. - **offset** (Int) - Optional - The number of entries to offset the start of the page by. If no offset is supplied it will start at the beginning of the list. After can not be set at the same time. ### Return Type BinFieldsConnection! ``` -------------------------------- ### customSQLTablesConnection Source: https://help.tableau.com/current/api/metadata_api/en-us/reference/query.doc.html Fetches CustomSQLTables with support for pagination. Accepts filter, sort order, permission mode, and pagination arguments. ```APIDOC ## Query: customSQLTablesConnection ### Description Fetches CustomSQLTables with support for pagination. ### Arguments - **filter** (CustomSQLTable_Filter) - Optional - Filter by GraphQL field and given value. - **orderBy** (CustomSQLTableSortOrder) - Optional - Sort by given fields. The sort orders defined first in the list will take priority. If there are no given sort orders or a tie on the final sorted field then the resulting set will be sorted by ID in ascending order. - **permissionMode** (PermissionMode) - Optional - Results filtering mode. - **after** (String) - Optional - The cursor to receive the next page of objects. If no cursor is supplied it will start at the beginning of the list. Offset can not be set at the same time. This is the preferred API to use if possible as it is faster. - **first** (Int) - Optional - Maximum number of objects to be returned in a page. The default is 100. - **offset** (Int) - Optional - The number of entries to offset the start of the page by. If no offset is supplied it will start at the beginning of the list. After can not be set at the same time. ### Return Type CustomSQLTablesConnection! ``` -------------------------------- ### Filter fields by name using text filter Source: https://help.tableau.com/current/api/metadata_api/en-us/docs/meta_api_release_notes.html Example query for filtering fields by name using a text filter. The filter returns fields where any word in the field name begins with the specified case-insensitive text. ```graphql query FilteredFields { publishedDatasources { name fields (filter: {text: "age"}) { id name } } } ```