UNPKG

signalk-server

Version:

An implementation of a [Signal K](http://signalk.org) server for boats.

136 lines (114 loc) 24.2 kB
<!DOCTYPE html><html class="default" lang="en" data-base="../../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Resources API | Signal K</title><meta name="description" content="Documentation for Signal K"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../../assets/style.css?cache=1767726585343"/><link rel="stylesheet" href="../../assets/highlight.css?cache=1767726585343"/><script defer src="../../assets/main.js?cache=1767726585343"></script><script async src="../../assets/icons.js?cache=1767726585343" id="tsd-icons-script"></script><script async src="../../assets/search.js?cache=1767726585343" id="tsd-search-script"></script><script async src="../../assets/navigation.js?cache=1767726585343" id="tsd-nav-script"></script><script async src="../../assets/hierarchy.js?cache=1767726585343" id="tsd-hierarchy-script"></script><link rel="stylesheet" href="../../assets/theme.css"/></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../../index.html" class="title"><img src="../../assets/logo.svg" alt="Signal K"/></a><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../../assets/icons.svg#icon-search"></use></svg><span class="visible@s">Search</span></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><div id="tsd-toolbar-links"><a href="https://discord.gg/uuZrwz4dCS" target="_blank" rel="noopener" class="toolbar-icon visible@s" aria-label="Discord"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M524.5 69.8a1.5 1.5 0 0 0 -.8-.7A485.1 485.1 0 0 0 404.1 32a1.8 1.8 0 0 0 -1.9 .9 337.5 337.5 0 0 0 -14.9 30.6 447.8 447.8 0 0 0 -134.4 0 309.5 309.5 0 0 0 -15.1-30.6 1.9 1.9 0 0 0 -1.9-.9A483.7 483.7 0 0 0 116.1 69.1a1.7 1.7 0 0 0 -.8 .7C39.1 183.7 18.2 294.7 28.4 404.4a2 2 0 0 0 .8 1.4A487.7 487.7 0 0 0 176 479.9a1.9 1.9 0 0 0 2.1-.7A348.2 348.2 0 0 0 208.1 430.4a1.9 1.9 0 0 0 -1-2.6 321.2 321.2 0 0 1 -45.9-21.9 1.9 1.9 0 0 1 -.2-3.1c3.1-2.3 6.2-4.7 9.1-7.1a1.8 1.8 0 0 1 1.9-.3c96.2 43.9 200.4 43.9 295.5 0a1.8 1.8 0 0 1 1.9 .2c2.9 2.4 6 4.9 9.1 7.2a1.9 1.9 0 0 1 -.2 3.1 301.4 301.4 0 0 1 -45.9 21.8 1.9 1.9 0 0 0 -1 2.6 391.1 391.1 0 0 0 30 48.8 1.9 1.9 0 0 0 2.1 .7A486 486 0 0 0 610.7 405.7a1.9 1.9 0 0 0 .8-1.4C623.7 277.6 590.9 167.5 524.5 69.8zM222.5 337.6c-29 0-52.8-26.6-52.8-59.2S193.1 219.1 222.5 219.1c29.7 0 53.3 26.8 52.8 59.2C275.3 311 251.9 337.6 222.5 337.6zm195.4 0c-29 0-52.8-26.6-52.8-59.2S388.4 219.1 417.9 219.1c29.7 0 53.3 26.8 52.8 59.2C470.7 311 447.5 337.6 417.9 337.6z"></path></svg></a><a href="https://github.com/SignalK/signalk-server" target="_blank" rel="noopener" class="toolbar-icon visible@s" aria-label="Discord"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"></path></svg></a><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../../Developing.html">Developing</a></li><li><a href="../REST_APIs.html">REST APIs</a></li><li><a href="" aria-current="page">Resources API</a></li></ul></div><div class="tsd-panel tsd-typography"><h1 id="working-with-the-resources-api" class="tsd-anchor-link">Working with the Resources API<a href="#working-with-the-resources-api" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../../assets/icons.svg#icon-anchor"></use></svg></a></h1><p>The SignalK specification defines a number of resources (routes, waypoints, notes, regions &amp; charts) each with its own path under the root <code>resources</code> path <em>(e.g. <code>/signalk/v2/api/resources/routes</code>)</em>.</p> <p>Additionally, the <code>/resources</code> path can be used to host other user defined resource types, each grouped within its own folder <em>(e.g. <code>/signalk/v2/api/resources/fishingZones</code>)</em>.</p> <p>The <em>Resources API</em> validates requests to these resource paths and passes them to a <a href="../Plugins/Resource_Providers.html">Resource Provider plugin</a> for storage and retrieval.</p> <p>Client applications can then use <code>HTTP</code> requests to these paths to store (<code>POST</code>, <code>PUT</code>), retrieve (<code>GET</code>) and remove (<code>DELETE</code>) resource entries.</p> <p><em>Note: the ability to store resource entries is controlled by the server security settings so client applications may need to authenticate for write / delete operations to complete successfully.</em></p> <h3 id="retrieving-resources" class="tsd-anchor-link">Retrieving Resources<a href="#retrieving-resources" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../../assets/icons.svg#icon-anchor"></use></svg></a></h3><hr> <p>Resource entries are retrived by submitting an HTTP <code>GET</code> request to the relevant path.</p> <p>For example to return a list of all available routes</p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/routes&#39;</span> </code><button type="button">Copy</button></pre> <p>or alternatively fetch a specific route.</p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/routes/94052456-65fa-48ce-a85d-41b78a9d2111&#39;</span> </code><button type="button">Copy</button></pre> <p>A filtered list of entries can be retrieved based on criteria such as:</p> <ul> <li>being within a bounded area</li> <li>distance from vessel</li> <li>total entries returned</li> <li>map zoom level</li> </ul> <p>by supplying a query string containing <code>key | value</code> pairs in the request.</p> <p><em>Example 1: Retrieve waypoints within 50km of the vessel. Note: distance in meters value should be provided.</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints?distance=50000&#39;</span> </code><button type="button">Copy</button></pre> <p><em>Example 2: Retrieve up to 20 waypoints within 90km of the vessel.</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints?distance=90000&amp;limit=20&#39;</span> </code><button type="button">Copy</button></pre> <p><em>Example 3: Retrieve waypoints within a bounded area. Note: the bounded area is supplied as bottom left &amp; top right corner coordinates in the form swLongitude,swLatitude,neLongitude,neLatitude</em>.</p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints?bbox=[-135.5,38,-134,38.5]&#39;</span> </code><button type="button">Copy</button></pre> <p><em>Example 4: Return notes for display on a map view at zoom level 5.</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/notes?zoom=5&#39;</span> </code><button type="button">Copy</button></pre> <p>It is up to the provider to determine which resource entries are returned for any given zoom level. As a guide we recommend alignment with the criteria in the following document: <a href="https://wiki.openstreetmap.org/wiki/Zoom_levels_">https://wiki.openstreetmap.org/wiki/Zoom_levels_</a>.</p> <h3 id="deleting-resources" class="tsd-anchor-link">Deleting Resources<a href="#deleting-resources" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../../assets/icons.svg#icon-anchor"></use></svg></a></h3><hr> <p>Resource entries are deleted by submitting an HTTP <code>DELETE</code> request to a path containing the <code>id</code> of the resource to delete.</p> <p><em>Example: Delete from storage the route with id <code>94052456-65fa-48ce-a85d-41b78a9d2111</code>.</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">DELETE</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/routes/94052456-65fa-48ce-a85d-41b78a9d2111&#39;</span> </code><button type="button">Copy</button></pre> <h3 id="creating--updating-resources" class="tsd-anchor-link">Creating / updating Resources<a href="#creating--updating-resources" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../../assets/icons.svg#icon-anchor"></use></svg></a></h3><hr> <p><strong>Creating a new resource entry:</strong></p> <p>Resource entries are created by submitting an HTTP <code>POST</code> request to a path for the relevant resource type.</p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">POST</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/routes&#39;</span><span class="hl-0"> {resource_data}</span> </code><button type="button">Copy</button></pre> <p>The new resource is created and its <code>id</code> (generated by the server) is returned in the response message.</p> <pre><code class="JSON"><span class="hl-0">{</span><br/><span class="hl-0"> </span><span class="hl-3">&quot;state&quot;</span><span class="hl-0">: </span><span class="hl-4">&quot;COMPLETED&quot;</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-3">&quot;statusCode&quot;</span><span class="hl-0">: </span><span class="hl-2">200</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-3">&quot;id&quot;</span><span class="hl-0">: </span><span class="hl-4">&quot;94052456-65fa-48ce-a85d-41b78a9d2111&quot;</span><br/><span class="hl-0">}</span> </code><button type="button">Copy</button></pre> <p><em>Note: Each <code>POST</code> will generate a new <code>id</code> so if the resource data remains the same duplicate resources will be created.</em></p> <p><strong>Updating a resource entry:</strong></p> <p>Resource entries are updated by submitting an HTTP <code>PUT</code> request to a path for the relevant resource type that includes the resource <code>id</code>.</p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">PUT</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints/94052456-65fa-48ce-a85d-41b78a9d2111&#39;</span> </code><button type="button">Copy</button></pre> <p>As the <code>PUT</code> request replaces the record with the supplied <code>id</code>, the submitted resource data should contain a complete record for the resource type being written.</p> <p>Each resource type has a specific set of attributes that are required to be supplied before the resource entry can be created or updated.</p> <p>If either the submitted resource data or the resource id are invalid then the operation is aborted._</p> <p><em>Note: the submitted resource data is validated against the OpenApi schema definition for the relevant resource type.</em></p> <hr> <h2 id="multiple-providers-for-a-resource-type" class="tsd-anchor-link">Multiple Providers for a Resource Type<a href="#multiple-providers-for-a-resource-type" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../../assets/icons.svg#icon-anchor"></use></svg></a></h2><p>The Resources API will allow for multiple plugins to register as a provider for the same resource type.</p> <p>When this scenario occurs the server services request in the following ways:</p> <p><strong>Listing entries:</strong></p> <p>When a list of resources is requested</p> <p><em>for example:</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints&#39;</span> </code><button type="button">Copy</button></pre> <p>each registered provider will be asked to return matching entries and the server aggregates the results and returns them to the client.</p> <hr> <p><strong>Requests for specific resources:</strong></p> <p>When a request is received for a specific resource</p> <p><em>for example:</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints/94052456-65fa-48ce-a85d-41b78a9d2111&#39;</span><br/><br/><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">PUT</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints/94052456-65fa-48ce-a85d-41b78a9d2111&#39;</span><br/><br/><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">DELETE</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints/94052456-65fa-48ce-a85d-41b78a9d2111&#39;</span> </code><button type="button">Copy</button></pre> <p>each registered provider will polled to determine which one owns the entry with the supplied id. The provider with the resource entry is then the target of the requested operation (<code>getResource()</code>, <code>setResource()</code>, <code>deleteResource()</code>).</p> <hr> <p><strong>Creating new resource entries:</strong></p> <p>When a request is received to create a new resource</p> <p><em>for example:</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">POST</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints&#39;</span> </code><button type="button">Copy</button></pre> <p>By default the first provider that was registered for that resource type will be the target of the requested operation (<code>setResource()</code>).</p> <p>You can view the registered providers for a resource type by making the following request:</p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/{resourceType}/_providers&#39;</span> </code><button type="button">Copy</button></pre> <p>_Example: `HTTP GET '<a href="http://hostname:3000/signalk/v2/api/resources/charts/%5C_providers">http://hostname:3000/signalk/v2/api/resources/charts/\_providers</a>'</p> <pre><code class="JSON"><span class="hl-0">[</span><br/><span class="hl-0"> </span><span class="hl-4">&quot;charts&quot;</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-4">&quot;resources-provider&quot;</span><br/><span class="hl-0">]</span> </code><button type="button">Copy</button></pre> <p>You can retrieve the default provider for a resource type by making the following request:</p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/{resourceType}/_providers/_default&#39;</span> </code><button type="button">Copy</button></pre> <p>Example: `HTTP GET '<a href="http://hostname:3000/signalk/v2/api/resources/charts/%5C_providers/%5C_default">http://hostname:3000/signalk/v2/api/resources/charts/\_providers/\_default</a>'</p> <pre><code class="JSON"><span class="hl-4">&quot;resources-provider&quot;</span> </code><button type="button">Copy</button></pre> <p>You can change the provider used for writing a resource record in the following ways:</p> <ol> <li>Per-request by using the <code>?provider=</code> query parameter.</li> <li>Setting a &quot;default&quot; provider for a specific resource type</li> </ol> <p><strong>1. Per-request by using the <code>?provider=</code> query parameter:</strong></p> <p>When multiple providers are registered for a resource type the client can specify which provider should be the target of the request by using the query parameter <code>provider</code>.</p> <p><em>Example:</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints?provider=my-plugin-id&#39;</span><br/><br/><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints/94052456-65fa-48ce-a85d-41b78a9d2111?provider=my-plugin-id&#39;</span><br/><br/><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">PUT</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints/94052456-65fa-48ce-a85d-41b78a9d2111?provider=my-plugin-id&#39;</span><br/><br/><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">DELETE</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints/94052456-65fa-48ce-a85d-41b78a9d2111?provider=my-plugin-id&#39;</span><br/><br/><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">POST</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/waypoints?provider=my-plugin-id&#39;</span> </code><button type="button">Copy</button></pre> <p>the value assigned to <code>provider</code> is the <code>plugin id</code> of the resource provider plugin.</p> <p>The plugin id can be obtained from the Signal K server url _<a href="http://hostname:3000/skServer/plugins_">http://hostname:3000/skServer/plugins_</a>.</p> <p><em>Example:</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">GET</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/plugins&#39;</span> </code><button type="button">Copy</button></pre> <pre><code class="JSON"><span class="hl-0">[</span><br/><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-3">&quot;id&quot;</span><span class="hl-0">: </span><span class="hl-4">&quot;mysk-resource-plugin&quot;</span><span class="hl-0">, </span><span class="hl-6">// &lt;-- plugin id</span><br/><span class="hl-0"> </span><span class="hl-3">&quot;name&quot;</span><span class="hl-0">: </span><span class="hl-4">&quot;Resources Provider&quot;</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-3">&quot;packageName&quot;</span><span class="hl-0">: </span><span class="hl-4">&quot;mysk-resource-plugin&quot;</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-3">&quot;version&quot;</span><span class="hl-0">: </span><span class="hl-4">&quot;1.3.0&quot;</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-7">...</span><br/><span class="hl-0"> },</span><br/><span class="hl-0"> </span><span class="hl-7">...</span><br/><span class="hl-0">]</span> </code><button type="button">Copy</button></pre> <p><strong>2. Setting a default provider for a resource type:</strong></p> <p>To change the default provider for a resource type make a POST request to _<a href="http://hostname:3000/signalk/v2/api/resources/%7BresourceType%7D/%5C_providers/%5C_default/%7BpluginId%7D_">http://hostname:3000/signalk/v2/api/resources/{resourceType}/\_providers/\_default/{pluginId}_</a> where <code>pluginId</code> is the id of resource provider plugin.</p> <p><em>Example: Direct create new chart source entries to <code>my-chart-plugin</code>.</em></p> <pre><code class="typescript"><span class="hl-2">HTTP</span><span class="hl-0"> </span><span class="hl-2">POST</span><span class="hl-0"> </span><span class="hl-4">&#39;http://hostname:3000/signalk/v2/api/resources/charts/_providers/_default/my-chart-plugin&#39;</span> </code><button type="button">Copy</button></pre> </div></div><div class="col-sidebar"><div class="page-menu"><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><ul><li><a href="#retrieving-resources"><span>Retrieving <wbr/>Resources</span></a></li><li><a href="#deleting-resources"><span>Deleting <wbr/>Resources</span></a></li><li><a href="#creating--updating-resources"><span>Creating / updating <wbr/>Resources</span></a></li></ul><a href="#multiple-providers-for-a-resource-type"><span>Multiple <wbr/>Providers for a <wbr/>Resource <wbr/>Type</span></a></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../../modules.html">Signal K</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>