Files
dewemoji/api-test-document.md
2026-02-06 14:04:41 +07:00

115 lines
2.3 KiB
Markdown

# Dewemoji API Test Document
This is a quick, repeatable checklist for validating the API locally or on staging.
## Base URLs
- Local: `http://127.0.0.1:8000/v1`
- Staging: `https://dewemoji.backoffice.biz.id/v1`
Set once in your shell for convenience:
```bash
BASE=http://127.0.0.1:8000/v1
# BASE=https://dewemoji.backoffice.biz.id/v1
```
## Health
```bash
curl -s "$BASE/health" | jq .
```
Expected: `{ "ok": true, ... }`
## Categories
```bash
curl -s "$BASE/categories" | jq 'keys | length'
```
Expected: number > 0.
## Emoji Search
```bash
curl -s "$BASE/emojis?q=love&limit=5" | jq '.items | length'
```
Expected: number > 0.
## Emoji Detail
```bash
curl -s "$BASE/emoji/grinning-face" | jq '.slug,.name'
```
Expected: `"grinning-face"` and `"grinning face"`.
## Rate-limit (Free tier)
```bash
curl -i "$BASE/emojis?limit=1&page=1" | grep -E "HTTP|X-RateLimit"
```
Expected:
- `X-RateLimit-Limit`
- `X-RateLimit-Remaining`
- `X-RateLimit-Reset`
Note:
- Local dev disables rate limiting by default, so headers may not appear on `http://127.0.0.1`.
## Pro key test (if you have a key)
```bash
KEY=YOUR_LICENSE_KEY
curl -s -H "Authorization: Bearer $KEY" "$BASE/emojis?q=love&limit=50" | jq '.limit,.plan'
```
Expected:
- `limit` up to 50
- `plan` = `free` or `pro` (depending on key validation).
## License verify / activate / deactivate
```bash
KEY=YOUR_LICENSE_KEY
curl -s -X POST "$BASE/license/verify" \
-H "Authorization: Bearer $KEY" | jq .
curl -s -X POST "$BASE/license/activate" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"email":"you@example.com","product":"extension","device_id":"local-dev"}' | jq .
curl -s -X POST "$BASE/license/deactivate" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"product":"extension","device_id":"local-dev"}' | jq .
```
Expected:
- verify → `{ ok: true }` if key is valid.
- activate → `{ ok: true }` and `device_id` echoed.
- deactivate → `{ ok: true }`.
## Caching (ETag)
```bash
ETAG=$(curl -i "$BASE/emojis?q=love&limit=5" | awk -F': ' '/^ETag:/ {print $2}' | tr -d '\r')
curl -i -H "If-None-Match: $ETAG" "$BASE/emojis?q=love&limit=5" | head -n 1
```
Expected: `HTTP/1.1 304 Not Modified`
## Error responses
```bash
curl -s "$BASE/emoji/this-does-not-exist" | jq .
```
Expected:
- `error` = `not_found`