# Data export API

### Fetching Nested Records

V3 is designed for retrieving larger datasets but limits the nested entities in the response. Related entities with a 1-to-1 relationship are generally included with basic details, while 1-to-many relationships are excluded and require separate fetches.

**Nested Query URLs**\
To obtain related entities, use the nested URL paths in the response. For example, a subscription response provides paths to fetch metrics, products, discounts and milestones for the subscription in separate requests. This is useful when records related to a specific entity are needed, such as:

```json
{
    "id": "af2d33b1-a614-556a-9cd3-08dd4760a5c7",
    "created": "2025-02-08T17:00:14",
    ...
    "products": "/subscriptions/af2d33b1-a614-556a-9cd3-08dd4760a5c7/subscription-products",
    "discounts": "/subscriptions/af2d33b1-a614-556a-9cd3-08dd4760a5c7/discounts",
    "milestones": "/subscriptions/af2d33b1-a614-556a-9cd3-08dd4760a5c7/milestones",
    "metrics": "/subscriptions/af2d33b1-a614-556a-9cd3-08dd4760a5c7/metrics"
}
```

**Fetching Entities in Separate Queries**\
When syncing data to a data warehouse or BI systems, it can be more effective to fetch data in bulk, entity by entity. For example, use the /subscription endpoint to fetch all subscriptions, then a separate call to /Subscription-product-charges to fetch subscription charges. The relationship in this case is defined by the `orderId` In the subscription-charge response, a reference to the subscription's `id`.

### Pagination

Pagination can be managed using the `pageNumber` and `pageSize` query parameters.

* Some endpoints may have a maximum `pageSize` limit of 5000 records per request.
* If not specified, the default `pageSize` is 100.

```
https://api.younium.com/v3/Subscriptions?pageSize=5000&pageNumber=2
```

When retrieving multiple records, the response includes an `items` property with the records and a `nextPage` property indicating if more records are available. If the `nextPage` is absent, there are no more records to fetch. If no records exist, an empty list of items will be returned.

```json
{
    "items": [ {...} ],
    "nextPage": "/subscriptions?pageNumber=2&pagesize=200"
}
```

### Filters

#### Filter Application in API Queries

Filters are applied as query parameters. The API reference documentation lists the available filters for each endpoint.

#### **Modified After and Before Filters**

Some endpoints support `modifiedAfter` and `modifiedBefore` filters to fetch records from a specific time span. The `modifiedAfter` filter defaults to the previous month if not specified.

### NULL values <a href="#zlqpf" id="zlqpf"></a>

In the response schema, only fields with values are included in the JSON response body. Fields with null values are omitted.
