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

feathers-shippo

v0.1.0

Published

A Feathers JS adapter for the Shippo API

Downloads

6

Readme

feathers-shippo

A FeathersJS adapter for the Shippo API. For more information, visit the Shippo API Docs and Shippo API Reference. This library automatically handles rate limits by using bottleneck under the hood.

import { ShippoShipments } from 'feathers-shippo';

const options = {
  token: 'YOUR_SHIPPO_TOKEN'
}

app.use('shipments', new ShippoShipments(options, app));


const shipments = await app.service('shipments').find({
  query: {
    results: 10,
    object_created_gt: '2023-01-01'
  }
});

Most services are a light wrapper around the corresponding Shippo resource. Some services implement custom params.query and custom methods to accomodate certain Shippo actions. To learn more about each service's capabilities, view the service's source code and read the Shippo API Reference. Note this library does not try to implement the Feathers Common query syntax, instead params.query is passed directly to Shippo.

  • ShippoAddresses
  • ShippoBatches
  • ShippoCarrierAccounts
  • ShippoCarrierParcelTemplates
  • ShippoCustomsDeclarations
  • ShippoCustomsItems
  • ShippoManifests
  • ShippoOrders
  • ShippoParcels
  • ShippoPickups
  • ShippoRates
  • ShippoRefunds
  • ShippoServiceGroups
  • ShippoShipments
  • ShippoTracks
  • ShippoTransactions
  • ShippoUserParcelTemplates

The library also exports some utility functions and classes

  • ShippoServce
  • shippo

Rate Limits

All services use Bottleneck to queue requests to the Shippo API. The limits are determined by whether the options.token starts with shippo_live or shippo_test and correspond to the Shippo Rate Limits. This means that requests should never exceed the rate limit because the Bottleneck will ensure they are limited properly. Note Bottleneck is a queue, not a rate limiter. You can also disable or pass your own rate limiters.

import { ShippoShipments } from 'feathers-shippo';
import Bottleneck from 'bottleneck';

 // disable rate limiting
const options = {
  token: 'YOUR_SHIPPO_TOKEN',
  limiters: null
}

// provide custom limiters
const options = {
  token: 'YOUR_SHIPPO_TOKEN',
  limiters: {
    get: new Bottleneck({ ... }) // GET/:id
    find: new Bottleneck({ ... }) // GET
    create: new Bottleneck({ ... }) // POST
    update: new Bottleneck({ ... }) // PUT
    remove: new Bottleneck({ ... }) // DELETE
  }
}

app.use('shipments', new ShippoShipmentsService(options, app));

ShippoService

You generally won't need to use this service directly, but its available to you. It is the base class used to create all other services.

import { ShippoService } from 'feathers-shippo';

const options = {
  token: 'YOUR_SHIPPO_TOKEN',
  path: 'shipments',
  methods: ['get', 'find', 'create']
}

app.use('shipments', new ShippoService(options, app));

Shippo Client

The shippo function creates a new axios instance with the Shippo API baseURL and Authorization header. It is used under the hood for all service requests. It is exported for you to handle any Shippo functionality not covered by this library. This client does not handle rate limiting.

import { shippo } from 'feathers-shippo';

const shippoClient = shippo('YOUR_SHIPPO_TOKEN');