> For the complete documentation index, see [llms.txt](https://en-api.decisiontele.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://en-api.decisiontele.com/esim-api/usage/remaining-data.md).

# Remaining Data

Calculate the remaining data allowance for the relevant package assignment.

### From eSIM assignment fields

```
remainingData = package.dataLimit - usageValue
```

| Value                                 | Example     |
| ------------------------------------- | ----------- |
| Total allowance (`package.dataLimit`) | 3 GB        |
| Used data (`usageValue`)              | 1.206621 GB |
| Remaining data                        | 1.793379 GB |

Convert numeric strings such as `usageValue` to numbers before subtraction. Use consistent units for both values.

### From the dedicated usage endpoint

```
remainingTraffic = rate_group_allowance - rate_group_usage
3 - 1.206621 = 1.793379 GB
```

Read the unit from `rate_group_allow_qtyp`. Calculate per relevant rate group; do not add or subtract values in different units without conversion.

Remaining data alone does not establish whether a package can be used. Check the assignment status, usage status, activation date, and expiration date.

Usage is near real-time and may have a short mobile-network reporting delay. When several packages are assigned to an eSIM, calculate the balance for each relevant assignment instead of assuming the first array entry is current.
