This package has been deprecated

Author message:

All Chipmunk services have been shut down.

@thinksquirrel/chipmunk
TypeScript icon, indicating that this package has built-in type declarations

0.8.10 • Public • Published

Chipmunk JavaScript SDK

Important Note

🚧 This SDK is currently in development. While we will try to maintain backwards compatibility, certain features may be added or removed at any time.

A Chipmunk account is required to use this SDK. You can sign up for one free here.

Please note that all API tokens currently have the full permissions of a user. Do not deploy API secrets publicly! Read-only public access via the JavaScript SDK is currently in development.

Installation

NPM:

npm install @thinksqurrel/chipmunk

Yarn:

yarn add @thinksquirrel/chipmunk

Usage

Basic usage

var chipmunk = require("@thinksquirrel/chipmunk").chipmunk;

var apiKey = "XXXXX"; // Your API key, under User Profile > API Keys
var apiSecret = "XXXXX"; // API secret, do not share this value

chipmunk.config({ apiKey, apiSecret });

chipmunk.collections
  .getAll()
  .request()
  .then(function(collectionList) {
    console.log("%s collection(s) total:", collectionList.count);
    collectionList.result.forEach(function(collection) {
      console.log(
        "    - %s: %s",
        collection.title,
        collection.summary || "No description available",
      );
    });
  });

Multiple API instances

var chipmunk = require("@thinksquirrel/chipmunk").chipmunk;

var apiKey = "XXXXX"; // Your API key, under User Profile > API Keys
var apiSecret = "XXXXX"; // API secret, do not share this value

const apiInstance = chipmunk.createInstance({ apiKey, apiSecret });

apiInstance.collections
  .getAll()
  .request()
  .then(function(collectionList) {
    console.log("%s collection(s) total:", collectionList.count);
    collectionList.result.forEach(function(collection) {
      console.log(
        "    - %s: %s",
        collection.title,
        collection.summary || "No description available",
      );
    });
  });

Downloading a revision

var chipmunk = require("@thinksquirrel/chipmunk").chipmunk;

var apiKey = "XXXXX"; // Your API key, under User Profile > API Keys
var apiSecret = "XXXXX"; // API secret, do not share this value
var assetId = "XXXXX"; // IDs for resources can be discovered through the API

// Initialize
chipmunk.config({ apiKey, apiSecret });

// Get asset information
// In the API, assets are named "items"
chipmunk.items
  .get({ id: assetId })
  .request()
  .then(function(myAsset) {
    console.log(
      "Downloading '%s' from '%s'...",
      myAsset.head.fileName,
      myAsset.title,
    );

    // Download an asset's current revision ("head")
    return chipmunk.revisions.get
      .download({
        id: myAsset.head.id,
      })
      .request()
      .then(function(downloadToken) {
        console.log("URL: %s", downloadToken.url); // Temporary URL to the file
      });
  });

See our API for more details.

Readme

Keywords

none

Package Sidebar

Install

npm i @thinksquirrel/chipmunk

Weekly Downloads

0

Version

0.8.10

License

MIT

Unpacked Size

63.2 kB

Total Files

62

Last publish

Collaborators

  • jbroderick9729
  • lmontoute