1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-03-23 21:09:30 +02:00
2020-11-06 21:52:57 +00:00

416 lines
22 KiB
HTML

<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>joplin.data | Joplin Plugin API Documentation</title>
<meta name="description" content="Documentation for Joplin Plugin API Documentation">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="joplin.html" class="title">Joplin Plugin API Documentation</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<!--
<li>
<a href="../globals.html">Globals</a>
</li>
-->
<li>
<a href="joplindata.html">joplin.data</a>
</li>
</ul>
<h1><!-- Class -->joplin.data</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-comment">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>This module provides access to the Joplin data API: <a href="https://joplinapp.org/api/references/rest_api/">https://joplinapp.org/api/references/rest_api/</a>
This is the main way to retrieve data, such as notes, notebooks, tags, etc.
or to update them or delete them.</p>
</div>
<p>This is also what you would use to search notes, via the <code>search</code> endpoint.</p>
<p><a href="https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple">View the demo plugin</a></p>
<p>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:</p>
<ul>
<li><code>path</code>: This is an array that represents the path to the resource in the form <code>[&quot;resouceName&quot;, &quot;resourceId&quot;, &quot;resourceLink&quot;]</code> (eg. [&quot;tags&quot;, &quot;:id&quot;, &quot;notes&quot;]). The &quot;resources&quot; segment is the name of the resources you want to access (eg. &quot;notes&quot;, &quot;folders&quot;, etc.). If not followed by anything, it will refer to all the resources in that collection. The optional &quot;resourceId&quot; points to a particular resources within the collection. Finally, an optional &quot;link&quot; 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.</li>
<li><code>query</code>: (Optional) The query parameters. In a URL, this is the part after the question mark &quot;?&quot;. In this case, it should be an object with key/value pairs.</li>
<li><code>data</code>: (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.</li>
<li><code>files</code>: (Optional) Used to create new resources and associate them with files.</li>
</ul>
<p>Please refer to the <a href="https://joplinapp.org/api/references/rest_api/">Joplin API documentation</a> for complete details about each call. As the plugin runs within the Joplin application <strong>you do not need an authorisation token</strong> to use this API.</p>
<p>For example:</p>
<pre><code class="language-typescript"><span class="hljs-comment">// Get a note ID, title and body</span>
<span class="hljs-keyword">const</span> noteId = <span class="hljs-string">&#x27;some_note_id&#x27;</span>;
<span class="hljs-keyword">const</span> note = <span class="hljs-keyword">await</span> joplin.data.get([<span class="hljs-string">&#x27;notes&#x27;</span>, noteId], { <span class="hljs-attr">fields</span>: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;body&#x27;</span>] });
<span class="hljs-comment">// Get all folders</span>
<span class="hljs-keyword">const</span> folders = <span class="hljs-keyword">await</span> joplin.data.get([<span class="hljs-string">&#x27;folders&#x27;</span>]);
<span class="hljs-comment">// Set the note body</span>
<span class="hljs-keyword">await</span> joplin.data.put([<span class="hljs-string">&#x27;notes&#x27;</span>, noteId], <span class="hljs-literal">null</span>, { <span class="hljs-attr">body</span>: <span class="hljs-string">&quot;New note body&quot;</span> });
<span class="hljs-comment">// Create a new note under one of the folders</span>
<span class="hljs-keyword">await</span> joplin.data.post([<span class="hljs-string">&#x27;notes&#x27;</span>], <span class="hljs-literal">null</span>, { <span class="hljs-attr">body</span>: <span class="hljs-string">&quot;my new note&quot;</span>, <span class="hljs-attr">title</span>: <span class="hljs-string">&quot;some title&quot;</span>, <span class="hljs-attr">parent_id</span>: folders[<span class="hljs-number">0</span>].id });</code></pre>
</div>
</section>
<!--
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="target">JoplinData</span>
</li>
</ul>
</section>
-->
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Methods</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-method tsd-parent-kind-class"><a href="joplindata.html#delete" class="tsd-kind-icon">delete</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="joplindata.html#get" class="tsd-kind-icon">get</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="joplindata.html#post" class="tsd-kind-icon">post</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="joplindata.html#put" class="tsd-kind-icon">put</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Methods</h2>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="delete" class="tsd-anchor"></a>
<h3>delete</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">delete<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><a href="../globals.html#path" class="tsd-signature-type">Path</a>, query<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <a href="../globals.html#path" class="tsd-signature-type">Path</a></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> query: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
</ul>
<!-- JOPLINCHANGE
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
-->
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="get" class="tsd-anchor"></a>
<h3>get</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">get<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><a href="../globals.html#path" class="tsd-signature-type">Path</a>, query<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <a href="../globals.html#path" class="tsd-signature-type">Path</a></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> query: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
</ul>
<!-- JOPLINCHANGE
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
-->
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="post" class="tsd-anchor"></a>
<h3>post</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">post<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><a href="../globals.html#path" class="tsd-signature-type">Path</a>, query<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, body<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, files<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <a href="../globals.html#path" class="tsd-signature-type">Path</a></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> query: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> body: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> files: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
</ul>
<!-- JOPLINCHANGE
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
-->
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="put" class="tsd-anchor"></a>
<h3>put</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">put<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><a href="../globals.html#path" class="tsd-signature-type">Path</a>, query<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, body<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, files<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <a href="../globals.html#path" class="tsd-signature-type">Path</a></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> query: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> body: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> files: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> = null</span></h5>
</li>
</ul>
<!-- JOPLINCHANGE
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
-->
</li>
</ul>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<!--
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="../globals.html"><em>Globals</em></a>
</li>
</ul>
</nav>
-->
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-enum">
<a href="../enums/contentscripttype.html" class="tsd-kind-icon">ContentScriptType</a>
</li>
<li class=" tsd-kind-enum">
<a href="../enums/filesystemitem.html" class="tsd-kind-icon">FileSystemItem</a>
</li>
<li class=" tsd-kind-enum">
<a href="../enums/importmoduleoutputformat.html" class="tsd-kind-icon">ImportModuleOutputFormat</a>
</li>
<li class=" tsd-kind-enum">
<a href="../enums/menuitemlocation.html" class="tsd-kind-icon">MenuItemLocation</a>
</li>
<li class=" tsd-kind-enum">
<a href="../enums/settingitemtype.html" class="tsd-kind-icon">SettingItemType</a>
</li>
<li class=" tsd-kind-enum">
<a href="../enums/toolbarbuttonlocation.html" class="tsd-kind-icon">ToolbarButtonLocation</a>
</li>
<li class=" tsd-kind-class">
<a href="joplin.html" class="tsd-kind-icon">joplin</a>
</li>
<li class=" tsd-kind-class">
<a href="joplincommands.html" class="tsd-kind-icon">joplin.commands</a>
</li>
</ul>
<ul class="current">
<li class="current tsd-kind-class">
<a href="joplindata.html" class="tsd-kind-icon">joplin.data</a>
<ul>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="joplindata.html#delete" class="tsd-kind-icon">delete</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="joplindata.html#get" class="tsd-kind-icon">get</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="joplindata.html#post" class="tsd-kind-icon">post</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="joplindata.html#put" class="tsd-kind-icon">put</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
<li class=" tsd-kind-class">
<a href="joplininterop.html" class="tsd-kind-icon">joplin.interop</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinplugins.html" class="tsd-kind-icon">joplin.plugins</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinsettings.html" class="tsd-kind-icon">joplin.settings</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinviews.html" class="tsd-kind-icon">joplin.views</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinviewsdialogs.html" class="tsd-kind-icon">joplin.views.dialogs</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinviewsmenuitems.html" class="tsd-kind-icon">joplin.views.menuItems</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinviewsmenus.html" class="tsd-kind-icon">joplin.views.menus</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinviewspanels.html" class="tsd-kind-icon">joplin.views.panels</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinviewstoolbarbuttons.html" class="tsd-kind-icon">joplin.views.toolbarButtons</a>
</li>
<li class=" tsd-kind-class">
<a href="joplinworkspace.html" class="tsd-kind-icon">joplin.workspace</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/buttonspec.html" class="tsd-kind-icon">ButtonSpec</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/command.html" class="tsd-kind-icon">Command</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/createmenuitemoptions.html" class="tsd-kind-icon">CreateMenuItemOptions</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/editorcommand.html" class="tsd-kind-icon">EditorCommand</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/exportcontext.html" class="tsd-kind-icon">ExportContext</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/exportmodule.html" class="tsd-kind-icon">ExportModule</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/exportoptions.html" class="tsd-kind-icon">ExportOptions</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/importcontext.html" class="tsd-kind-icon">ImportContext</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/importmodule.html" class="tsd-kind-icon">ImportModule</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/menuitem.html" class="tsd-kind-icon">MenuItem</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/script.html" class="tsd-kind-icon">Script</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/settingitem.html" class="tsd-kind-icon">SettingItem</a>
</li>
<li class=" tsd-kind-interface">
<a href="../interfaces/settingsection.html" class="tsd-kind-icon">SettingSection</a>
</li>
<li class=" tsd-kind-type-alias">
<a href="../globals.html#buttonid" class="tsd-kind-icon">ButtonId</a>
</li>
<li class=" tsd-kind-type-alias">
<a href="../globals.html#path" class="tsd-kind-icon">Path</a>
</li>
<li class=" tsd-kind-type-alias">
<a href="../globals.html#viewhandle" class="tsd-kind-icon">ViewHandle</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<!-- JOPLINCHANGE
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
-->
<div class="overlay"></div>
<script src="../assets/js/main.js"></script>
</body>
</html>