docmost icon indicating copy to clipboard operation
docmost copied to clipboard

[Future request] Implement API support for Docmost

Open fkryczek opened this issue 1 year ago • 23 comments

I'd like to request API support for Docmost. This API will allow external systems to communicate with Docmost, enabling functions such as automated document generation, external system integration, and remote data retrieval.

Use cases:

  • Integration with third-party applications for automatic document generation.
  • External tools to manage, search, and retrieve documents from Docmost without requiring direct access to the UI.
  • Enabling automated workflows where documents need to be processed and transferred between different services or systems.

Consider integrating such capabilities early in the app development process. It would be wonderful if we could send API queries instead of exchanging records in the database.

fkryczek avatar Sep 27 '24 07:09 fkryczek

yes, we need APIs with create space , create doc, update doc, remove doc, list space doc tree ...

timiil avatar Sep 30 '24 01:09 timiil

There is an API. It will be documented in the future.

Philipinho avatar Sep 30 '24 01:09 Philipinho

There is an API. It will be documented in the future.

please tell us which API ? we are looking for use apis to update doc, not use websocket. thanks advance!

timiil avatar Sep 30 '24 06:09 timiil

I am also interested in this and it is the most important feature I am looking for. Looking through the code I am not able to find anything for updating the content on a page.

I found this to update the page name etc, but not anything about content.

https://github.com/docmost/docmost/blob/978fadd6b90043d9cc9e1ca56b969500b4b44e73/apps/server/src/core/page/page.controller.ts#L80

Having a bit of a hard time navigating the project, I decided to look at how the frontend updates the page content and it is using Tiptap over websocket.

https://github.com/docmost/docmost/blob/978fadd6b90043d9cc9e1ca56b969500b4b44e73/apps/client/src/features/editor/page-editor.tsx#L73-L79 https://github.com/docmost/docmost/blob/978fadd6b90043d9cc9e1ca56b969500b4b44e73/apps/client/src/features/editor/page-editor.tsx#L166


There is an API. It will be documented in the future.

@Philipinho could you provide a little bit more context? Or reopen the issue as it doesn't seem to exist.

erictuvesson avatar Oct 29 '24 14:10 erictuvesson

@erictuvesson did you see anything about accessing content? I just want to get a page's Markdown via an API call.

jcpsantiago avatar Nov 24 '24 20:11 jcpsantiago

@erictuvesson did you see anything about accessing content? I just want to get a page's Markdown via an API call.

A quick look, it seems you might be able to use this.

  • https://github.com/docmost/docmost/blob/main/apps/server/src/core/page/page.controller.ts#L43

Which I expect would return this:

  • https://github.com/docmost/docmost/blob/main/apps/server/src/database/types/db.d.ts#L95

I have not looked at authentication.

Since I didn't get a response on this issue and the lack of support I decided to use another system to meet my requirements.

erictuvesson avatar Nov 25 '24 08:11 erictuvesson

This is also something I stumbled in to. Was looking at a game development use case where a script would create a document for each item in a game, allowing the writers to work on descriptions there, and using a script to export & recycle the documents after everything was done.

IcedQuinn avatar Dec 13 '24 03:12 IcedQuinn

You can login

Philipinho avatar Dec 13 '24 03:12 Philipinho

There is an API. It will be documented in the future. @Philipinho, is there any update on this request? Docmost is being reviewed and would likely be adopted by my team. Thank you and your team for great software, we need our deployed services to have api endpoints to send reports to.

dockerman2020 avatar Dec 26 '24 08:12 dockerman2020

@erictuvesson did you see anything about accessing content? I just want to get a page's Markdown via an API call.

A quick look, it seems you might be able to use this.

  • https://github.com/docmost/docmost/blob/main/apps/server/src/core/page/page.controller.ts#L43

Which I expect would return this:

  • https://github.com/docmost/docmost/blob/main/apps/server/src/database/types/db.d.ts#L95

I have not looked at authentication.

Since I didn't get a response on this issue and the lack of support I decided to use another system to meet my requirements.

What other system did you settle for? I’m also looking for something similar to docmost that I can integrate into other systems.

martinjo avatar Jan 13 '25 12:01 martinjo

I'm also curious about what others are using. At the moment I'm considering falling back to Notion because it has an API and it's possible to allow guests to comment documents for free without accounts.

jcpsantiago avatar Jan 13 '25 14:01 jcpsantiago

There is an API. It will be documented in the future.

Is there currently any priority to at least list features of the API with the endpoint names. And maybe the link to the source code to know what object to pass to the endpoint?

As we search for a solution which we could simultaneously integrate with an AI Agent to search and retrieve information from it it would be crucial to be able to search and retrieve pages

wienans avatar Feb 15 '25 09:02 wienans

I found this documentation, but didn't have a chance to look into it yet.

https://www.postman.com/docmost-api

Would appreciate any comment if it works for you. I will certainly post after trying.

n8himmel avatar Feb 16 '25 09:02 n8himmel

I found this documentation, but didn't have a chance to look into it yet.

https://www.postman.com/docmost-api

Would appreciate any comment if it works for you. I will certainly post after trying.

As is mentioned in https://github.com/docmost/docmost/pull/503

paulpv avatar Feb 17 '25 18:02 paulpv

Thank you for https://www.postman.com/docmost-api Any idea how authentication works ? Is it possible to generate a token ?

oliviertripet avatar Apr 10 '25 13:04 oliviertripet

Thank you for https://www.postman.com/docmost-api Any idea how authentication works ? Is it possible to generate a token ?

Never mind, I was able to fetch the token via the inspector. All is well.

oliviertripet avatar Apr 10 '25 15:04 oliviertripet

I found this documentation, but didn't have a chance to look into it yet.

https://www.postman.com/docmost-api

