# API Filter path overview

**URL:** <https://community.shotgridsoftware.com/t/api-filter-path-overview/9834>\
**Category:** Flow Production Tracking\
**Tags:** api, filters\
**Created:** [August 28, 2020, 7:07am UTC](https://community.shotgridsoftware.com/t/api-filter-path-overview/9834 "2020-08-28T07:07:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChristianHelmich](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/christianhelmich/32/3199_2.png) [@ChristianHelmich](https://community.shotgridsoftware.com/u/ChristianHelmich)\
**Post date:** [August 28, 2020, 7:07am UTC](https://community.shotgridsoftware.com/t/api-filter-path-overview/9834/1 "2020-08-28T07:07:06Z")

</div>

Hi,

I haven’t found information about the filter path to provide to a GET request, and I was wondering if there is an overview over the types, or a way to get the correct path.

E.g. with the request below, the path I’m using in the filter is “project.Project.name”.

```
curl -X GET https://dena901.shotgunstudio.com/api/v1/entity/CustomEntity03\?fields\=\*\&filter\[project.Project.name\]\=$ProjectName \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer $AuthToken'

```

Cheers.

---

<div class="post-metadata">

**Author:** ![jing.liu](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/jing.liu/32/888_2.png) [@jing.liu](https://community.shotgridsoftware.com/u/jing.liu)\
**Post date:** [August 28, 2020, 8:00am UTC](https://community.shotgridsoftware.com/t/api-filter-path-overview/9834/2 "2020-08-28T08:00:14Z")

</div>

Hi @ChristianHelmich,

Here is [detail of filtering](https://developer.shotgunsoftware.com/rest-api/#filtering). Is this you are looking for?

```auto
curl -X GET https://yoursite.shotgunstudio.com/api/v1/entity/assets?filter[sg_status_list]=ip&filter[sg_asset_type]=Prop,Character,Environment&filter[shots.Shot.code]=bunny_010_0020 \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json'

```

Thanks

Loney

---

<div class="post-metadata">

**Author:** ![ChristianHelmich](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/christianhelmich/32/3199_2.png) [@ChristianHelmich](https://community.shotgridsoftware.com/u/ChristianHelmich)\
**Post date:** [August 28, 2020, 2:20pm UTC](https://community.shotgridsoftware.com/t/api-filter-path-overview/9834/3 "2020-08-28T14:20:17Z")

</div>

Err, thanks but that’s not really what I’m looking for. What I search is the part you put in the filter brackets, e.g. for `filter[shots.Shot.code]` the `shots.Shot.code` part.

Is this information I can get from the schema by querying as explained below?  
[https://developer.shotgunsoftware.com/rest-api/#read-schema-for-all-entities](https://developer.shotgunsoftware.com/rest-api/#read-schema-for-all-entities)

Cheers.

---

<div class="post-metadata">

**Author:** ![tony](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tony/32/197_2.png) [@tony](https://community.shotgridsoftware.com/u/tony)\
**Post date:** [August 28, 2020, 6:18pm UTC](https://community.shotgridsoftware.com/t/api-filter-path-overview/9834/6 "2020-08-28T18:18:37Z")

</div>

Hey Christian!

If I understand your question correctly, you’re looking for a way to navigate from one entity to another via the filter?

Essentially, the paths that exist do so because of the presence of linked fields on an entity. In your example, it’s easy to get an asset’s project by looking at `project.Project.name`.

In regards to the notation, here’s a breakdown in case you haven’t grokked it yet:

1. `project`: for the entity you’re linking through, its entity field whose name is `project`. In your case, it’s the Asset field called `project`.
2. `Project`: an entity field can link through multiple kinds of entities (though it doesn’t always), so here we declare what kind of entity we’re looking for. In this case, a Project entity.
3. `name`: for the Project entity, we’re looking to filter on its name, and that field is obviously called `name`.

So your query is asking for all Assets whose Project’s name is `$ProjectName`.

If you want to construct other linked field queries, you’d need to follow a path of linked entity fields in order to arrive at your destination. If two entities aren’t linked by an entity field, you won’t be able to get from one to the other.

You’re correct that you can infer relationships by reading the schema, but there’s a torrent of information to digest and it can be a little hard to sift through to what you need. Here’s the result of a schema field read for the Asset’s `project` field:

```auto
>>> sg.schema_field_read("Asset",'project')
{'project': {'mandatory': {'editable': False, 'value': False}, 'name': 
{'editable': True, 'value': 'Project'}, 'data_type': {'editable': False, 
'value': 'entity'}, 'entity_type': {'editable': False, 'value': 'Asset'}, 
'custom_metadata': {'editable': True, 'value': ''}, 'editable': 
{'editable': False, 'value': True}, 'ui_value_displayable': 
{'editable': False, 'value': True}, 'visible': {'editable': False, 
'value': True}, 'unique': {'editable': False, 'value': False}, 
'properties': {'default_value': {'editable': False, 'value': None}, 
'summary_default': {'editable': True, 'value': 'none'}, 'valid_types': 
{'editable': True, 'value': ['Project']}}, 'description': 
{'editable': True, 'value': ''}}}

```

important keys here are `data_type` and `valid_types`. `data_type` should be `entity` or `multi_entity`, you can follow those. `valid_types` will tell you what kind of entities can be linked to that field.

You can also use this ‘dot notation’ in the fields that you request. However, an important caveat: while you can filter through a multi-entity field, you can’t query the field data on a multi-entity field, because we can’t know _which_ entity you’re trying to query through (since there can be many).

for instance, this is valid:

```auto
# sg_task_group is an entity field that links to one Group that a Task 
# belongs to
>>> sg.find("Task",
    [['sg_sequence','is_not',None]],
    ['sg_task_group.Group.code'])
[{'type': 'Task', 'id': 9289, 'sg_task_group.Group.code': 'lavagroup'}]

```

but this is not:

```auto
# sg_supervisors is a multi-entity field that can belong 
# to multiple HumanUsers
>>> sg.find("Task",
    [['sg_supervisors','is_not',None]],
    ['sg_supervisors.HumanUser.name'])
[{'type': 'Task', 'id': 9289}]
# we don't get `HumanUser.name` back, because we can't know which 
# 'name' of the potentially multiple supervisors in that field 
# should be returned.

```

Also, if you want to know a little more about how linked entities work, we have a fantastic series of Producer Training videos, and this one specifically talks about the subject:

[![](https://global.discourse-cdn.com/shotgunsoftware/original/2X/6/63f31345870b774298607499280c30c401920e02.jpeg "Producer Training - Shotgun: Linking Entities") ](https://www.youtube.com/watch?v=ASRjM1e9Ld8)

I hope this helps!

---

<div class="post-metadata">

**Author:** ![tony](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tony/32/197_2.png) [@tony](https://community.shotgridsoftware.com/u/tony)\
**Post date:** [August 28, 2020, 7:04pm UTC](https://community.shotgridsoftware.com/t/api-filter-path-overview/9834/8 "2020-08-28T19:04:36Z")

</div>

Also, just for clarity, I’m changing the subject line from “REST API Filter path overview” to “API Filter path overview”, since it’s not actually a REST-specific topic 🙂

---

<div class="post-metadata">

**Author:** ![ChristianHelmich](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/christianhelmich/32/3199_2.png) [@ChristianHelmich](https://community.shotgridsoftware.com/u/ChristianHelmich)\
**Post date:** [August 29, 2020, 8:50am UTC](https://community.shotgridsoftware.com/t/api-filter-path-overview/9834/10 "2020-08-29T08:50:38Z")

</div>

Thanks. This helps a lot.
