What is this?
Simple JSON API for five collections. Reads are public; writes require an x-api-key
.
- GET read/query (no auth)
- POST, PATCH, DELETE change data (require
x-api-key
)
TL;DR
- Read: GET
__BASE__/<collection>?by=<field>&q=<value>
- Random: GET
__BASE__/<collection>/random
- Add: POST
__BASE__/<collection>
+x-api-key
- Edit: PATCH
__BASE__/<collection>/:id
(:isbn
for books) - Delete: DELETE
__BASE__/<collection>/:id
(:isbn
for books)
Pagination:
?page=1&limit=25
(limit ≤ 100)Authentication (only for writes)
For POST, PATCH, and DELETE send this header:
x-api-key: <API_KEY>
Reads (GET/Random) are public.
How querying works
Exact match only: WHERE field == value
. No fuzzy search.
by
— which field to check (must be allowed below)q
— exact value- Optional:
page
,limit
Collection | Allowed by |
---|---|
art | id , author , prompt , medium , keywords |
writing | id , author , prompt , genre |
qotd | id , author , question , theme |
books | isbn , editor , title , author , genre , series , synopsis |
games | id , author , title , genre , description |
Case rules on write:
- Arrays like
medium
,keywords
,genre
,theme
,series
are normalized to lowercase. - Book authors are stored in UPPERCASE.
Model
{
"id": "A-001",
"author": "Casey",
"prompt": "A neon fox in the rain",
"medium": ["digital","oil"],
"keywords": ["portrait","fox"]
}
Read (query)
curl -s "__BASE__/art?by=author&q=Casey"
Random
curl -s "__BASE__/art/random"
Create (x-api-key)
curl -X POST "__BASE__/art" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "id":"A-001","author":"Casey","prompt":"A neon fox in the rain","medium":["Digital","Oil"],"keywords":["Portrait","Fox"] }'
Edit (x-api-key)
curl -X PATCH "__BASE__/art/A-001" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "type":"medium", "value":["digital","watercolor"] }'
Delete (x-api-key)
curl -X DELETE "__BASE__/art/A-001" -H "x-api-key: <API_KEY>"
Model
{
"id": "W-001",
"author": "Casey",
"prompt": "Write about a quiet storm.",
"genre": ["scifi","drama"]
}
Read
curl -s "__BASE__/writing?by=genre&q=scifi"
Random
curl -s "__BASE__/writing/random"
Create (x-api-key)
curl -X POST "__BASE__/writing" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "id":"W-001","author":"Casey","prompt":"Write about a quiet storm.","genre":["Scifi","Drama"] }'
Edit (x-api-key)
curl -X PATCH "__BASE__/writing/W-001" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "type":"genre", "value":["scifi","mystery"] }'
Delete (x-api-key)
curl -X DELETE "__BASE__/writing/W-001" -H "x-api-key: <API_KEY>"
Model
{
"id": "Q-001",
"author": "Casey",
"question": "What makes a place feel like home?",
"theme": ["reflection","home"]
}
Read
curl -s "__BASE__/qotd?by=theme&q=reflection"
Random
curl -s "__BASE__/qotd/random"
Create (x-api-key)
curl -X POST "__BASE__/qotd" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "id":"Q-001","author":"Casey","question":"What makes a place feel like home?","theme":["Reflection","Home"] }'
Edit (x-api-key)
curl -X PATCH "__BASE__/qotd/Q-001" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "type":"theme", "value":["reflection","community"] }'
Delete (x-api-key)
curl -X DELETE "__BASE__/qotd/Q-001" -H "x-api-key: <API_KEY>"
Model
{
"isbn": "9780132350884",
"editor": "P. Martin",
"link": "https://example.com/book",
"title": "Clean Code",
"synopsis": "A handbook of agile software craftsmanship.",
"genre": ["programming","craft"], // lowercase
"series": ["null"], // example
"author": ["ROBERT C. MARTIN"] // UPPERCASE
}
Read
curl -s "__BASE__/books?by=author&q=Neil%20Gaiman"
Random
curl -s "__BASE__/books/random"
Create (x-api-key)
curl -X POST "__BASE__/books" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "isbn":"9780132350884","editor":"P. Martin","link":"https://example.com/book","title":"Clean Code","synopsis":"...","genre":["Programming","Craft"],"series":["none"],"author":["robert c. martin"] }'
Edit (x-api-key)
curl -X PATCH "__BASE__/books/9780132350884" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "type":"genre", "value":["programming","clean-code"] }'
Delete (x-api-key)
curl -X DELETE "__BASE__/books/9780132350884" -H "x-api-key: <API_KEY>"
Model
{
"id": "G-001",
"author": "Casey",
"title": "Neon Fox Runner",
"description": "Endless runner with rain effects.",
"genre": ["arcade","runner"]
}
Read
curl -s "__BASE__/games?by=genre&q=arcade"
Random
curl -s "__BASE__/games/random"
Create (x-api-key)
curl -X POST "__BASE__/games" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "id":"G-001","author":"Casey","title":"Neon Fox Runner","description":"Endless runner...","genre":["Arcade","Runner"] }'
Edit (x-api-key)
curl -X PATCH "__BASE__/games/G-001" \
-H "x-api-key: <API_KEY>" -H "Content-Type: application/json" \
-d '{ "type":"genre", "value":["arcade","platformer"] }'
Delete (x-api-key)
curl -X DELETE "__BASE__/games/G-001" -H "x-api-key: <API_KEY>"
Stats
curl -s "__BASE__/stats/counts"
Returns object with counts per collection and total.
Response shapes
Success (list)
{
"ok": true,
"data": [ { ... }, { ... } ],
"meta": { "total": 2, "page": 1, "limit": 25 }
}
Success (single/random)
{ "ok": true, "data": { ... } }
Error (validation)
{
"ok": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid query parameters",
"issues": [
{ "path": "by", "code": "custom", "message": "Invalid 'by' field" }
]
}
}
Error (not found)
{ "ok": false, "error": { "code": "NOT_FOUND", "message": "Art not found" } }
Tips & gotchas
- Exact match: the value in
q
must exactly match what’s stored. - Arrays normalize on write: array fields to lowercase; book authors to UPPERCASE.
- HTML-escaped
&
is fine: the server repairs it. - Writes are JSON: include
Content-Type: application/json
. - Auth for writes: add
x-api-key
for POST/PATCH/DELETE.