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

pitney-bowes

v0.3.1

Published

The Pitney Bowes Complete Shipping APIs let you integrate shipping services from multiple carriers, including USPS® and Newgistics®, into your services and applications.

Downloads

332

Readme

pitney-bowes

Build Status Coverage Status

The Pitney Bowes Complete Shipping APIs let you integrate shipping services from multiple carriers, including USPS® and Newgistics®, into your services and applications.

https://shipping.pitneybowes.com

Usage

const PitneyBowes = require('pitney-bowes');

const pitneyBowes = new PitneyBowes({
    api_key: 'your_api_key',
    api_secret: 'your_api_secret',
    baseUrl: 'https://api-sandbox.pitneybowes.com/shippingservices'
});

pitneyBowes.createShipment(shipment, options, callback)

This operation creates a shipment and purchases a shipment label. The API returns the label as either a Base64 string or a link to a PDF.

Example

const shipment = {
    documents: [
        {
            contentType: 'BASE64',
            fileFormat: 'ZPL2',
            printDialogOption: 'NO_PRINT_DIALOG',
            size: 'DOC_6X4',
            type: 'SHIPPING_LABEL'
        }
    ],
    fromAddress: {
        addressLines: ['4750 Walnut Street'],
        cityTown: 'Boulder',
        countryCode: 'US',
        name: 'Pitney Bowes',
        postalCode: '80301',
        stateProvince: 'CO'
    },
    parcel: {
        dimension: {
            height: 9,
            length: 12,
            unitOfMeasurement: 'IN',
            width: 0.25
        },
        weight: {
            unitOfMeasurement: 'OZ',
            weight: 3
        }
    },
    rates: [
        {
            carrier: 'PBPRESORT',
            parcelType: 'LGENV',
            serviceId: 'BPM'
        }
    ],
    shipmentOptions: [
        {
            name: 'PERMIT_NUMBER',
            value: '1234'
        },
        {
            name: 'SHIPPER_ID',
            value: '9015544760'
        }
    ],
    toAddress: {
        addressLines: ['114 Whitney Ave'],
        cityTown: 'New Haven',
        countryCode: 'US',
        name: 'John Doe',
        postalCode: '06510',
        stateProvince: 'CT'
    }
};

const options = {
    integratorCarrierId: '987654321',
    shipmentGroupId: '500002',
    transactionId: crypto.randomBytes(12).toString('hex')
};

pitneyBowes.createShipment(shipment, options, function(err, shipment) {
    console.log(shipment);
});

pitneyBowes.getOAuthToken(callback)

Each request to the PB Complete Shipping APIs requires authentication via an OAuth token. This API call generates the OAuth token based on the Base64-encoded value of the API key and secret associated with your PB Complete Shipping APIs developer account. The token expires after 10 hours, after which you must create a new one.

Example

pitneyBowes.getOAuthToken(function(err, oAuthToken) {
    console.log(oAuthToken);
});

pitneyBowes.tracking(args, callback)

Shipment labels that are printed using the PB Complete Shipping APIs are automatically tracked. This operation retrieves package status for a label.

Example

pitneyBowes.tracking({ trackingNumber: 'trackingNumber' }, function(err, data) {
    console.log(data);
});

pitneyBowes.tlsTest(callback)

The minimum supported security protocol for connection to the PB Complete Shipping APIs is TLS v1.2. To test whether your servers support TLS v1.2: From your servers, issue the following operation. The operation retrieves a resource that accepts only the TLS v1.2 protocol:

Example

pitneyBowes.tlsTest(function(err, res) {
    console.log(res);
});

pitneyBowes.validateAddress(args, callback)

Address validation verifies and cleanses postal addresses within the United States to help ensure packages are rated accurately and shipments arrive at their final destinations on time. The Validate Address operation sends an address to be verified. The response indicates whether the address is valid and whether the validation check made changes to the address.

Example

const address = {
    addressLines: [
        '1600 Pennsylvania Avenue NW'
    ],
    cityTown: 'Washington',
    stateProvince: 'DC',
    postalCode: '20500 ',
    countryCode: 'US',
    company: 'Pitney Bowes Inc.',
    name: 'John Doe',
    phone: '203-000-0000',
    email: '[email protected]'
};

pitneyBowes.validateAddress({ address, minimalAddressValidation: false }, function(err, data) {
    console.log(data);
});