# LOLS Anti-Spam API (api.lols.bot)

Public HTTP API of **LOLS** — the anti-spam bot for Telegram groups ([@LolsBot](https://t.me/LolsBot)).
It tells whether a Telegram account is in the LOLS global ban list (spammers, scammers, spam-farm bots)
and gives account details for moderators and anti-spam tools.

- Base URL: `https://api.lols.bot`
- Machine-readable description (OpenAPI 3.1): <https://api.lols.bot/openapi.json> (YAML: <https://api.lols.bot/openapi.yaml>)
- Interactive docs: <https://api.lols.bot/>
- Russian version of this page: [api.md](api.md)

## Methods at a glance

| Method | Path | Key | Price | Purpose |
|---|---|---|---|---|
| GET | `/account?id=…` | no | free | Is the account banned? Call it when a member joins. |
| GET | `/lists` | no | free | URLs of downloadable ban list dumps (check a whole group at once). |
| GET | `/stats` | no | free | Overall numbers: banned accounts, scammers, chats with the bot. |
| GET, POST | `/accountFull?id=…` | yes | $0.012 ($0.024 with `withNames=1`) | Full account profile, as the account card in @LolsBot. |
| GET, POST | `/estimateRegistration?id=…` | yes | $0.0006 ($0.0012 with `precision=1`) | Registration date estimate. |
| GET, POST | `/resolveUsername?username=…` | yes | $0.06 | Live check: who owns a username right now. |

**Ids** are Telegram ids as in the Bot API: users and bots are positive, groups and channels negative
(`-100…` for supergroups and channels).

## Authentication (paid methods)

1. Open [@LolsBot](https://t.me/LolsBot) and send `/apikey`. The key looks like `lols_` + 40 hex characters.
   It is shown only once; "Change the key" issues a new one and revokes the old one immediately.
2. Pass the key in a header:
   - `X-Api-Key: lols_…`, or
   - `Authorization: Bearer lols_…`
3. A key in the URL or form (`key=`, `api_key=`) is rejected with `401`.

Payment: the price is set in USD and charged from your LolsBot balance in **L¢** (balance units, 1 L¢ = $1). Top up: <https://t.me/LolsBot?start=balance_topup>.
The same request (same key and parameters) repeated within 24 hours returns the cached answer for free (`billing.cached: true`).
Not charged: errors, `404` (no data), hidden profiles.

## Limits

| Limit | Scope | Answer |
|---|---|---|
| 60 requests/s (burst 100) | per client IP, all methods | `429` (HTML body) |
| 5 requests/s and 120 requests/min | per API key, paid methods | `429` `too_many_requests` |
| 30 invalid keys per 10 min | per client IP, paid methods | `429` `too_many_requests` until the window ends |
| Too many not-found lookups | per key, paid methods | `429` `daily_limit` |
| 200 live checks per day | per key, `/resolveUsername` | `429` `daily_limit` |

Recommended use: call `/account` for each joining member; for a bulk check download a dump from `/lists`
instead of calling `/account` in a loop. Respect the 5-minute cache of `/account` answers.

---

## GET /account — free account check

Checks one account against the LOLS global ban list. No key needed.

| Parameter | In | Required | Description |
|---|---|---|---|
| `id` | query | yes | Telegram id (int64; groups/channels negative). If repeated, the last value is used. |
| `quick` | query | no | Only the ban list is checked (fastest; no `when`, no statistics). Enabled by `?quick` or any value except `0`/`false`. |

Response `200 application/json` — fields that would be zero, `false` or unknown are omitted:

| Field | Type | Description |
|---|---|---|
| `ok` | boolean | Always `true`. |
| `user_id` | integer | The checked id. |
| `banned` | boolean | In the global ban list, a known scammer, or most recorded messages are spam (spam_factor > 50, or > 10 with more than 10 messages). |
| `when` | string | Ban time, format `YYYY-MM-DD HH:MM:SS UTC` (not ISO 8601). |
| `offenses` | integer | Spam messages recorded. |
| `spam_factor` | number | Share of spam among recorded messages, % (0–100). |
| `scammer` | boolean | Present only for known scammers (`true`). |
| `scamrsalert` | integer | Related post in <https://t.me/scamrsalert>. |

```bash
curl "https://api.lols.bot/account?id=1234567890"
```

```json
{"ok":true,"user_id":1234567890,"banned":false}
{"ok":true,"user_id":1234567890,"banned":true,"when":"2026-11-27 17:14:17 UTC"}
{"ok":true,"user_id":1234567890,"banned":true,"when":"2026-11-26 19:35:54 UTC","offenses":2,"spam_factor":100,"scammer":true,"scamrsalert":16926}
{"ok":true,"user_id":-1001234567890,"banned":true,"when":"2026-06-13 17:04:07 UTC"}
```

Errors:

| Code | Body | When |
|---|---|---|
| 400 | `{"ok":false,"error":"Argument \`id\` is required. See also https://api.lols.bot/"}` | no `id` |
| 500 | `{"ok":false,"error":"ERROR: You have an error in your SQL syntax; …"}` | `id` is not a number (fixed legacy text; validate `id` before calling) |
| 503 | `{"ok":false,"user_id":…,"error":"gban_unavailable","description":"Global ban list is temporarily unavailable, please retry later"}` | ban list temporarily unavailable; retry, never treat as "not banned" |
| 429 | HTML | per-IP limit |

Caching: answers carry `Expires` (about 5 minutes) and may be served from the CDN cache for that time.
For the Telegram link-preview robot (`User-Agent: TelegramBot (like TwitterBot)`) the method returns a PNG card followed by the JSON.

## GET /lists — ban list dumps

| Parameter | In | Required | Description |
|---|---|---|---|
| `ids` | query | no | If present (any value), the answer is an object keyed by list id instead of an array. |

```json
[
  {"id":"scammers","description":"Verified scammer list","format":{"json":"https://lols.bot/scammers.json","csv":"https://lols.bot/scammers-list.csv","plain":"https://lols.bot/scammers.txt"}},
  {"id":"spammers-full","description":"Lols Bot banlist: all global bans, updated daily","format":{"json":"https://lols.bot/spam/banlist.json","plain":"https://lols.bot/spam/banlist.txt"}},
  {"id":"spammers-1h","description":"Hourly updated banlist for last hour","format":{"json":"https://lols.bot/spam/banlist-1h.json","plain":"https://lols.bot/spam/banlist-1h.txt"}}
]
```

| List | Files | Content |
|---|---|---|
| `spammers-full` | `banlist.json`, `banlist.txt` | All accounts in the global ban list, regenerated daily. JSON array of ids / one id per line. More than 10 million ids, about 120 MB per file; HTTP Range is supported. |
| `spammers-1h` | `banlist-1h.json`, `banlist-1h.txt` | Ids banned during the last hour, regenerated hourly. |
| `scammers` | `scammers.json`, `scammers-list.csv`, `scammers.txt` | Verified scammers. JSON: array of `{user_id, names[], usernames[], updated, postid}` (`postid` — post in t.me/scamrsalert); CSV columns `user_id,names,usernames,link,updated`; TXT: one id per line. |

Files are served by `https://lols.bot` and may be cached by the CDN for up to 4 hours.
Old addresses `https://api.lols.bot/spam/<file>` answer `302` to `//lols.bot/spam/<file>` (deprecated).

## GET /stats — overall statistics

CORS is allowed (`Access-Control-Allow-Origin: *`); POST and OPTIONS are accepted too.

```json
{"banned":13595458,"scammers":12310,"botin":73171,"uptime":"24/7"}
```

`banned` — accounts in the global ban list, `scammers` — known scammers, `botin` — chats where the bot works.

---

## GET|POST /accountFull — full account profile (paid)

| Parameter | In | Required | Description |
|---|---|---|---|
| `id` | query or form | yes | Telegram id: user, bot (positive) or chat/channel (negative). Digits and `-`, up to 20 characters. |
| `withNames` | query or form | no | `1`/`true`/`yes`/`on` — add name and username history ($0.024 instead of $0.012). |

Response `200`: `{ok, id, type, data, billing}`; `type` is `user`, `bot` or `chat`, the shape of `data` depends on it.

User `data`: `name`, `username` (or `null`), `names[]` `{name, since}` and `usernames[]` `{username, date}` (only with
`withNames=1`, newest first, at most 200; `history_truncated: true` if longer, `history_hidden: true` if the owner hid part of it),
`lols_ban {banned, date}`, `registration {from, to}` (unix range), `first_message`, `first_photo` (unix or `null`),
`spam {messages, factor}`, `cas_ban` (true/false from our latest cached CAS check, `null` if none), `unofficial_client`,
`stats {chats_seen, messages, chats_with_messages, uniqueness, language, profile_views, last_day {member, left, restricted, kicked}}`, `scammer`.

Bot `data`: `name`, `username`, `lols_ban`, and if known `mau {users, as_of}` (monthly active users and the time of that snapshot).

Chat `data`: `title` (only for public chats with a username, otherwise `null`), `username` (empty string if none), `lols_ban`,
`registration` (estimated creation date, unix; supergroups and channels).

Hidden profile: `data` is `{"hidden": true}`, free of charge.

`billing`: `charged` (L¢), `charged_usd`, `balance` (L¢), `currency` (`L¢`), `cached`, `cached_at` (when cached).

```bash
curl -H "X-Api-Key: $LOLS_API_KEY" "https://api.lols.bot/accountFull?id=1234567890"
curl -X POST -H "Authorization: Bearer $LOLS_API_KEY" -d "id=1234567890&withNames=1" https://api.lols.bot/accountFull
```

```json
{
  "ok": true, "id": 1234567890, "type": "user",
  "data": {
    "name": "John Smith", "username": "johnsmith",
    "lols_ban": {"banned": false, "date": null},
    "registration": {"from": 1580515200, "to": 1585699200},
    "first_message": 1600000000, "first_photo": 1590000000,
    "spam": {"messages": 0, "factor": 0},
    "cas_ban": false, "unofficial_client": false,
    "stats": {"chats_seen": 12, "messages": 345, "chats_with_messages": 5, "uniqueness": 87.5, "language": "en",
              "profile_views": 3, "last_day": {"member": 1, "left": 0, "restricted": 0, "kicked": 0}},
    "scammer": false
  },
  "billing": {"charged": 0.012, "charged_usd": 0.012, "balance": 4.988, "currency": "L¢", "cached": false}
}
```

## GET|POST /estimateRegistration — registration date estimate (paid)

| Parameter | In | Required | Description |
|---|---|---|---|
| `id` | query or form | yes | Telegram id (users, bots, groups, channels). |
| `precision` | query or form | no | `1`/`true`/`yes`/`on` — also use the first known message and profile photo to narrow the range ($0.0012 instead of $0.0006). |

Response `200`: `{ok, id, type, precision, registration {from, to, estimate}, billing}`; `type` is `user`, `bot`, `channel`, `group` or `chat`;
times are unix seconds, `null` if unknown; `estimate` is the middle of the range (or the only known end).
Hidden profile: `{ok, id, type:"user", data:{"hidden":true}, billing}` — free. Unknown account: `404`, free.

```json
{"ok":true,"id":1234567890,"type":"user","precision":false,
 "registration":{"from":1580515200,"to":1585699200,"estimate":1583107200},
 "billing":{"charged":0.0006,"charged_usd":0.0006,"balance":4.9994,"currency":"L¢","cached":false}}
```

## GET|POST /resolveUsername — who owns a username (paid)

Live check in Telegram at the moment of the request (not a database lookup).

| Parameter | In | Required | Description |
|---|---|---|---|
| `username` | query or form | yes | `name`, `@name` or `https://t.me/name`, up to 64 characters. A valid username: 4–32 of `A-Z a-z 0-9 _`, starting with a letter. |

Response `200`: `{ok, username, found, data, billing}`. `found: false` — the username is free (still a completed, paid check).
`data`: `id` (Bot API format, `-100…` for channels/supergroups), `type` (`user`, `bot`, `channel`, `group`), `name`, `username`,
optional `verified`, `scam`, `fake`, `premium`, `deleted` (present only when `true`), `members`.

Price $0.06 per completed check; the same username within 24 hours is not charged again; up to 200 live checks per key per day.

```json
{"ok":true,"username":"examplechannel","found":true,
 "data":{"id":-1001234567890,"type":"channel","name":"Example Channel","username":"examplechannel","verified":true,"members":12345},
 "billing":{"charged":0.06,"charged_usd":0.06,"balance":4.94,"currency":"L¢","cached":false}}
```

## Errors of paid methods

Body: `{"ok": false, "error": "<code>", "description": "<hint>", "billing": {…}}` (`billing` only where relevant). Nothing is charged on any error.

| HTTP | `error` | Meaning |
|---|---|---|
| 400 | `bad_request` | missing or invalid `id` / `username` |
| 401 | `unauthorized` | no key, key passed in the URL/form, invalid or revoked key |
| 402 | `insufficient_funds` | not enough balance; `billing.price`, `billing.price_usd`, `billing.topup` |
| 404 | `not_found` | no data about this account |
| 429 | `too_many_requests` | per-key rate limit or too many invalid keys from your IP |
| 429 | `daily_limit` | too many not-found lookups, or the daily `resolveUsername` limit |
| 502 | `internal` | internal error |
| 503 | `unavailable`, `busy` | temporarily unavailable, retry in a few seconds |
| 504 | `timeout` | the answer was not ready in time; a retry usually gets the prepared answer |

Example: `{"ok":false,"error":"unauthorized","description":"API key is required: X-Api-Key header. Get it with /apikey in @LolsBot"}`
