Methods
delete
- delete(path: Path, query?: any): Promise<any>
-
Parameters
-
-
Default value query: any = null
get
- get(path: Path, query?: any): Promise<any>
-
Parameters
-
-
Default value query: any = null
itemType
- itemType(itemId: string): Promise<ModelType>
post
- post(path: Path, query?: any, body?: any, files?: any[]): Promise<any>
-
Parameters
-
-
Default value query: any = null
-
Default value body: any = null
-
Default value files: any[] = null
put
- put(path: Path, query?: any, body?: any, files?: any[]): Promise<any>
-
Parameters
-
-
Default value query: any = null
-
Default value body: any = null
-
Default value files: any[] = null
resourcePath
- resourcePath(resourceId: string): Promise<string>
userDataDelete
- userDataDelete(itemType: ModelType, itemId: string, key: string): Promise<void>
-
Parameters
-
itemType: ModelType
-
itemId: string
-
key: string
userDataGet
- userDataGet<T>(itemType: ModelType, itemId: string, key: string): Promise<T>
-
Type parameters
Parameters
-
itemType: ModelType
-
itemId: string
-
key: string
userDataSet
- userDataSet<T>(itemType: ModelType, itemId: string, key: string, value: T): Promise<void>
-
Type parameters
Parameters
-
itemType: ModelType
-
itemId: string
-
key: string
-
value: T
This module provides access to the Joplin data API: https://joplinapp.org/help/api/references/rest_api This is the main way to retrieve data, such as notes, notebooks, tags, etc. or to update them or delete them.
This is also what you would use to search notes, via the
search
endpoint.View the demo plugin
In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. And each method takes these parameters:
path
: This is an array that represents the path to the resource in the form["resourceName", "resourceId", "resourceLink"]
(eg. ["tags", ":id", "notes"]). The "resources" segment is the name of the resources you want to access (eg. "notes", "folders", etc.). If not followed by anything, it will refer to all the resources in that collection. The optional "resourceId" points to a particular resources within the collection. Finally, an optional "link" can be present, which links the resource to a collection of resources. This can be used in the API for example to retrieve all the notes associated with a tag.query
: (Optional) The query parameters. In a URL, this is the part after the question mark "?". In this case, it should be an object with key/value pairs.data
: (Optional) Applies to PUT and POST calls only. The request body contains the data you want to create or modify, for example the content of a note or folder.files
: (Optional) Used to create new resources and associate them with files.Please refer to the Joplin API documentation for complete details about each call. As the plugin runs within the Joplin application you do not need an authorisation token to use this API.
For example:
// Get a note ID, title and body const noteId = 'some_note_id'; const note = await joplin.data.get(['notes', noteId], { fields: ['id', 'title', 'body'] }); // Get all folders const folders = await joplin.data.get(['folders']); // Set the note body await joplin.data.put(['notes', noteId], null, { body: "New note body" }); // Create a new note under one of the folders await joplin.data.post(['notes'], null, { body: "my new note", title: "some title", parent_id: folders[0].id });