# Meta

> The API itself, its status and this document.


## What this API is and where its documents are

<a id="index"></a>`index`

`GET /`

No key needed

### Responses

- `200` The API's index. ([`Api`](https://imgsearch.com/developers/reference/schemas.md#Api))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# What this API is and where its documents are.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}"
```

**Python**

```python
# What this API is and where its documents are.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")

r = httpx.get(f"{base}", timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// What this API is and where its documents are.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}`);
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "api",
    "name": "ImgSearch API",
    "version": "2.0.0",
    "docs_url": null,
    "openapi_url": "https://imgsearch.com/api/v2/openapi.json",
    "status_url": "https://imgsearch.com/api/v2/status",
    "authentication": "API key (Account → API keys) or OAuth 2.1 with PKCE, as Authorization: Bearer"
}
```

## Whether the AI Generator takes work now, and which models are paused

<a id="status"></a>`status`

`GET /status`

No key needed

### Responses

- `200` The current status. Cached for 15 seconds. ([`Status`](https://imgsearch.com/developers/reference/schemas.md#Status))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Whether the AI Generator takes work now, and which models are paused.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/status"
```

**Python**

```python
# Whether the AI Generator takes work now, and which models are paused.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")

r = httpx.get(f"{base}/status", timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Whether the AI Generator takes work now, and which models are paused.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/status`);
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "status",
    "api": {
        "version": "2.0.0"
    },
    "generator": {
        "enabled": true,
        "workers": true
    },
    "models_paused": []
}
```

## This document as JSON

<a id="openapi.json"></a>`openapi.json`

`GET /openapi.json`

No key needed

### Responses

- `200` The OpenAPI document.
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Saves the OpenAPI document as openapi.json.
curl -sS -o openapi.json \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/openapi.json"
```

**Python**

```python
# Saves the OpenAPI document as openapi.json.
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")

r = httpx.get(f"{base}/openapi.json", timeout=60)
if r.status_code == 200:
    open("openapi.json", "wb").write(r.content)
print(r.status_code, len(r.content), "bytes")
```

**JavaScript**

```js
// Saves the OpenAPI document as openapi.json.
import { writeFile } from "node:fs/promises";

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

const r = await fetch(`${base}/openapi.json`);
const bytes = Buffer.from(await r.arrayBuffer());
if (r.status === 200) await writeFile("openapi.json", bytes);
console.log(r.status, bytes.length, "bytes");
```

## This document as YAML

<a id="openapi.yaml"></a>`openapi.yaml`

`GET /openapi.yaml`

No key needed

### Responses

- `200` The OpenAPI document, byte for byte as published.
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Saves the OpenAPI document as openapi.yaml.
curl -sS -o openapi.yaml \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/openapi.yaml"
```

**Python**

```python
# Saves the OpenAPI document as openapi.yaml.
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")

r = httpx.get(f"{base}/openapi.yaml", timeout=60)
if r.status_code == 200:
    open("openapi.yaml", "wb").write(r.content)
print(r.status_code, len(r.content), "bytes")
```

**JavaScript**

```js
// Saves the OpenAPI document as openapi.yaml.
import { writeFile } from "node:fs/promises";

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

const r = await fetch(`${base}/openapi.yaml`);
const bytes = Buffer.from(await r.arrayBuffer());
if (r.status === 200) await writeFile("openapi.yaml", bytes);
console.log(r.status, bytes.length, "bytes");
```