Would appreciate any comment if it works for you. I will certainly post after trying.

I was able to retrieve a page's info as well as to create a new page. However it seems that there is no endpoint to create or to update the content of a page. The content is probably transferred via WebSocket which I'm not able to detect with the inspector unfortunately.

Any advice on how one can create or update a page's content would be very appreciated.

oliviertripet avatar Apr 12 '25 15:04 oliviertripet

@oliviertripet you can use the page import endpoint to create new pages from Markdown or HTML.

Philipinho avatar Apr 12 '25 16:04 Philipinho

@oliviertripet you can use the page import endpoint to create new pages from Markdown or HTML.

@Philipinho Thank you for pointing me in the right direction. Any clue how I should submit the markdown/html content ? Also does the import endpoint create a new page or replace the content of an existing page ?

oliviertripet avatar Apr 12 '25 17:04 oliviertripet

Are there some API docs I can check? I'm looking to manage (a part of) dockmost through my self-hosted management tool. I want to create users, add and remove users from groups, and delete users. Which endpoints can I use, and how can I authenticate? If there is any documentation about this, I'd like to know! Thank you.

leurs247 avatar Apr 12 '25 22:04 leurs247

@oliviertripet format accepts both markdown and html. You should attach the file as binary. See screenshot below. Make sure the file key comes last in the request.

How we do it from the frontend

https://github.com/docmost/docmost/blob/49d0f1cc9a105e6488be20a7138dde3a69819ac0/apps/client/src/features/page/services/page-service.ts#L75-L87

Postman example

Image

Philipinho avatar Apr 13 '25 09:04 Philipinho

@Philipinho it works like a charm. Many thanks !

oliviertripet avatar Apr 13 '25 15:04 oliviertripet

@oliviertripet format accepts both markdown and html. You should attach the file as binary. See screenshot below. Make sure the file key comes last in the request.

How we do it from the frontend

docmost/apps/client/src/features/page/services/page-service.ts

Lines 75 to 87 in 49d0f1c

export async function importPage(file: File, spaceId: string) { const formData = new FormData(); formData.append("spaceId", spaceId); formData.append("file", file);

const req = await api.post<IPage>("/pages/import", formData, { headers: { "Content-Type": "multipart/form-data", }, });

return req.data; }

Postman example

Image

Thank you! Can I overwrite existing file using import?

me-kirill avatar Apr 27 '25 20:04 me-kirill

is there a documentation somewhere how to use the API... i found the postman webpage (https://www.postman.com/docmost-api) but already fail at the auth part... with "cannot Post /auth/login (404). i use docmost (vanilla), converted the docker compose file to k8s deployment! I wonder if it might have something to do with the APP_SECRET, but am completely lost at the moment.

dderichswei avatar Jun 22 '25 12:06 dderichswei

is there a documentation somewhere how to use the API... i found the postman webpage (https://www.postman.com/docmost-api) but already fail at the auth part... with "cannot Post /auth/login (404). i use docmost (vanilla), converted the docker compose file to k8s deployment! I wonder if it might have something to do with the APP_SECRET, but am completely lost at the moment. @dderichswei

Try to add /api/ to your base_url, so the whole url reads https://domain.tld/api/auth/login

der--flo avatar Jun 28 '25 18:06 der--flo

@benone - I am interested in your question to re: being able to update existing. I suspect it' only for new page content addition since it does not look like it accepts an ID value and this would be necessary for updating content.

ReessKennedy avatar Jul 26 '25 03:07 ReessKennedy

  • I tried to create an endpoint in Python to fix this quickly until there is a fully-documented API
  • After investigating DB realized actual content is stored as JSON and not just simple markdown
  • This storage is likely standard for Prosemirror but makes it tough to just create some temporary endpoint as I'd have to parse this json and think through Prosemirror's logic
  • Going to abandon this idea ... Maybe could write a temporary endpoint using Prosemirror's API and Node but just documenting that this hack idea has failed me to save anyone else time that has this idea
Image

ReessKennedy avatar Aug 08 '25 14:08 ReessKennedy

@ReessKennedy use the page import endpoint to create pages with markdown or html.

Philipinho avatar Aug 08 '25 17:08 Philipinho

Update: Looks like finally got this working! I had some port blocking because of Cloudflare and now it works but had to used Y.js and websockets and mirror the collab server within app to get it work with external requests!

@Philipinho ... thanks for the reply. But import only creates a new page with content, right? It does not update an existing page? We're create a bidirectional sync so need a way to update existing content. I was using Python and then hit the Webocket issue of the collaborative editor and then started to use Node to try to get around this but finally hit an error that may be the result of inherent restrictions on making page edits outside the web editor? ... that scripts are restricted in current, default Docmost build? Testing a fully Node-based version and getting "wss://docs.mydomain.com:3001/collab' failed: " in Console ... so maybe this is security blocked?

ReessKennedy avatar Aug 08 '25 21:08 ReessKennedy

See here - https://github.com/tool-ext/docmost-api-bridge

Using Node, I created a rest-based endpoint just for updating content.

Until Docmost has a full-featured API you can now just run this on a server somewhere and it will act as a bridge. You can still use the rest of the endpoints in the Postman for all the other operations but if you also need to update, this works.

Of course, I may have missed something in all this and not needed to do this but I couldn't get IMPORT to work for update and was anxious to try to get it working.

I just run mine on a little VPS and run it directly on Node 22.x ... it is important to use a newish version of Node, like great than 20. When you run it like this I just added a little .env file to define my IP or domain. The docker-based version might worker but I didn't test it after I got it running directly and it worked fine for my needs.

The update seems to take a few seconds / not immediate. Unclear why.

ReessKennedy avatar Aug 22 '25 21:08 ReessKennedy