# Downloading Data

Export stored Harvest Data for analysis or offline processing.

To download data from Harvest Data, first open the **Harvest Data** screen for one or more devices by following the instructions in the [Viewing Data](https://docs.soracom.io/en/services/harvest/viewing-data) documentation.

Below the chart, click the **Download ▾** menu, then select the data format you want to download.

Once the data has been prepared, your download will begin automatically.

> [!WARNING]
>
> You can only download up to 1,000 lines of data at a time.
>
> To extract more data, follow the steps in the **Programmatic Usage** section below.

> [!WARNING]
>
> Note that all Harvest Data access is counted as a data export when the [Extended Data Retention](https://docs.soracom.io/en/services/harvest/configuration#extended-data-retention) option is enabled. This includes viewing data in the User Console, requesting data via the Soracom API/CLI, and accessing data through Soracom Lagoon. Refer to the [Pricing & Fee Schedule](https://docs.soracom.io/en/pricing#soracom-harvest-data) for more information..

## Programmatic Usage

You can also use the Soracom API or Soracom CLI to download data.

### Soracom API

To access the Soracom API, first use the [**auth**](https://docs.soracom.io/en/api#!/Auth/auth) API to obtain an API Key and Token. Refer to the [**API Usage Guide**](https://docs.soracom.io/en/developers/soracom-api) for instructions on how to use the API Key and Token in API requests.

Then, use the [getDataEntries](https://docs.soracom.io/en/api#!/DataEntry/getDataEntries) API to retrieve data uploaded from a subscriber to Harvest Data, specifying the subscriber IMSI in the request URL:

**Global**

```bash
curl -X GET \
  -H "X-Soracom-API-Key: <MY-API-KEY>" \
  -H "X-Soracom-Token: <MY-TOKEN>" \
  -H "Accept: application/json" \
  https://g.api.soracom.io/v1/data/Subscriber/<IMSI>
```

**Japan**

```bash
curl -X GET \
  -H "X-Soracom-API-Key: <MY-API-KEY>" \
  -H "X-Soracom-Token: <MY-TOKEN>" \
  -H "Accept: application/json" \
  https://jp.api.soracom.io/v1/data/Subscriber/<IMSI>
```

Data will be returned in JSON format:

```json
[
  {
    "resourceType": "Subscriber",
    "resourceId": "<IMSI>",
    "category": "myCategory",
    "time": 1479350871000,
    "contentType": "application/json",
    "content": "{\"temperature\":20}"
  },
  {
    "resourceType": "Subscriber",
    "resourceId": "<IMSI>",
    "category": "myCategory",
    "time": 1479350881000,
    "contentType": "application/json",
    "content": "{\"temperature\":25}"
  },
  {
    "resourceType": "Subscriber",
    "resourceId": "<IMSI>",
    "category": "myCategory",
    "time": 1479350891000,
    "contentType": "application/json",
    "content": "{\"temperature\":20}"
  }
]
```

You can use `from` (Unix milliseconds), `to` (Unix milliseconds), `sort` (`asc` or `desc`), and `limit` query parameters in the request URL, such as `https://g.api.soracom.io/v1/data/Subscriber/<IMSI>?from=<FROM>&to=<TO>&sort=asc&limit=100` in order to control the range of data.

You can also use the [getDataEntriesByCategory](https://docs.soracom.io/en/api#!/DataEntry/getDataEntriesByCategory) API to retrieve the data by filtering the category name specified in your group configuration.

### Soracom CLI

To use the Soracom CLI, you must first configure it to authenticate with your account information, authorization key, or SAM user credentials.

Then, run the following command to retrieve data uploaded from a subscriber to Harvest Data:

**Global**

```bash
soracom data get-entries --resource-type "Subscriber" --resource-id "<IMSI>" --coverage-type g
```

**Japan**

```bash
soracom data get-entries --resource-type "Subscriber" --resource-id "<IMSI>" --coverage-type jp
```

The CLI will return data in JSON format following the API example above.

Similar to the API usage, you can use the `--from`, `--to`, `--sort`, and `--limit` flags to control the range of data.
