Reading API
Every page URL doubles as an API. Ask for a different content type and you get the Concept as data instead of HTML. Browsers still get the normal page. This works on Sunstone Web and under sunstone serve, which makes a Bundle easy for agents and scripts to read.
| Request | Accept |
Response |
|---|---|---|
GET /path/to/page |
text/markdown |
The raw file, frontmatter included. |
GET /path/to/page |
application/json |
Frontmatter, body, outbound links and backlinks. |
GET /folder?list |
application/json |
Every Concept under the folder: path, title, description, type, tags. Filter with &type= or &tag=. /?list lists the whole Bundle. |
GET /folder?q=text |
application/json |
Full-text search under the folder, with line numbers and snippets. |
Without one of these Accept headers, you get the normal HTML page.
Examples
Try it on this guide:
curl -H 'Accept: text/markdown' https://wiki.sunstone.pothos.dev/5-web/reading-api
curl -H 'Accept: application/json' https://wiki.sunstone.pothos.dev/2-editing/links
curl -H 'Accept: application/json' 'https://wiki.sunstone.pothos.dev/2-editing?list'
Sources
- Sunstone CHANGELOGhttps://github.com/pothos-dev/sunstone/blob/main/CHANGELOG.md