# Download API — Download Samples from Spectra Analyze

> Download analyzed samples from Spectra Analyze to local storage. GET /api/samples/{hash}/download/ returns password-protected ZIP files.

## Download samples from Spectra Analyze to local storage

```
GET /api/samples/{hash_value}/download/
```

Download a sample from Spectra Analyze to the local storage (compatible with modern ZIP tools such as `unzip` 6.00+, Python's `zipfile`, 7-Zip, or `bsdtar`)

### Request Format

**Request Parameters**

| NAME       | REQUIRED | DESCRIPTION                                                  | TYPE          |
| :--------- | :------- | :----------------------------------------------------------- | :------------ |
| hash_value | Required | Hash of the sample to download. Only one hash can be submitted in one request. Supported hash types: SHA1, SHA256, SHA512, MD5 | path, string  |
| fetch      | Optional | If this parameter is provided in the request, samples not available locally will be downloaded from Spectra Intelligence, provided they are available and there’s enough free disk space on the appliance. Once downloaded, samples will be submitted for analysis on Spectra Analyze and downloaded to local storage. | query, string |

**Request Examples**

**cURL**

```bash
# Add --insecure before the URL if you are using a self-signed SSL certificate
curl -X GET 'https://appliance.example.com/api/samples/988881adc9fc3655077dc2d4d757d480b5ea0e11/download/?fetch' \
  --header 'Authorization: Token exampletoken' \
  --output <FILENAME>
```

**Python**

```python

# Change the values of hash_value and token
hash_value = "examplehash"
token = "exampletoken"

# Change the hostname in the URL
url = f"https://appliance.example.com/api/samples/{hash_value}/download/"

headers = {
    "Authorization": f"Token {token}"
}

# Add verify=False in the request if you are using a self-signed SSL certificate
response = requests.get(url, headers=headers)

with open("filename", "wb") as f:
   f.write(response.content)
```

### Response Format

**Response Status Codes**

| CODE | DESCRIPTION                                                  |
| :--- | :----------------------------------------------------------- |
| 200  | Download is successful                                       |
| 404  | Sample not found on the appliance, and is not available for download in the Spectra Intelligence cloud (in case the `fetch` parameter was used) |
| 410  | Unable to retrieve sample content                            |
| 503  | The appliance storage space is close to being full. When there is less than 25% of free space on the disk, it is not possible to upload or download new samples until disk space is freed up. |
