> For the complete documentation index, see [llms.txt](https://api.dataloy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.dataloy.com/api-release-8.6/user-guides/enterprise-functionalities/sub-queries.md).

# 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**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api.dataloy.com/api-release-8.6/user-guides/enterprise-functionalities/sub-queries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
