diff --git a/docs/api/index.html b/docs/api/index.html index 573b70f60..f49410056 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -180,6 +180,24 @@ color: gray; font-size: .9em; } + a.heading-anchor { + display: inline-block; + opacity: 0; + width: 1.3em; + font-size: 0.7em; + margin-left: -1.3em; + line-height: 1em; + text-decoration: none; + } + a.heading-anchor:hover, + h1:hover a.heading-anchor, + h2:hover a.heading-anchor, + h3:hover a.heading-anchor, + h4:hover a.heading-anchor, + h5:hover a.heading-anchor, + h6:hover a.heading-anchor { + opacity: 1; + } @media all and (min-width: 400px) { .nav-right .share-btn { display: inline-block; @@ -250,7 +268,7 @@ -

Joplin API

+

πŸ”—Joplin API

When the Web Clipper service is enabled, Joplin exposes a REST API which allows third-party applications to access Joplin's data and to create, modify or delete notes, notebooks, resources or tags.

In order to use it, you'll first need to find on which port the service is running. To do so, open the Web Clipper Options in Joplin and if the service is running it should tell you on which port. Normally it runs on port 41184. If you want to find it programmatically, you may follow this kind of algorithm:

let port = null;
@@ -262,13 +280,13 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
     }
 }
 
-

Authorisation

+

πŸ”—Authorisation

To prevent unauthorised applications from accessing the API, the calls must be authentified. To do so, you must provide a token as a query parameter for each API call. You can get this token from the Joplin desktop application, on the Web Clipper Options screen.

This would be an example of valid cURL call using a token:

curl http://localhost:41184/notes?token=ABCD123ABCD123ABCD123ABCD123ABCD123
 

In the documentation below, the token will not be specified every time however you will need to include it.

-

Using the API

+

πŸ”—Using the API

All the calls, unless noted otherwise, receives and send JSON data. For example to create a new note:

curl --data '{ "title": "My note", "body": "Some note in **Markdown**"}' http://localhost:41184/notes
 
