Shotgun subquery request


I couldn’t figure from the documentation how to make a query that gets me in one single requests all versions of a project and the shots data. The entity element gives shot name and id but I would like to get more of the Shot entity fields in there.

This should be an easy thing with usual database but through Shotgun API I can’t find the syntax to do that sort of request in one go. Can anyone spare an example of what the fields parameter would be when calling the find() method ?



Hi @chistof, thanks for posting, and welcome to the :shotgun: forums!

You can reference fields from a linked entity using dot syntax, like this:
This references the id field on the Pipeline Step entity record, which the Task entity record listed in the sg_task field is linked to.

To break it down a bit further:
sg_task is a field (perhaps on a Version entity record) that links to a Task entity record
Task references the entity type of this linked entity record
step is a field on Tasks, linking to a Pipeline Step entity record
Step references the entity type of this next linked entity record
id is the unique ID field on the linked Pipeline Step entity record

See the API Reference doc on Shotgun.find for more details.

To get a field from a Shot record linked to a Version, you might do a find() on the Version entity that includes this field reference:

Hopefully that gets you the data you need. Beyond that, if there’s no direct linkage from the entity you are querying, you’d need to do a separate call to find data from another entity.


Perfect! Thanks!