Sivaji Posted September 22, 2021 Share Posted September 22, 2021 I was wondering if we can do a Data search a signal (formula/condition) by its ID? Use-case: for validating IDs used in the DataLab project created by others. Link to comment Share on other sites More sharing options...
Thorsten Vogt Posted September 22, 2021 Share Posted September 22, 2021 Hi Sivaji, actually you can search by ID using either the API/SDK or writing some code in Data Lab. In terms of API/SDK you should try the /items/{id} endpoint: In case an item exists you will get HTTP 200 as status code and details about the item in the response body. If the item does not exist you receive an HTTP 404 status code. In Data Lab you can use spy.search for this. In case of non-existing item spy.search throws an error, therefore I am iterating over the IDs: item_ids = ["FCC9F932-B328-4A7E-9300-A17331519C93", "BF769E50-B93A-4C1A-81FD-326F488CD1E1", "64832183-D97F-4E5C-81A1-C466C494DC3A", "64832183-D97F-4E5C-81A1-C466C494DC6A", "FCC9F932-B328-4A7E-9300-A17331519C91"] item_infos = [] for item_id in item_ids: try: data = spy.search({"ID": item_id}) item_infos.append("Item with ID " + item_id + " exists") except: item_infos.append("Item with ID " + item_id + " does not exist") print (item_infos) Output looks like this: ['Item with ID FCC9F932-B328-4A7E-9300-A17331519C93 exists', 'Item with ID BF769E50-B93A-4C1A-81FD-326F488CD1E1 exists', 'Item with ID 64832183-D97F-4E5C-81A1-C466C494DC3A does not exist', 'Item with ID 64832183-D97F-4E5C-81A1-C466C494DC6A exists', 'Item with ID FCC9F932-B328-4A7E-9300-A17331519C91 does not exist'] Be aware that both methods return all types of items. In case you want to search only for signals or conditions you have to make some adjustments like evaluating the returned data. Hope this helps. Regards, Thorsten Link to comment Share on other sites More sharing options...
Sivaji Posted September 22, 2021 Author Share Posted September 22, 2021 Thanks, Thorsten. I was looking for something like the below search and look at the signal trend. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now