# podio-client

> A utility for working with the Podio API. The functionality is:

Latest version **3.0.1** (published 2022-09-26) · 0 weekly downloads

## Install

```sh
npm install podio-client
pnpm add podio-client
yarn add podio-client
bun add podio-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2022-09-26 |
| First published | 2019-04-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 24.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | thomas-jensen, adomas.d |

## Links

- npm: https://www.npmjs.com/package/podio-client
- npm.io page: https://npm.io/package/podio-client

## Dependencies (1)

- [podio-fetch](https://npm.io/package/podio-fetch.md) ^3.0.0

## Recent versions

- 3.0.1 (latest) — 2022-09-26
- 3.0.0 — 2022-09-21
- 2.0.0 — 2020-05-13
- 1.5.0 — 2020-05-04
- 1.4.0 — 2020-04-01
- 1.3.0 — 2020-01-25
- 1.2.0 — 2019-12-13
- 1.1.1 — 2019-06-11
- 1.1.0 — 2019-06-11
- 1.0.0 — 2019-04-29

## README

# Podio client

A utility for working with the Podio API. The functionality is:

- Maintain (refresh) the access token when needed (lazily)
- Provide a retry mechanism with sane defaults
- Wrap common errors in easy-to-catch classes
- Provide a helper for paginating through results
- Provide a helper for formatting dates to Podio format

```js
request({
  log = noop,

  // at least one of
  client: {id, secret, refreshToken},
  session: {
    // optional, use an empty object for reuse across requests
    token,
    expiry,
  },

  method, // defaults to POST/GET depending on "data"
  path,
  query,
  data,
  retry = defaultRetry, // fn(err, retries) → true for "now", false for "no", integer for delay (ms)
})
// → Promise → parsed JSON data from the API
```

`expires` is optional but should be a timestamp in milliseconds on which `token`
is regarded expired. It is checked prior to a request to avoid pointless
requests and will immediately trigger a refresh. The `session` object will be
modified if a new `token` is obtained.

`client` is required for token refreshes.

The default retry strategy is a minute delay for `RateLimitError`, immediately
for `TokenExpiredError`, ten seconds delay for `UnexpectedHttpStatusError` and
any Node.js system error, and fail in all other situations. Be aware that
retrying may result in duplicate processing of your request. You should disable
it where that is not tolerable.

```js
authenticate({
  log = noop,
  client,
  // `username` and `password` if authenticating as a user
  username,
  password,
  // `appId` and `appToken` if authenticating as an app
  appId,
  appToken,
})
// → Promise → {refreshToken, accessToken, expiry}
```

Used to obtain a session object from a username and password or app ID and app
token.

```js
paginate(batchSize, limit, scroll)
// → source pull-stream

// Example
pull(
  paginate(500 /* Podio max */, Infinity, (offset, limit) =>
    podio
      .request({
        client,
        session,
        path: `/item/app/${appId}/filter`,
        json: {
          sort_by: 'created_on',
          sort_desc: false,
          offset,
          limit,
        },
      })
      .then((r) => r.items)
  ),
  map((i) => i.itemId),
  drain(console.log, (err) => err && console.error(err))
)
```

Proxies
[`formatPeriod` from `podio-fetch`](https://www.npmjs.com/package/podio-fetch#formatting)
for Date formatting to Podio format

## Errors

```
TokenExpiredError
RateLimitError
UnexpectedHttpStatusError
UnexpectedHttpContentTypeError
InvalidJsonBodyError
```

---
_Source: https://npm.io/package/podio-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
