# WePostX public tools API

The Common tools API is public for people, scripts and AI clients. It does not
require login, a Session Cookie, CSRF token or Agent token.

- Base URL: `https://wepostx.com/api/v1/tools`
- Discovery: `GET /api/v1/tools`
- OpenAPI: `https://wepostx.com/openapi/tools-v1.json`
- Requests and responses use UTF-8 JSON.
- POST responses use `Cache-Control: private, no-store`.
- Browser clients may call these routes cross-origin without credentials.
- Inputs are bounded to 768 KiB and a request may run for up to four seconds.

## Tools

| Tool | Endpoint | Required request fields |
|---|---|---|
| Structured data | `POST /data-format` | `input`, `source=auto|json|yaml|toml`, `target=json|yaml|toml`, `indent=2|4` |
| Data to models | `POST /data-models` | `input`, `source`, `language=go|rust|typescript`, `root_name` |
| Identifier cases | `POST /case-converter` | `input`, `target=snake|camel|pascal|kebab|constant|dot`, `preserve_empty` |
| Regular expression | `POST /regex` | `input`, `pattern`, `flags`, `replacement` |
| Table converter | `POST /table-converter` | `input`, `source`, `target`, `alignment=left|center|right` |
| Text comparison | `POST /text-diff` | `left`, `right`, `mode=line|character` |
| Text cleanup | `POST /text-cleaner` | `input` plus cleanup options |
| URL tools | `POST /url` | `input`, `operation=parse|encode|decode` |
| Encoding | `POST /encoding` | `input`, `scheme=base64|unicode|html`, `operation=encode|decode` |
| Time and date | `POST /datetime` | `operation` plus its timestamp/date fields |
| UUID | `POST /uuid` | `version=v4|v7`, `count`, `uppercase`, `hyphens` |
| Cron | `POST /cron` | `expression`, `timezone`, optional `current_date`, `count` |
| Random numbers | `POST /random-number` | `mode`, `min`, `max`, `count`; optional `decimals`, `unique`, `sort` |

The regex endpoint uses the Go RE2 engine. Supported flags are `g`, `i`, `m`
and `s`; match positions are UTF-8 byte offsets. Cron accepts exactly five
numeric Unix fields and an IANA timezone.

## Examples

Discover all tools:

```bash
curl -sS https://wepostx.com/api/v1/tools
```

Convert JSON to YAML:

```bash
curl -sS https://wepostx.com/api/v1/tools/data-format \
  -H 'Content-Type: application/json' \
  --data '{"input":"{\"id\":42,\"active\":true}","source":"json","target":"yaml","indent":2}'
```

Generate Go models:

```bash
curl -sS https://wepostx.com/api/v1/tools/data-models \
  -H 'Content-Type: application/json' \
  --data '{"input":"{\"user_id\":42,\"name\":\"Fei\"}","source":"json","language":"go","root_name":"User"}'
```

Preview Cron runs:

```bash
curl -sS https://wepostx.com/api/v1/tools/cron \
  -H 'Content-Type: application/json' \
  --data '{"expression":"0 9 * * 1-5","timezone":"Asia/Shanghai","count":10}'
```

Invalid requests return the standard error envelope:

```json
{"error":{"code":"invalid_request","message":"..."}}
```
