# Sub queries

API 5.21 supports sub-queries during any API query.

The syntax is:

* filter=attributeName(OPERATOR)**{**&#x52;esourceName.attributeNam&#x65;**\[**&#x66;ilter\_&#x31;**]**,**\[**&#x66;ilter\_&#x32;**]**,**\[**&#x66;ilter\_&#x6E;**]}**

en-capsuling sub-queries between {} and the filters inside the sub-queries as list inside \[ ]

Here an example to get the ongoing cargoes of a list of business partners:

[http://dataloy.com/ws/rest/Cargo?filter=charterer.businessPartnerCode(IN)(133105,105882,123125,136200)\&filter=key(IN)({Cargo.key\[cargoPorts.portCall.eventLogs.event.eventCode(EQ)ARR](https://dataloy-cloud.atlassian.net/wiki/spaces/VMSINT/pages/1556250625/Sub+queries)]\[cargoPorts.portCall.eventLogs.eventLogDate(GT)2020-06-18T17:02:21]\[cargoPorts.cargoPortSequence(EQ)1],\[cargoPorts.reasonForCall.reasonForCall(EQ)D]})\&filter=key(IN)({Cargo.key\[cargoPorts.portCall.eventLogs.event.eventCode(EQ)DEP]\[cargoPorts.portCall.eventLogs.eventLogDate(LT)2020-06-18T17:02:21]\[cargoPorts.cargoPortSequence(EQ)1],\[cargoPorts.reasonForCall.reasonForCall(EQ)L]})

&#x20;

[http://dataloy.com/ws/rest/Cargo?filter=charterer.businessPartnerCode(IN)(133105,105882,123125,136200)\&filter=key(IN)(%7BCargo.key\[cargoPorts.portCall.eventLogs.event.eventCode(EQ)ARR](https://dataloy-cloud.atlassian.net/wiki/spaces/VMSINT/pages/1556250625/Sub+queries)]\[cargoPorts.portCall.eventLogs.eventLogDate(GT)2020-06-18T17:02:21]\[cargoPorts.cargoPortSequence(EQ)1],\[cargoPorts.reasonForCall.reasonForCall(EQ)D]%7D)\&filter=key(IN)(%7BCargo.key\[cargoPorts.portCall.eventLogs.event.eventCode(EQ)DEP]\[cargoPorts.portCall.eventLogs.eventLogDate(LT)2020-06-18T17:02:21]\[cargoPorts.cargoPortSequence(EQ)1],\[cargoPorts.reasonForCall.reasonForCall(EQ)L]%7D)

**The character { must be encoded with %7B and } with %7D**
