# hematite REST API overview

The hematite REST API at a glance: the base address, the code, message and data every answer has, sending data, ids, dates, enums, paging and limits.

hematite's REST API is what the website and ShareX use: upload, list and edit images, folders, shares, comments and domains. Every endpoint is in the [API reference](https://hematite.gg/docs/developers/reference/images), made from the API's own schemas. From JavaScript or TypeScript, [the SDK](https://hematite.gg/docs/developers/sdk) makes the same calls for you.

## The address

Every endpoint is under one base address:

```text label="Base address"
https://api.hematite.gg/v1
```

An endpoint's path follows it: `GET /images/:imageId` is `https://api.hematite.gg/v1/images/1`. A part written `:imageId` stands for a value, here the image's id.

## A first request

Badges need no token, so this works as it is:

```bash
curl https://api.hematite.gg/v1/badges
```

Most endpoints need you signed in: send your token in the `Authorization` header. [Authentication](https://hematite.gg/docs/developers/authentication) says where a token comes from, and [Sign in with hematite](https://hematite.gg/docs/developers/oauth) how an app gets one. Every endpoint in the reference has a **Try it** tab that sends it as you, once you've signed in to the docs.

```bash
curl https://api.hematite.gg/v1/images/1 \
  -H "Authorization: $HEMATITE_TOKEN"
```

## Every answer has the same shape

The body is JSON with three fields: `code`, `message` and `data`. What the endpoint returns is in `data`; the reference lists its fields for each endpoint.

```json title="200 OK"
{
  "code": "SUCCESS",
  "message": "OK",
  "data": {
    "id": 1,
    "title": "Clutch on Ascent",
    "visibility": "Unlisted"
  }
}
```

`message` is the status in words (`OK`, `Created`). An error keeps the shape, with its own `code` and `message`: see [errors and limits](https://hematite.gg/docs/developers/errors).

## Sending data

- **JSON bodies** go with `Content-Type: application/json`.
- **Uploads** are `multipart/form-data`, the image in the field `file`: see [`POST /images`](https://hematite.gg/docs/developers/reference/images#post-images).
- **Query parameters** are written as text and read as their type: `?limit=20&partial=true`.

## Values

- **Ids** are numbers.
- **Dates** are ISO 8601 strings in UTC: `2026-11-10T18:24:00.000Z`.
- **Sizes** are bytes: a `size` of `2457600` is 2.4 MB.
- **Enums are strings,** the value's name: an image's `visibility` is `Unlisted`, `Public` or `Private`. The reference lists every enum's values where it's used.
- **Colours** are `#` and six hex digits, lowercase: a folder's `color` is `#c4d4e0`. Send them so; six digits without the `#` are still taken for now.

> **Note: Numbers for enums**
>
> Up to SDK 0.0.9 enums were numbers. Inputs still accept the old numbers for
> now, so older clients keep working; send the names.

## Paging

Lists that can grow long take `limit` and `offset`: `limit` is how many to return (100 unless you say), `offset` how many to skip from the start (0). Images come newest first.

```bash
curl "https://api.hematite.gg/v1/users/1/images?limit=20&offset=40" \
  -H "Authorization: $HEMATITE_TOKEN"
```

That's the third page of 20. A page shorter than `limit` is the last one. The image and user searches take the same two fields in their body.

## Limits

Every endpoint has a rate limit, per address: 120 a minute unless its reference entry says otherwise. How much you can store depends on your plan: see [pricing](https://hematite.gg/pricing). [Errors and limits](https://hematite.gg/docs/developers/errors) has the details.
