API for DataSet tags
I am having trouble trying to pull values from the Domo API, to identify datasets by "tag". In data center, if I tag some of my datasets as "API", I want to use Python to pull the list of all datasets with that tag.
There's a discussion at this link but it doesn't give a solution:
I can get a list of my Domo datasets and search by name using "https://api.domo.com/v1/datasets". But the list I need doesn't have a common string in the names. Therefore I need the type or tag. I'm looking for the datasets associated to the code in my Jupyter notebooks.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **
Best Answer
-
You can send a POST to this endpoint as referenced in the discussion you linked: https://{{your_instance}}.domo.com/api/data/ui/v3/datasources/search
with this post body:
{"entities": ["DATASET"], "filters": [{"filterType": "facetValue", "field": "tag", "value": "<YOUR TAG GOES HERE>*"}], "combineResults": "true", "query": "*", "count": 10, "offset": 0,
"sort": {"isRelevance": "false", "fieldSorts": [{"field": "create_date", "sortOrder": "DESC"}]}}0
Answers
-
@ArborRose when I inspect the network traffic when I click on a tag in the data center, I see that this is being applied.
This would be against the https://[instance-name].domo.com/api/search/v1/query
Have you tried using this already?
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
You can send a POST to this endpoint as referenced in the discussion you linked: https://{{your_instance}}.domo.com/api/data/ui/v3/datasources/search
with this post body:
{"entities": ["DATASET"], "filters": [{"filterType": "facetValue", "field": "tag", "value": "<YOUR TAG GOES HERE>*"}], "combineResults": "true", "query": "*", "count": 10, "offset": 0,
"sort": {"isRelevance": "false", "fieldSorts": [{"field": "create_date", "sortOrder": "DESC"}]}}0 -
Thank you @MarkSnodgrass and @ggenovese.
I had been searching different endpoints and couldn't find the correct one. @ggenovese , the endpoint you listed was what I needed for my search. After a bit of exhaustive code changes, the following will display a list of the datasets with tag "Your_Tag_Goes_Here". And all the information about the datasets. From there, we can gather the specific fields needed.
My specific use for this is to extract my API dataset list (based on name search for a string I include in all my API calls), and my Jupyter dataset list (based on the tag, using code below) and automate them into a scheduling Gantt chart. I've been hoping Domo would create one.import requests import json # 10.03.24 Author: ArborRose # This Python code uses the Domo API to retrieve # datasets based on the "tag". # Domo API Credentials (replace with your developer token) developer_token = 'your_developer_token' # Set headers for the API call headers = { 'X-DOMO-Developer-Token': developer_token, 'Content-Type': 'application/json' } # API URL for fetching datasets and their tags url = 'https://yourinstance.domo.com/api/data/ui/v3/datasources/search' # Payload for searching datasets by tag payload = { "entities": ["DATASET"], # Specify that we want datasets "filters": [ { "filterType": "facetValue", "field": "tag", "value": "Your_Tag_Goes_Here" # Replace with your tag as needed } ], "combineResults": "true", "query": "*", # Use wildcard to match all "count": 500, # Number of datasets to retrieve "offset": 0, # Starting offset for pagination "sort": { "isRelevance": "false", "fieldSorts": [ { "field": "create_date", "sortOrder": "DESC" # Sort by creation date } ] } } # Make the API request to search for datasets response = requests.post(url, json=payload, headers=headers) # Check if the request was successful if response.status_code == 200: # Print the full response to understand its structure response_data = response.json() print(json.dumps(response_data, indent=2)) # Pretty-print the JSON response else: print(f"Failed to fetch datasets: {response.status_code} - {response.text}")
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1 -
This is great! Thanks for sharing your code! One small enhancement you can make is to use an Account to store your developer token so that it's not in plain text in your workbook
https://domo-support.domo.com/s/article/36004740075?language=en_US#use_accounts
0 -
Thanks for the note. When I'm debugging code, I often use a temporary token with a quick expiration. One odd thing I found about the API, it doesn't contain information in the field dataLastUpdated.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
In regard to the dataLastUpdated, I'm seeing the same thing on my side. A workaround might be to add last_updated to the filter of your search.
"filters": [
{
"filterType": "facetValue",
"field": "tag",
"value": "Your_Tag_Goes_Here" # Replace with your tag as needed
},
{
"field": "last_updated",
"filterType": "numeric",
"longNumber": 1727755200000,
"operator": "GT"
}
]Above is your tag search with Last Run: After 10/01/2024 added to it
0 -
I assume last updated is when the code was last update, not the data. I need to know the code ran and data was populated via the API it was calling.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
It's amazing to me that after 2 years nothing has been added to the Dataset API to allow retrieving a Dataset by a tag. We ran into the same problem and the way that we had to solve it was to query the Domo web UI API (as mentioned above and in the linked post), then grab the dataset ID from there and use that to retrieve the dataset(s) using the Dataset API. Seems kinda convoluted.
It seems like it would be a nice enhancement to the Dataset API would be either (or both):
- Add an array of tags to the information returned about a dataset.
- Allow getting a datasets by tags.
Tags are so useful and integral on the UI side of things and that inevitably follows through to automation API side of things.
Just my 2 cents… Glad you found a solution.
0 -
@jlrosenlof - The API has the tag list as an array. In my code above, I'm only pulling based on the tag "Jupyter". But the API does show an array for the datasets that have more than one tag.
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
I'm still doing a bit of work. But my end goal is to create a blank brick that summarizes my API and Jupyter calls as a custom made Gantt chart. Basically because I couldn't figure out how to do it with a Domo chart. I want to visually see which tasks I have scheduled at specific times to ensure hand-offs and to consolidate the total time of processing.
Using fake data it looks like this:** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive