@putdotio/api-client
TypeScript icon, indicating that this package has built-in type declarations

8.49.0 • Public • Published

putio-js

JavaScript SDK for interacting with the put.io API.

Build Status Coverage Status npm (scoped) npm bundle size (scoped) GitHub

Installation

yarn add @putdotio/api-client

npm install @putdotio/api-client

ES Modules / TypeScript

import PutioAPI from '@putdotio/api-client'

CommonJS

const PutioAPI = require('@putdotio/api-client').default

Usage

// you can pass the options in constructor
const putioAPI = new PutioAPI({ clientID: 'OAUTH_CLIENT_ID' })

// or use `configure` method
MyApp.bootstrap(config => {
  putioAPI.configure({ clientID: config.OAUTH_CLIENT_ID })
})

// setToken will send the given auth token with every request, in Authorization header
MyApp.onLogin(token => {
  putioAPI.setToken(token)

  putioAPI.Account.Info()
    .then(r => console.log('Fetched user info: ', r))
    .catch(e => console.log('An error occurred while fetching user info: ', e))
})

// clearToken will perform a clean-up and stop sending the token in Authorization header
MyApp.onLogout(() => {
  putioAPI.clearToken()
})

API

Options

Prop Type Default Value Description
clientID number 1 OAuth app client ID, defaults to put.io web app
baseURL string api.put.io/v2 Base URL of the API
webAppURL string app.put.io Base URL of the Put.io web app, used in the authentication flow

Methods

Name Parameters Return Value
configure (options: IPutioAPIClientOptions) PutioAPIClient Instance
setToken (token: string) PutioAPIClient Instance
clearToken PutioAPIClient Instance

Events

Value Payload Description
ERROR IPutioAPIClientError Fired when an HTTP request fails
CLIENT_IP_CHANGED { IP: string, newIP: string } Fired when the IP of the client changes

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
8.49.027latest
7.0.0-alpha70alpha

Version History

VersionDownloads (Last 7 Days)Published
8.49.027
8.48.00
8.47.01
8.46.00
8.45.00
8.44.00
8.43.00
8.42.024
8.41.00
8.40.00
8.39.00
8.38.00
8.37.00
8.36.10
8.36.00
8.35.10
8.35.00
8.34.40
8.34.30
8.34.20
8.34.00
8.33.10
8.33.00
8.32.00
8.31.20
8.31.10
8.31.00
8.30.00
8.29.00
8.28.00
8.27.30
8.27.20
8.27.10
8.27.00
8.26.10
8.26.00
8.25.00
8.24.00
8.23.20
8.23.10
8.23.00
8.22.00
8.21.02
8.20.01
8.19.00
8.18.00
8.17.00
8.16.00
8.15.30
8.15.20
8.15.10
8.15.00
8.14.00
8.13.30
8.13.20
8.13.10
8.13.00
8.12.00
8.11.00
8.10.00
8.9.00
8.8.00
8.7.00
8.6.10
8.6.00
8.5.20
8.5.10
8.5.00
8.4.10
8.4.00
8.3.00
8.2.00
8.1.00
8.0.00
7.10.10
7.10.00
7.9.00
7.8.20
7.8.10
7.8.00
7.7.00
7.6.20
7.6.10
7.6.00
7.5.00
7.4.10
7.3.10
7.3.00
7.2.00
7.1.20
7.1.10
7.1.00
7.0.20
7.0.10
7.0.00
7.0.0-beta0
7.0.0-alpha70
7.0.0-alpha60
7.0.0-alpha50
7.0.0-alpha40
7.0.0-alpha30
7.0.0-alpha20
7.0.0-alpha10
6.6.00
6.5.10
5.1.00
4.3.10
4.3.00
4.2.00
4.0.00
3.11.00
3.3.00
3.2.00
2.24.00
2.19.00
2.15.00
2.16.00
2.13.00
2.12.00
2.11.00
2.10.00
2.9.00
2.8.00

Package Sidebar

Install

npm i @putdotio/api-client

Weekly Downloads

55

Version

8.49.0

License

MIT

Unpacked Size

504 kB

Total Files

139

Last publish

Collaborators

  • altaywtf
  • cenkalti
  • tolgaakyuz
  • putio
  • banjuan