# Downloads

> Files and signed links, counted under fair use only when delivered; the download history.


## Download one file

<a id="assets.file"></a>`assets.file`

`GET /assets/{type}/{id}/file`

Scope: `download`

Fetches, verifies and returns the file, and records the download only after that, under the website's fair use; a file already downloaded is free again. Photos come at the account's size (1600×900 on a free account). Videos, sound packs and 3D kits answer 302 to a short-lived signed CDN URL: follow redirects. A video counts when its link is handed out, and a retry of the same video is free. Pack and kit ZIPs never count. Only GET fetches; HEAD answers 405 and counts nothing.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `type` | path | string | Yes | One of: photo, video, svg, svg_pack, brand, sound_effect, sfx_pack, 3d_model, 3d_kit. |
| `id` | path | string | Yes | A photo's slug, an SFX pack's slug, or any other item's uid, as the search card gives it. |
| `background` | query | string | No | SVGs, brands and SVG packs only. Defaults to the item's own. One of: original, transparent. |

### Responses

- `200` The file, as an attachment: a photo (JPEG or PNG), an SVG, a sound (WAV), or a ZIP (brands, SVG packs, 3D models).
- `302` A video, sound pack or 3D kit, at a signed CDN URL.
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Downloads the file under fair use. Videos, sound packs and 3D kits redirect to a signed CDN address.
# Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
curl -sS -L -OJ \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/assets/$ASSET_TYPE/$ASSET_ID/file" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Downloads the file under fair use. Videos, sound packs and 3D kits redirect to a signed CDN address.
# Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
import os
import re

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(
    f"{base}/assets/{os.environ['ASSET_TYPE']}/{os.environ['ASSET_ID']}/file",
    headers=headers,
    follow_redirects=True,
    timeout=60,
)
match = re.search(r'filename="?([^";]+)', r.headers.get("content-disposition", ""))
name = match.group(1) if match else os.environ["ASSET_ID"]
if r.status_code == 200:
    open(name, "wb").write(r.content)
print(r.status_code, r.headers.get("content-type"), len(r.content), "bytes", name if r.status_code == 200 else r.text)
```

**JavaScript**

```js
// Downloads the file under fair use. Videos, sound packs and 3D kits redirect to a signed CDN address.
// Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
import { writeFile } from "node:fs/promises";

const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/assets/${process.env.ASSET_TYPE}/${process.env.ASSET_ID}/file`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
const match = /filename="?([^";]+)/.exec(r.headers.get("content-disposition") ?? "");
const name = match ? match[1] : process.env.ASSET_ID;
const bytes = Buffer.from(await r.arrayBuffer());
if (r.status === 200) await writeFile(name, bytes);
console.log(r.status, r.headers.get("content-type"), bytes.length, "bytes", r.status === 200 ? name : bytes.toString());
```

## Signed download links for up to 20 items

<a id="downloads.store"></a>`downloads.store`

`POST /downloads`

Scope: `download`

A 10-minute link per item, for a person or a batch. No fair use is counted until a link is fetched; fetching it works like the file route. Each item found counts as one result card, as GET /assets/{type}/{id} does. One item that cannot be downloaded is refused on its own, and the others still get their links.

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `items` | array of object | Yes | At least 1 items, At most 20 items. |

### Responses

