Description of image

How to Generate a Core API Key and Install the CLI and SDKs

Core provides a RESTful API and a number of client libraries to manage compute resources programmatically. A new GraphQL API is under development and in use for some resources.

Banner

How to Generate an API Key

To use the Paperspace Core API you first need to generate an API key.

API keys are available from the API Keys tab in the Team Settings menu of the Paperspace console.

Navigate to the API Keys tab

Once in the API Keys tab, create an API key with a memorable name.

API Keys

The only time the API Key is available to copy is during creation of the key. So be sure to copy the key at this time.

Copy API Key

After the key is copied, the name of the key is available in the list of API Keys.

List of API Keys

How to install the CLI

To install the Paperspace CLI, you need to have Node.js v8.12.0 or later installed.

Once Node is installed, check the Node version:

node -v

Node.js comes bundled with npm, the Node package management tool.

To install the CLI, you need to install the package globally with -g flag:

npm install -g paperspace-node

We can now invoke the Paperspace CLI from the command line. To check the version of the package:

paperspace -v

Now that the CLI is installed, we can now run commands in the CLI tab.

How to install the Node client library

The Paperspace Node.js client library is bundled with the CLI, so the installation method is similar.

To install the Node.js client library, you need to have Node.js v8.12.0 or later installed.

To check the version of Node.js installed on your machine run:

node -v

Node.js comes bundled with npm, the Node.js package management tool.

We then install the Node.js client library without using the -g flag:

npm install paperspace-node

We recommend installing the paperspace-node package globally so that the paperspace command is available on your command line everywhere on your system. If you want to make it available only within an individual Node.js project, you can install it for use only in the current directory by omitting the -g flag.

To use the Node.js library within your Node.js app, import the package:

var paperspace_node = require("paperspace-node");

Then create an instance of the client, optionally passing in your API key:

var paperspace = paperspace_node({
  apiKey: "1ba4f98e7c0...", // <- paste your api key here
});

If you do not pass an apiKey parameter, the paperspace-node module looks for the environment variable value named PAPERSPACE_API_KEY.

It’s also possible to use the cached api key location created by the paperspace login command which is stored at ~/.paperspace/config.json.

var paperspace = paperspace_node();

You can get the paperspace-node version programmatically via the VERSION attribute:

var version = paperspace_node.VERSION;

Now that the Node.js client is installed, refer to the API reference for command details.

How to install the Go client library

package main

import (
    paperspace "github.com/Paperspace/paperspace-go"
)

func getClient() *paperspace.Client {
    client := paperspace.NewClient()
    client.APIKey = p.APIKey
    return client
}

Environment variables

PAPERSPACE_APIKEY: Paperspace API key
PAPERSPACE_BASEURL: Paperspace API url
PAPERSPACE_DEBUG: Enable debugging
PAPERSPACE_DEBUG_BODY: Enable debug for response body

Now that the Go client is installed, refer to the API reference for command details.