2.3 KiB
2.3 KiB
The server API is relatively small. The client primarily communicates with the server for file “CRUD” (Create, Read, Update, Delete) style operations.
All API requests from the client will always set the X-Sync-Mode request header set to true. The server may use this fact to distinguish between requests coming from the client and regular e.g. GET requests from the browser (through navigation) and redirect appropriately (for instance to the UI URL associated with a specific .md file).
The API:
GET /index.jsonwill return a full listing of all files in your space including metadata like when the file was last modified, as well as permissions. This is primarily used for sync purposes with the client.GET /*.*: Reads and returns the content of the file at the given path. This means that if youGET /index.mdyou will receive the content of yourindexpage. If the the optionalX-Get-Metarequest header is set, the server does not need to return the body of the file (but it can). TheGETresponse will have a few additional SB-specific headers:- (optional)
X-Last-Modifiedthe last modified time of the file as a UNIX timestamp in ms since the epoch (as coming fromData.now()). This timestamp has to match thelastModifiedlisted for this file in/index.jsonotherwise syncing issues may occur. When this header is missing, frequent polling-based sync will be disabled for this file. - (optional)
X-Createdthe created time of the file as a UNIX timestamp in ms since the epoch (as coming fromData.now()). - (optional)
X-Permission: eitherrworrowhich will change whether the editor opens in read-only or edit mode. When missing,rois assumed. - (optional)
X-Content-Length: which will be the same asContent-Lengthexcept if the request was sent with aX-Get-Metaheader and the body is not returned (thenContent-Lengthwill be0andX-Content-Lengthwill be the size of the file)
- (optional)
PUT /*.*: The same asGETexcept that it takes the body of the request and writes it to a file.DELETE /*.*: Again the same, except this will delete the given file.GET /.client/*: Retrieve files implementing the clientGET /*andGET /: Anything else (any path without a file extension) will serve the SilverBullet UI HTML.