- `200` One link or refusal per item, in order. ([`List`](https://imgsearch.com/developers/reference/schemas.md#List))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# A 10-minute download link per item; nothing counts until a link is fetched.
# Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/downloads" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<EOF
{
  "items": [
    {
      "type": "$ASSET_TYPE",
      "id": "$ASSET_ID"
    }
  ]
}
EOF
```

**Python**

```python
# A 10-minute download link per item; nothing counts until a link is fetched.
# Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/downloads",
    headers=headers,
    json={"items": [{"type": os.environ["ASSET_TYPE"], "id": os.environ["ASSET_ID"]}]},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// A 10-minute download link per item; nothing counts until a link is fetched.
// Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/downloads`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ items: [{ type: process.env.ASSET_TYPE, id: process.env.ASSET_ID }] }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "list",
    "has_more": false,
    "next_cursor": null,
    "data": [
        {
            "status": "ready",
            "url": "https://imgsearch.com/api/v2/files/EXAMPLE-SIGNED-LINK",
            "expires_at": "2026-11-26T09:55:42Z",
            "file_name": "majestic-red-fox-in-a-frosty-landscape-141601326.jpg",
            "download": {
                "fair_use_units": 0,
                "free": true,
                "counter": "files"
            },
            "object": "download_link",
            "type": "photo",
            "id": "majestic-red-fox-in-a-frosty-landscape-141601326",
            "error": null
        }
    ]
}
```

## The account's download history, newest first

<a id="account.downloads"></a>`account.downloads`

`GET /account/downloads`

Scope: `download`

Every surface's downloads (web, api, mcp); rows from before the API have surface null. svg covers brands.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `type` | query | string | No | One of: photo, video, svg, sound_effect, 3d_model. |
| `limit` | query | integer | No | Items per page. |
| `cursor` | query | string | No | The next_cursor of the previous page, as it came. It works only for the same list, filter and account. |

### Responses

- `200` One page of the history. ([`List`](https://imgsearch.com/developers/reference/schemas.md#List))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# The account's last ten downloads, from every surface.
# Needs IMGSEARCH_API_KEY.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/account/downloads?limit=10" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# The account's last ten downloads, from every surface.
# Needs IMGSEARCH_API_KEY.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(f"{base}/account/downloads", headers=headers, params={"limit": 10}, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// The account's last ten downloads, from every surface.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/account/downloads?limit=10`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "list",
    "data": [
        {
            "object": "download",
            "type": "photo",
            "id": "majestic-red-fox-in-a-frosty-landscape-141601326",
            "title": "Majestic red fox in a frosty landscape",
            "downloaded_at": "2026-11-07T14:59:38Z",
            "charged": true,
            "surface": "api"
        }
    ],
    "has_more": false,
    "next_cursor": null
}
```

## Fetch a signed download link

<a id="files.show"></a>`files.show`

`GET /files/{token}`

No key needed

The link is the credential: it works for 10 minutes, for the account and the key or token that asked for it, and stops when either is revoked. Fetching it downloads and counts exactly as the file route does. Only GET fetches; HEAD answers 405 and counts nothing.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `token` | path | string | Yes |  |

### Responses

- `200` The file, as an attachment: a photo (JPEG or PNG), an SVG, a sound (WAV), or a ZIP (brands, SVG packs, 3D models).
- `302` A video, sound pack or 3D kit, at a signed CDN URL.
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Fetches a signed download link (a url from POST /downloads) and saves it under the download's file_name. The link is
# the credential. Videos, sound packs and 3D kits answer 302 to a signed CDN address, which -L follows.
# Needs LINK_URL and FILE_NAME.
name="${FILE_NAME:-download}"
status=$(curl -sS -L -o "$name" -w '%{http_code}' "$LINK_URL")
echo "$status $name"
if [ "$status" != 200 ]; then
  cat "$name"; rm -f "$name"
fi
```

**Python**

```python
# Fetches a signed download link (a url from POST /downloads) and saves it under the download's file_name. The link is
# the credential. Videos, sound packs and 3D kits answer 302 to a signed CDN address, which this follows.
# Needs LINK_URL and FILE_NAME.
import os

import httpx

name = os.environ.get("FILE_NAME") or "download"
r = httpx.get(os.environ["LINK_URL"], follow_redirects=True, timeout=60)
if r.status_code == 200:
    open(name, "wb").write(r.content)
print(r.status_code, r.headers.get("content-type"), len(r.content), "bytes", name if r.status_code == 200 else r.text)
```

**JavaScript**

```js
// Fetches a signed download link (a url from POST /downloads) and saves it under the download's file_name. The link is
// the credential. Videos, sound packs and 3D kits answer 302 to a signed CDN address, which fetch follows.
// Needs LINK_URL and FILE_NAME.
import { writeFile } from "node:fs/promises";

const name = process.env.FILE_NAME || "download";
const r = await fetch(process.env.LINK_URL);
const bytes = Buffer.from(await r.arrayBuffer());
if (r.status === 200) await writeFile(name, bytes);
console.log(r.status, r.headers.get("content-type"), bytes.length, "bytes", r.status === 200 ? name : bytes.toString());
```
