Skip to content

lib-js: the JavaScript client

lib-js is the official Pryv.io client library for JavaScript / TypeScript, published on npm as pryv. It works both in Node.js and in the browser, and wraps the HTTP API with a small, promise-based surface (connections, batched API calls, authentication helpers, high-frequency series, and event/attachment helpers).

Reach for lib-js when you build a JavaScript or TypeScript app or service that talks to a Pryv.io account, instead of calling the REST API by hand. For other languages, use the OpenAPI definitions to generate a client, or call the API directly.

Terminal window
npm install pryv
const Pryv = require('pryv');
// An API endpoint is `https://{token}@{username}.{domain}/`
const connection = new Pryv.Connection('https://TOKEN@USERNAME.pryv.me');
// Batched API calls use the same method ids as the reference
const [result] = await connection.api([
{ method: 'events.get', params: { limit: 20 } },
]);
console.log(result.events);

In the browser, the same library is available as a bundle; see the repository for the script-tag and authentication (auth request) flows.

The authoritative documentation, browser usage, authentication flows, high-frequency series and the complete API live in the repository:

See also Get started and the API reference.