npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

amazon-drive

v2.1.1

Published

Amazon Drive API client

Readme

Amazon Drive Node.js Client

Simple rest client based on the cloud drive API: https://developer.amazon.com/public/apis/experience/cloud-drive/content/restful-api-getting-started

This is a Promise based API.

js-standard-style

Authentication

Amazon Drive uses the "Login with Amazon" to authenticate. It is an OAuth workflow that requires visiting an Amazon login page. This means we need to jump through some hoops to get started. The good news is that you'll get an acceess_token and a refresh_token-- which allows us to renew the credentials programmatically.

The auth object

In the examples you will see request('./auth.json'). This file contains the auth object return from a successful OAuth response. It will look like this:

{
  "access_token": "Atza|<really_long_string_of_characters>",
  "refresh_token": "Atzr|<really_long_string_of_characters>",
  "token_type": "bearer",
  "expires_in": 3600
}

The basics

The javascript API matches the REST API the best it can.

let urlsCache
const drive = require('amazon-drive')({
  cacheUrls: (urls) => {
    // urls passed in: save them
    if (urls) urlsCache = urls
    return Promise.resolve(urlsCache)
  },
  refresh: () => {
    // When this OAuth token expires (401 returned) this will be called.
    // You will need to refresh the token and return an updated auth object.
    // See: examples/refresh.js
  }
})

// get the urls for your account and cache them
drive.getUrls()
.then((urls) => {
  console.log(urls.metadataUrl)
  console.log(urls.contentUrl)
})
.catch(console.error)

API

Account

drive.getUrls()

All endpoints will call this internally to retrieve the account's endpoints. If they are retrieved from the Amazon Drive API, it will call cacheUrls(urls) for you to cache them somewhere. Amazon requests that they be cached for 3 to 5 days.

drive.account.endpoint()

This is what drive.getUrls() calls- but without caching.

drive.account.info()

drive.account.quota()

drive.account.usage()

Nodes (Files & Folders)

drive.nodes.upload(fullpath, metadata = {}, suppress = false)

drive.nodes.overwrite(id, fullpath)

drive.nodes.download(id)

drive.nodes.create(name, metadata = {})

Creates a folder

drive.nodes.get(id, options = undefined)

drive.nodes.patch(id, properties)

drive.nodes.list(options)

drive.nodes.list.all(filters = undefined)

drive.nodes.children.add(parent, child)

drive.nodes.children.move(child, oldParent, newParent)

drive.nodes.children.delete(parent, child)

drive.nodes.children.list(parent, options = undefined)

drive.nodes.properties.add(id, owner, key, value)

drive.nodes.properties.get(id, owner, key)

drive.nodes.properties.delete(id, owner, key)

drive.nodes.properties.list(id, owner)

Trash

drive.trash.add(id)

drive.trash.list(options = undefined)

drive.trash.restore(id)

Changes

drive.changes(options = undefined)

Credits

Thanks to @alex-phillips for the work on node-clouddrive. I used hints in his code and leveraged the authentication server he hosts to help get me started.

See:

  • https://github.com/alex-phillips/node-clouddrive
  • https://github.com/alex-phillips/node-clouddrive/issues/9
  • https://github.com/alex-phillips/clouddrive-endpoint

License

MIT Copyright (c) William Kapke