pipedrive-api-client
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

PipeDrive API wrapper for JavaScript

Build Status Coverage Status

PipeDrive API wrapper. api docs.

Installation

Node.js

npm i pipedrive-api-client -S

Usage with api token

doc

import PipeDrive from 'pipedrive-api-client'

const pd = new PipeDrive({
  apiToken: 'xxxxxx',
  host: 'https://your-pipedrive-domain.pipedrive.com'
})

let r = await gc.get('/v1/users/me')
  .then(d => d.data)
  .catch(console.log)
expect(r.success).toBe(true)

Usage with oauth

doc

import PipeDrive from 'pipedrive-api-client'

const pd = new PipeDrive({
  redirectUri: 'https://xxxxxx.com/oauth',
  clientId: 'xxxxxx',
  clientSecret: 'yyyyyy'
})

const loginUrl = pd.authorizeUri('some_state_string')

app.get('/oauth', (req, res) {
  const { code } = req.query
  await pd.authorize(code)
  let r = await pd.get('/v1/users/me')
    .then(d => d.data)
    .catch(console.log)
  expect(r.success).toBe(true)
})

Check examples/server.js as basic example server side code.

APIs

// constructor
const pd = new PipeDrive({
  host?: string,
  apiToken?: string,
  clientId?: string,
  clientSecret?: string,
  oauthServer?: string,
  redirectUri?: string,
  appName?: string,
  appVersion?: string,
  token?: Token,
  logger?: Logger
})

// refresh token
pd.refresh()

// revoke token
pd.revoke()


// rest request
pg.get(url, options)
pg.delete(url, data, options)
pg.post(url, data, options)
pg.put(url, data, options)

// options: check https://axios-http.com/docs/req_config

Test

cp .sample.env .env
# edit .env fill required fields
npm run test

Credits

Based on Tyler's https://github.com/tylerlong/ringcentral-js-concise.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i pipedrive-api-client

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

25.6 kB

Total Files

7

Last publish

Collaborators

  • zxdong262