Introduction
collections.rest is a free public data library. Each dataset is a typed list of key/value pairs, accessible via a predictable REST URL.
https://collections.rest/api/v1/
No authentication for public datasets
All public datasets are available without an account, API key or auth header. Just fetch the URL.
Output formats
Append an extension to any collection URL. No extension returns JSON.
/api/v1/collection/nato-alphabet.json → application/json
/api/v1/collection/nato-alphabet.csv → text/csv; charset=utf-8
/api/v1/collection/nato-alphabet.html → text/html
/api/v1/collection/nato-alphabet.txt → text/plain; charset=utf-8
/api/v1/collection/nato-alphabet.yaml → application/yaml; charset=utf-8
/api/v1/collection/nato-alphabet.xml → application/xml; charset=utf-8
/api/v1/collection/nato-alphabet.ndjson → application/x-ndjson; charset=utf-8
/api/v1/collection/nato-alphabet.md → text/markdown; charset=utf-8
YAML (.yaml, not .yml) has the same fields as the JSON: collection, type, count and items with id, key and value. Integers and decimals stay numbers, and strings that YAML would read as something else (such as yes, null or 1e3) are quoted. It works for the daily and single item routes too.
CSV uses a semicolon (;) between key and value, with a key;value header. A field that contains a semicolon, a double quote or a line break is wrapped in double quotes, with quotes inside doubled.
XML is a <collection name type count> element with one <item id key>value</item> per item. The key is an attribute, never an element name, so any key works; characters XML 1.0 cannot carry (control characters other than tab and line breaks) are left out.
NDJSON (.ndjson) has one JSON object per line, {"id":1,"key":"A","value":"Alpha"}, with no header line; numbers stay numbers. Each line ends with a line break, so the body can be streamed line by line.
Markdown (.md) is a | key | value | table. A pipe or a backslash in a value is escaped with a backslash, and a line break becomes <br>, so every item stays one row.
One item by key
Fetch a single item by its key, in any of the formats above. Keys match exactly, so m and M are different keys. URL-encode the key: a slash becomes %2F, a space %20. A key that itself ends in .json, .csv, .html, .txt, .yaml, .xml, .ndjson or .md needs the format added after it. A missing key returns 404.
/api/v1/collection/chemical-elements/key/Fe
/api/v1/collection/chemical-elements/key/Fe.txt
/api/v1/collection/danish-flag-days/key/06-05.json
Value types
Every dataset declares one type. JSON returns values cast to the correct JavaScript type, not as strings.
stringText, max 250 chars
Endpoints
Public collection access
Read-only access to public collections. No authentication required.
GET/api/v1/collectionsBrowse & search public collections
GET/api/v1/collection/{slug}Fetch all items in a collection
GET/api/v1/collection/{slug}/dailyGet the daily item (rotates every 24h UTC)
GET/api/v1/collection/{slug}/key/{key}Fetch a single item by key (exact match, URL-encode the key)
GET/api/v1/collection/{slug}/{item}Fetch a single item by ID
Authentication
Register, login, and logout. Login returns a Sanctum bearer token.
POST/api/v1/auth/registerRegister a new user
POST/api/v1/auth/loginLogin, returns Sanctum token
DELETE/api/v1/auth/logoutInvalidate current token
User (requires Bearer token)
Manage your own collections, items, and API keys.
GET/api/v1/meCurrent user profile & active plan
GET/api/v1/me/collectionsList own collections
POST/api/v1/me/collectionsCreate a new collection
GET/api/v1/me/collections/{collection}Show a single collection
PUT/api/v1/me/collections/{collection}Update a collection
DELETE/api/v1/me/collections/{collection}Delete a collection
GET/api/v1/me/collections/{collection}/itemsList items in a collection
POST/api/v1/me/collections/{collection}/itemsAdd an item to a collection
POST/api/v1/me/collections/{collection}/items/importImport many items from CSV, JSON or NDJSON (dry_run for a preview)
PUT/api/v1/me/collections/{collection}/items/{item}Update an item
DELETE/api/v1/me/collections/{collection}/items/{item}Delete an item
GET/api/v1/me/collections/{collection}/share-linksList the private share links of a collection
POST/api/v1/me/collections/{collection}/share-linksCreate a private share link (optional expiry)
POST/api/v1/me/collections/{collection}/share-links/{link}/regenerateReplace a share link with a new one
DELETE/api/v1/me/collections/{collection}/share-links/{link}Revoke a share link
GET/api/v1/me/keysList API keys
POST/api/v1/me/keysGenerate a new API key
DELETE/api/v1/me/keys/{key}Revoke an API key
Response format
All JSON responses follow this structure. Values are cast to the declared type.
{
"collection": "famous-quotes",
"type": "string",
"count": 66,
"items": [
{ "id": 1, "key": "Albert Einstein", "value": "Imagination is more important than knowledge." }
]
}Plain text (.txt)
When keys are present, each line is key: value. If a collection has no meaningful keys (values only), each line contains just the value.
# With keys (e.g. famous-quotes)
Albert Einstein: Imagination is more important than knowledge.
Marie Curie: I was taught that the way of progress was neither swift nor easy.
# Values only (e.g. a list with no labels)
Imagination is more important than knowledge.
I was taught that the way of progress was neither swift nor easy.
Error response
{ "error": "Not Found", "status": 404 }Status codes
| Code | Meaning |
|---|
| 200 | Success |
| 404 | Not found (also for private collections without key) |
| 422 | Validation error, e.g. string value over 250 chars |
| 429 | Rate limit exceeded |
Authentication
Public datasets need no authentication. Private collections (user-created) require an API key.
API key: header (recommended)
X-API-Key: your-api-key-here
API key: query string
GET /api/v1/collection/my-private-col?api_key=your-key
Private collections return 404, not 403, to avoid revealing their existence.
Create & share
Anyone with a free account can create a collection: pick a name and a type, then add keys and values.
Public
A public collection is listed in the library and has its own page. Share that page, or the data URL itself: anyone can fetch it with no key, as JSON, CSV, HTML, text, YAML, XML, NDJSON or Markdown.
https://collections.rest/api/v1/collection/your-slug.json
Private
A private collection is not listed. Only requests with your API key can read it. You can switch a collection between public and private at any time.
Private share link
To show a private collection to someone without giving out your API key, create a share link in the Share panel of the collection. The link looks like /s/<token> and serves the page, and the data in every format at /s/<token>.json. It is read only, never cached or indexed, and you can set an expiry, regenerate it or revoke it with one click. Anyone who has the link can read the collection, so send it only to people you trust. A collection can have up to 10 links. The same is available in the API under /api/v1/me/collections/{slug}/share-links.
Embed a table
Every public collection is also served as a styled HTML table with the .html extension. It has no scripts and may be shown in an iframe on any site. The Embed tab of the Share panel gives you the code to copy:
<iframe src="https://collections.rest/api/v1/collection/your-slug.html" title="Your collection" width="100%" height="320" loading="lazy" sandbox></iframe>
Add ?theme=dark or ?theme=light to pick a theme. Without it the table follows the visitor's colour scheme. Private collections cannot be embedded.
Create a collectionImport
Add many items at once. On your collection's page, press Import, paste text or choose a file, and press Preview. The preview shows the format it found, how many rows are new, updated or skipped, and any row that is wrong. Nothing is saved until you press Import, and then every row is saved or none is.
Formats
- CSV with
;, , or a tab between key and value, found from the first line. A first row key;value is skipped. Quote a value that holds the delimiter, a quote ("") or a line break. - JSON: a list of objects,
[{"key": "a", "value": "x"}], an object of pairs, {"a": "x"}, or a collection's own .json. - NDJSON: one
{"key", "value"} object per line, like a collection's .ndjson.
The text must be UTF-8. A collection's own .csv imports back unchanged.
Rules
- Every key and value is required and at most 250 characters. Values follow the collection's type: whole numbers for integer collections, finite numbers for decimal ones.
- A key may appear once per import. Keys match exactly, including case. A key the collection already has is skipped, or its value is updated if you choose so.
- New items must fit your plan's items per collection. If they do not, nothing is imported and the preview says how many fit.
- Up to 5,000 rows and 1 MB per import, and 20 imports or previews a minute.
- New items are added after the existing ones, in the order of the file.
From the API
Send the text as content, or a file as file (multipart), with a bearer token. on_duplicate is skip or update, format is csv, json or ndjson (detected when left out), and dry_run: true returns the preview without saving. The answer is the report: 201 when imported, 422 with the rows that are wrong.
POST /api/v1/me/collections/your-slug/items/import
Authorization: Bearer <token>
Content-Type: application/json
{"content": "key;value\nalpha;First\nbravo;Second", "dry_run": true}Export
The Export menu on your collection's page downloads it in any format, private collections too.
Home Assistant
Home Assistant reads any collection with its built-in REST sensor. No plugin and no key for public collections. Add these to configuration.yaml and restart or reload.
One value by key
Look up one item with /api/v1/collection/<slug>/key/<key>.json. The response has a value field, typed as the collection declares.
rest:
- resource: https://collections.rest/api/v1/collection/chemical-elements/key/Fe
scan_interval: 86400
sensor:
- name: "Element Fe"
value_template: "{{ value_json.value }}"Today's Danish name day
The keys of danish-name-days are MM-DD, so a templated resource finds today's date.
rest:
- resource_template: "https://collections.rest/api/v1/collection/danish-name-days/key/{{ now().strftime('%m-%d') }}.json"
scan_interval: 3600
sensor:
- name: "Danish name day today"
value_template: "{{ value_json.value }}"The daily item
Every collection has a daily item that changes at midnight UTC. It has the same shape as a key lookup.
rest:
- resource: https://collections.rest/api/v1/collection/famous-quotes/daily.json
scan_interval: 3600
sensor:
- name: "Quote of the day"
value_template: "{{ value_json.value }}"Plain text
With .txt the body is key: value on one line. Keep what follows the first colon and space.
rest:
- resource: https://collections.rest/api/v1/collection/chemical-elements/key/Fe.txt
scan_interval: 86400
sensor:
- name: "Element Fe"
value_template: "{{ value.split(': ', 1)[-1] | trim }}"Private collections
Send your API key in a header. Without it a private collection answers 404.
rest:
- resource: https://collections.rest/api/v1/collection/my-private-collection/key/some-key
headers:
X-API-Key: your-api-key-here
sensor:
- name: "My value"
value_template: "{{ value_json.value }}"Good to know
- A missing key or collection returns 404. The sensor then shows as unavailable until the next successful update.
- Home Assistant polls every 30 seconds by default. Set
scan_interval in seconds to 3600 or more. Public requests are limited to 60 per minute per IP address, and responses are cached, so polling faster than the data changes gains nothing. - Keys match exactly, including case. URL-encode special characters in a key (a space is
%20, a slash is %2F). - Home Assistant states hold at most 255 characters, so very long string values are not a fit for a sensor.