Skip to content

✨(api) add API route to fetch document content #1213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

sylvinus
Copy link
Member

@sylvinus sylvinus commented Jul 24, 2025

This allows API users to fetch document content, enabling the use of Docs as a headless CMS for instance, or any kind of document processing, with /api/v1.0/documents/xyz/content/?content_format=html URLs.

Fixes #1206.

This allows API users to process document content, enabling the
use of Docs as a headless CMS for instance, or any kind of document
processing. Fixes #1206.
@sylvinus sylvinus requested review from lunika and AntoLC July 24, 2025 00:39
@StephanMeijer
Copy link
Contributor

StephanMeijer commented Jul 24, 2025

Overhead

Instead of using the "content" and "format" fields, you can use the Content-Type-header and the body of the request. This will have as effect:

  • No overhead in JSON-encoding
  • Aligning with the HTTP spec more
  • No overhead in base64: CPU/memory but also network traffic (base64 also increases traffic with ~33% and JSON also increases payload size with a tiny bit)

This is in line with the existing convert-endpoint.

Utilizing the existing convert-endpoint

Instead of writing a new endpoint, you can rewrite the convert-endpoint to accept a Accept and Content-Type header.

e.g.

POST /convert

Content-Type: text/markdown
Accept: application/vnd.yjs.doc

# Heading

Some text

Would transform the markdown document into a YJs document (raw non-base64 encoded content).

e.g.

POST /convert

Content-Type: application/vnd.yjs.doc
Accept: text/html

<binary contents>

Would transform the YJs document (raw non-base64 encoded content) to HTML.

It'd then respond by:

Content-Type: text/html

<h1>Heading</h1><p>Some text</p>

Last but not least.

If you have any questions about this approach, feel free to schedule a call with me and/or ask @lunika to be in our secret Matrix room.

I also left some code style comments.

@sylvinus
Copy link
Member Author

@StephanMeijer Thanks for the review! Your approach is more concise indeed and I implemented all your feedbacks I think.

@StephanMeijer
Copy link
Contributor

Will give it a new review today or tomorrow!

@StephanMeijer
Copy link
Contributor

@sylvinus Can I propose a different style of writing this tomorrow? Need some time to get behind my editor,.

@sylvinus
Copy link
Member Author

@StephanMeijer feel free to push on the branch, frankly I don't care that much about the internals, I just badly need the API as a user ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Html and markdown endpoint to retrieve content of public docs
2 participants