> For the complete documentation index, see [llms.txt](https://docs.partssource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.partssource.com/getting-started/core-concepts/including-related-data.md).

# Including Related Data

Use the include query parameter to fetch related data alongside search results

Some search endpoints support an `include` query parameter that lets you fetch related data in a single request, avoiding extra API calls. Without `include`, related properties are **omitted entirely** from the response. With it, the requested relationships are populated inline.

***

## Syntax

Pass a comma-separated list of relationship names as the `include` query parameter:

```
GET /{resource}/search?q=<query>&include=<relationship1>,<relationship2>
```

Values are **case-sensitive** and must match the relationship names documented for each endpoint. Unrecognized values are silently ignored.

***

## Supported Endpoints

### GET /orders/search

| Relationship   | Description                                                             |
| -------------- | ----------------------------------------------------------------------- |
| `lineItems`    | Line item details for each order (part number, quantity, price, status) |
| `shippingInfo` | Shipping details for each order (address, carrier, service level)       |

**Without `include`** — `lineItems` and `shippingInfo` are not present in the response:

```json
{
  "data": {
    "orders": [
      {
        "orderId": 5499760,
        "companyId": 12345,
        "requesterId": 500,
        "poNumber": "PO-456",
        "requesterName": "Jane Smith",
        "orderDate": "2026-01-15T10:30:00Z",
        "lastUpdated": "2026-01-16T08:00:00Z",
        "total": 249.99,
        "shippingMethod": "GROUND"
      }
    ],
    "pagination": { "total": 1, "limit": 50, "offset": 0, "hasMore": false }
  }
}
```

**With `include=lineItems,shippingInfo`:**

```
GET /orders/search?q=companyId:12345 AND createdDate>="2026-01-01" AND createdDate<"2026-02-01"&include=lineItems,shippingInfo&limit=20
```

```json
{
  "data": {
    "orders": [
      {
        "orderId": 5499760,
        "companyId": 12345,
        "requesterId": 500,
        "poNumber": "PO-456",
        "requesterName": "Jane Smith",
        "orderDate": "2026-01-15T10:30:00Z",
        "lastUpdated": "2026-01-16T08:00:00Z",
        "total": 249.99,
        "shippingMethod": "GROUND",
        "lineItems": [
          {
            "lineId": 9000001,
            "partNumber": "MOT-1234",
            "requestedPartNumber": "MOT-1234-A",
            "replacementPartNumber": "MOT-1234-B",
            "poNumber": "PO-456",
            "description": "Replacement motor assembly",
            "quantity": 1,
            "price": 249.99,
            "extendedPrice": 249.99,
            "statusName": "Ordered"
          }
        ],
        "shippingInfo": [
          {
            "shippingDocId": 7000001,
            "lineItemIds": [9000001],
            "attentionTo": "Jane Smith",
            "address1": "100 Medical Center Dr",
            "city": "Aurora",
            "state": "IL",
            "zip": "60505",
            "country": "US",
            "carrierName": "FedEx",
            "serviceLevel": "Ground"
          }
        ]
      }
    ],
    "pagination": { "total": 1, "limit": 50, "offset": 0, "hasMore": false }
  }
}
```

You can include one or both relationships:

```
GET /orders/search?q=companyId:12345&include=lineItems
GET /orders/search?q=companyId:12345&include=shippingInfo
GET /orders/search?q=companyId:12345&include=lineItems,shippingInfo
```

***

## Performance Considerations

Including related data increases response size and may add latency. Only request relationships you need. For large result sets, consider:

* Using a narrower search query to reduce the number of orders returned
* Reducing the `limit` parameter when including related data
* Omitting `include` when you only need order-level summary information


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.partssource.com/getting-started/core-concepts/including-related-data.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
