Hey all,
Shotgrid entity_type are really helpful to fetch data from Shotgun web.
Entity_type, Filters and fields are referred from this post. It is an amazing post, I would recommend you to read it- http://yamagishi-2bit.blogspot.com/2020/01/shotgun-shotgun-python-api-quickstart.html
One of my Colleagues from my studio Michael H, gave alot of code snippets to understand this topic.
You’ll find i have mentioned entity_type, filters and fields in the earlier post – https://digdeeperts.wordpress.com/2023/09/22/shotgrid-how-to-access-api/
This topic is related to CRUD method,
once we get access to api with the below code, we’ll try to find some data regarding the show, shot, seq, etc.
sg = shotgun_api3.Shotgun(SERVER_PATH, login=LOGIN, password=PASSWORD)
Shotgun.find(entity_type, filters, fields=None, order=None, filter_operator=None, limit=0, retired_only=False, page=0, include_archived_projects=True, additional_filter_presets=None)
Shotgun.find(entity_type, filters, fields=None
) first 3 arguments will help you get almost whatever you’re looking for from Shotgun web. (arguments – entity_type, filters, fields)
Question is – How do we find the entity_type?
from pprint import pprint
entities = sg.schema_entity_read() # entity_type
pprint(entities)
As per the docs you can provide the show entity or project entity dictionary as argument as well – {'type': 'Project', 'id': 3}
incase you don’t know the project id, you can just run the sg.find to list type project and its id
full code
import shotgun_api3
from pprint import pprint
SERVER_PATH = 'https://<company>.shotgunstudio.com' #shotgun company link
LOGIN = 'bghuntla'
PASSWORD = 'password'
sg = shotgun_api3.Shotgun(SERVER_PATH, login=LOGIN, password=PASSWORD)
if __name__ == '__main__':
entities = sg.schema_entity_read().keys() # entity_type
pprint(entities)
print(sg.find('Project', [], []))
print(sg.find('Shot, [], [])) # examples
print(sg.find('Status', [], [])) # examples
[{'type': 'Project', 'id': 4}, {'type': 'Project', 'id': 63}, {'type': 'Project', 'id': 64}, {'type': 'Project', 'id': 65}, {'type': 'Project', 'id': 66}, {'type': 'Project', 'id': 67}, {'type': 'Project', 'id': 70}, {'type': 'Project', 'id': 75}, .......
I have consolidated of the important aspects to get started with find and entity_type.
Useful links