@@ -283,27 +301,27 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
  • PUT: To update an item. Note in a REST API, traditionally PUT is used to completely replace an item, however in this API it will only replace the properties that are provided. For example if you PUT {"title": "my new title"}, only the "title" property will be changed. The other properties will be left untouched (they won't be cleared nor changed).
  • DELETE: To delete items.
  • -

    Filtering data

    +

    πŸ”—Filtering data

    You can change the fields that will be returned by the API using the fields= query parameter, which takes a list of comma separated fields. For example, to get the longitude and latitude of a note, use this:

    curl http://localhost:41184/notes/ABCD123?fields=longitude,latitude
     

    To get the IDs only of all the tags:

    curl http://localhost:41184/tags?fields=id
     
    -

    Error handling

    +

    πŸ”—Error handling

    In case of an error, an HTTP status code >= 400 will be returned along with a JSON object that provides more info about the error. The JSON object is in the format { "error": "description of error" }.

    -

    About the property types

    +

    πŸ”—About the property types

    -

    Testing if the service is available

    +

    πŸ”—Testing if the service is available

    Call GET /ping to check if the service is available. It should return "JoplinClipperServer" if it works.

    -

    Searching

    +

    πŸ”—Searching

    Call GET /search?query=YOUR_QUERY to search for notes. This end-point supports the field parameter which is recommended to use so that you only get the data that you need. The query syntax is as described in the main documentation: https://joplinapp.org/#searching

    -

    Notes

    -

    Properties

    +

    πŸ”—Notes

    +

    πŸ”—Properties

    @@ -450,13 +468,13 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
    -

    GET /notes

    +

    πŸ”—GET /notes

    Gets all notes

    -

    GET /notes/:id

    +

    πŸ”—GET /notes/:id

    Gets note with ID :id

    -

    GET /notes/:id/tags

    +

    πŸ”—GET /notes/:id/tags

    Gets all the tags attached to this note.

    -

    POST /notes

    +

    πŸ”—POST /notes

    Creates a new note

    You can either specify the note body as Markdown by setting the body parameter, or in HTML by setting the body_html.

    Examples:

    @@ -477,17 +495,17 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) { -

    Creating a note with a specific ID

    +

    πŸ”—Creating a note with a specific ID

    When a new note is created, it is automatically assigned a new unique ID so normally you do not need to set the ID. However, if for some reason you want to set it, you can supply it as the id property. It needs to be a 32 characters long hexadecimal string. Make sure it is unique, for example by generating it using whatever GUID function is available in your programming language.

      curl --data '{ "id": "00a87474082744c1a8515da6aa5792d2", "title": "My note with custom ID"}' http://127.0.0.1:41184/notes
     
    -

    PUT /notes/:id

    +

    πŸ”—PUT /notes/:id

    Sets the properties of the note with ID :id

    -

    DELETE /notes/:id

    +

    πŸ”—DELETE /notes/:id

    Deletes the note with ID :id

    -

    Folders

    +

    πŸ”—Folders

    This is actually a notebook. Internally notebooks are called "folders".

    -

    Properties

    +

    πŸ”—Properties

    @@ -544,21 +562,21 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
    -

    GET /folders

    +

    πŸ”—GET /folders

    Gets all folders

    The folders are returned as a tree. The sub-notebooks of a notebook, if any, are under the children key.

    -

    GET /folders/:id

    +

    πŸ”—GET /folders/:id

    Gets folder with ID :id

    -

    GET /folders/:id/notes

    +

    πŸ”—GET /folders/:id/notes

    Gets all the notes inside this folder.

    -

    POST /folders

    +

    πŸ”—POST /folders

    Creates a new folder

    -

    PUT /folders/:id

    +

    πŸ”—PUT /folders/:id

    Sets the properties of the folder with ID :id

    -

    DELETE /folders/:id

    +

    πŸ”—DELETE /folders/:id

    Deletes the folder with ID :id

    -

    Resources

    -

    Properties

    +

    πŸ”—Resources

    +

    πŸ”—Properties

    @@ -630,24 +648,24 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
    -

    GET /resources

    +

    πŸ”—GET /resources

    Gets all resources

    -

    GET /resources/:id

    +

    πŸ”—GET /resources/:id

    Gets resource with ID :id

    -

    GET /resources/:id/file

    +

    πŸ”—GET /resources/:id/file

    Gets the actual file associated with this resource.

    -

    POST /resources

    +

    πŸ”—POST /resources

    Creates a new resource

    Creating a new resource is special because you also need to upload the file. Unlike other API calls, this one must have the "multipart/form-data" Content-Type. The file data must be passed to the "data" form field, and the other properties to the "props" form field. An example of a valid call with cURL would be:

    curl -F 'data=@/path/to/file.jpg' -F 'props={"title":"my resource title"}' http://localhost:41184/resources
     

    The "data" field is required, while the "props" one is not. If not specified, default values will be used.

    -

    PUT /resources/:id

    +

    πŸ”—PUT /resources/:id

    Sets the properties of the resource with ID :id

    -

    DELETE /resources/:id

    +

    πŸ”—DELETE /resources/:id

    Deletes the resource with ID :id

    -

    Tags

    -

    Properties

    +

    πŸ”—Tags

    +

    πŸ”—Properties

    @@ -699,21 +717,21 @@ for (let portToTest = 41184; portToTest <= 41194; portToTest++) {
    -

    GET /tags

    +

    πŸ”—GET /tags

    Gets all tags

    -

    GET /tags/:id

    +

    πŸ”—GET /tags/:id

    Gets tag with ID :id

    -

    GET /tags/:id/notes

    +

    πŸ”—GET /tags/:id/notes

    Gets all the notes with this tag.

    -

    POST /tags

    +

    πŸ”—POST /tags

    Creates a new tag

    -

    POST /tags/:id/notes

    +

    πŸ”—POST /tags/:id/notes

    Post a note to this endpoint to add the tag to the note. The note data must at least contain an ID property (all other properties will be ignored).

    -

    PUT /tags/:id

    +

    πŸ”—PUT /tags/:id

    Sets the properties of the tag with ID :id

    -

    DELETE /tags/:id

    +

    πŸ”—DELETE /tags/:id

    Deletes the tag with ID :id

    -

    DELETE /tags/:id/notes/:note_id

    +

    πŸ”—DELETE /tags/:id/notes/:note_id

    Remove the tag from the note.