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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ollivander

v2.0.2

Published

Wonde API client for Node.js, browsers, and workers

Downloads

5

Readme

ollivander

🪄 Ollivander

Wonde API client for Node.js, browsers, and workers

npm Code Climate maintainability npms.io (quality) Snyk Vulnerabilities for npm package npm bundle size

  • Promise-based API. For all of that async/await goodness!
  • 🏫 Multi-school support. Make one request for multiple schools!
  • 📄 Automatic pagination aggregation. Wonde's paginated API responses are automatically aggregated into one!
  • 💪 TypeScript. Fully typed and self-documenting!

🚀 Quick Start

Install

# npm
npm i ollivander

# or yarn
yarn add ollivander

Import

// ESM / TypeScript
import { $wonde } from "ollivander";

// or CommonJS
const { $wonde } = require("ollivander");

Example Usage

Fetch all students for two schools:

const schools = await $wonde((school) => `/schools/${school}/students`, {
  schools: ["A123456789", "A987654321"],
  token: "abc123",
});

console.log(schools["A123456789"]);
// => Array of school A123456789's students

🏫 Single versus multi-school

Single school mode

const students = await $wonde("/schools/A123456789/students", {
  token: "abc123",
});

console.log(students);
// => Array of school A123456789's students
// => i.e. [ ... ]

Multi-school mode

const schools = await $wonde((school) => `/schools/${school}/students`, {
  schools: ["A123456789", "A987654321"],
  token: "abc123",
});

console.log(schools);
// => Object mapping schools to their array of students
// => i.e. { 'A123456789': [ ... ], 'A987654321': [ ... ] }

💪 TypeScript Support

Wonde responses can be type assisted using generics:

type Student = { ... };

const students = await $wonde<Student>("/schools/A123456789/students", {
  token: "abc123",
});

// => Students now has type definitions

♻ Auto Retry

Ollivander can be configured to retry requests if an error is encountered:

const students = await $wonde("/schools/A123456789/students", {
  token: "abc123",
  retry: 5, // => Request will retry 5 times before giving up
});

By default, requests will retry 1 time (except for POST, PUT, and PATCH requests, which will not retry).

📂 HTTP Headers

You can supply additional HTTP headers to Wonde's API:

const students = await $wonde("/schools/A123456789/students", {
  token: "abc123",
  headers: {
    some: "header", // => This will be included in the request (including every paginated request)
  },
});

⛓ Includes

You can instruct Wonde's API to populate relationships with includes. Typically, this would be done with the includes search parameter, but Ollivander has a specific option for includes:

const students = await $wonde("/schools/A123456789/students", {
  token: "abc123",
  includes: ["classes"], // => Each student object will include their respective classes
});

🔢 Per Page

Wonde's API returns paginated responses for arrays of data. You can increase the number of resources returned per request (reducing the overall number of requests):

const students = await $wonde("/schools/A123456789/students", {
  token: "abc123",
  perPage: 200, // => Wonde's API caps this value at 200 (5000 when retrieving attendance sessions)
});

⚠ It's important to remember that Ollivander will handle paginated responses from Wonde so you never need to make more than one request.

However, increasing the perPage option will still reduce Ollivander's request time because of the overhead encountered when making a request to Wonde's API.

🌍 Wonde Endpoints

Wonde's API has separate endpoints/base URLs for the UK and Australia/New Zealand. You can find these endpoints on Wonde's API Reference, or import them as constants from Ollivander:

// ESM / TypeScript
import {
  UK,
  REST_OF_THE_WORLD,
  AUSTRALIA,
  NEW_ZEALAND,
} from "ollivander/endpoints";

// or CommonJS
const {
  UK,
  REST_OF_THE_WORLD,
  AUSTRALIA,
  NEW_ZEALAND,
} = require("ollivander/endpoints");

const students = await $wonde("/schools/A123456789/students", {
  baseURL: AUSTRALIA,
});

By default, Ollivander will use Wonde's endpoint for the UK/Rest of the World.

⚖ License

Ollivander is licensed under the MIT License.