Server-Hosted Skynet Usage


Most of this documentation assumes you're interacting with Skynet from a client-side, browser context, using skynet-nodejs. This guide will walk you through some of the main considerations of interacting with Skynet from a server-side context.
If you are working with us as a partner, please reach out to [email protected] (Discord dghelm#8125) for a promo code for a free elevated tier account.
If you're migrating from, you might start with reading Moving Off of
Previous versions of this page recommended mixing skynet-js and skynet-nodejs usage in a single project. We now suggest developers only use one or the other, depending on how their code will be run.

Skynet SDK Capabilities

Currently, only our NodeJS SDK has all the features addressed in this article.
Skyfile Upload
Skyfile Download
MySky + DACs
Large File Upload (tus)
Registry Access
Resolver Skylink Set
Portal Account
File Pinning
Looking to contribute? Many of these features are thin abstractions over our HTTP APIs. Take a look at open issues in the Python SDK and Go SDK.

File Uploads

skynet-js currently only supports browser uploads. You will want to upload files using one of our other SDK or CLI tools (ie @skynetlabs/skynet-nodejs).
The node SDK has been updated to support large file uploads in version 2.1.0. The tus protocol will automatically be used for any file >40MB.

File Persistence

In a browser context, cookies containing encrypted JWTs are used for linking file uploads to your portal account. This is needed for pinning files >90 days or accessing account-only portals.
If your upload method does not support cookies and your file needs to persist longer than 90 days, you will want to upload your file using a Skynet API Key or your encrypted JSON Web Token (located in the skynet-jwt cookie.

Using your Skynet API Key with skynet-nodejs

To use a Skynet API Key, you will specify a skynetApiKey when you initialize your client.
const { SkynetClient } = require('@skynetlabs/skynet-nodejs');
const client = new SkynetClient('', {skynetApiKey: SKYNET_API_KEY});

Obtaining your Skynet API Key

Private API keys for interacting with portals will be officially released in April 2022, and using JWTs will be deprecated.
Currently, no UI exists in the portal dashboard for creating new API keys for your account. If you wish to manually create one, visit your account dashboard page, and run the following in your browser's developer tools console:
fetch("/api/user/apikeys", {method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({public:"false"})}).then((r) => r.json()).then(console.log)
Then, copy the key field from the response. You can generate additional Skynet API Keys, but you cannot view this key again.
Access to this key allows full access to your portal account. It should be kept private. Do not share it or commit it to your repo. This feature is still experimental and the scope of permissions granted may change before a full release.

Using your JWT with skynet-nodejs

To use your account JWT, you will specify a customCookie when you initialize your client.
const { SkynetClient } = require('@skynetlabs/skynet-nodejs');
const client = new SkynetClient('', {customCookie: SKYNET_JWT});
Do not commit the value of SKYNET_JWT to the repo and be sure the value is formatred to be begins with skynet-jwt=.
We do not suggest trying to set customCookie in skynet-js since browsers will not include this cookie header in browser requests.

Obtaining your JWT

Currently, we don't yet support API keys for accounts, so you need to obtain the value for your JSON web token.
  1. 1.
    First, login to your account at
  2. 2.
    Press F12 to open your developer tools, select the “Application” tab
  3. 3.
    In the bar at left, under “Storage”, find “” under “Cookies”
  4. 4.
    Locate the item named “skynet-jwt” and copy-paste its value, but make sure the string is prefixed with skynet-jwt=.
To pin a skylink, first initialize your Skynet Client to use your JWT. After initializing the client with a custom cookie, call client.pinSkylink(skylink);

Cookie / JWT Expiration

JWTs expire after 720 hours and we have no tooling to detect if your JWT is expired. We don’t currently support API Keys, so please reach out to our team if you want a longer expiration time on your JWT.

Resolver Skylink Creation

One common use-case for server-side applications is to upload files that are pointed to using a resolver skylink, so that the data can be consumed using a consistent URL.
Here is a code example:
const { SkynetClient, genKeyPairFromSeed } = require("@skynetlabs/skynet-nodejs");
const { SKYNET_JWT, SECRET_SEED } = require './consts';
const portal = '';
const client = new SkynetClient(portal, { customCookie: SKYNET_JWT })
// Setup Keys for Read/Write of Mutable Data
const { privateKey, publicKey } = genKeyPairFromSeed( SECRET_SEED );
const dataKey = 'nameForRegistryEntry';
// skylink to point to with resolver skylink
const skylink = "sia://MABdWWku6YETM2zooGCjQi26Rs4a6Hb74q26i-vMMcximQ";
// Set Registry Entry to point at our Skylink
await client.db.setDataLink(privateKey, dataKey, skylink);
// Get the resolver skylink that represents the registry entry
const resolverSkylink = await client.registry.getEntryLink(publicKey, dataKey);
// Get the URL for the resolver skylink, at ``
const resolverSkylinkUrl = await client.getSkylinkUrl(resolverSkylink);