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

printify-node-api

v1.0.1

Published

A small API implementation to communicate with your printify shops

Downloads

11

Readme

printify-node-api v1.0.1

1. Installation

npm install printify-node-api

2. Usage

Just require the Printify class by typing:

const Printify = require('printify-node-api');

const API =  Printify.getInstance( 'myShopId', options)

Parameters:

shopID: Your Printify shop ID

options: A configuration object with the following properties:

  • version - default "v1": The Printify API version.
  • authKey: Your printify API key
  • mode - default undefined: Can be set to "debug" to print additional information to the console

3. Collections

3.1 products collection

Access your products via API.products and the respective method.

//Create a product
API.products.create(payload);

//Get all products
API.products.getAll()
.then(response => console.log(response.data))
.catch( err => console.log(err.message));

//Get a single product
API.products.getById('yourProductId')
.then(response => console.log(response.data))
.catch( err => console.log(err.message));

//Update a product
API.products.update('yourProductId', payload);

//Delete a product
API.products.delete('yourProductId');

//Publish a new product

//TODO 

//Unpublish a published product

//TODO

3.2 orders collection

Access your orders via API.orders and the respective method.

//Create an order
API.orders.create(payload);

//Get all orders
API.orders.getAll()
.then(response => console.log(response.data))
.catch( err => console.log(err.message));

//Get a single order
API.orders.getById('yourProductId')
.then(response => console.log(response.data))
.catch( err => console.log(err.message));

//Update an order
API.orders.update('yourProductId', payload);

//Delete an order
API.orders.delete('yourProductId');

//Send an order to production

//TODO 

//Calculate shipping costs of an order

//TODO

3.3 webhooks collection

//TODO

4. Events

If you use the printify-node-api in combination with express, you can register an endpoint for the printify webhooks. Events will be sent to the defined endpoint and whenever and event arrives at this endpoint, the printify-node-api will emit an event of the event type that has been received.

You can then listen to these events and implement your own handlers to react to these events.

WARNING: Printify does not provide webhooks for local test environments. This feature can only be used in production or if your express server is reachable.

const express = require('express');

const app = express();
/** Your express setup **/

//Register an endpoint for your events
API.registerWebhookEndpoint(app, '/webhooks', whsec);

//Listen to events. Only events with a registered webhook will be fired by printify
// The event will be passed to the listener

API.on('order:created', (event) => {
    /*** your listener implementation***/
})

//TODO

For information about printify's events please visit the Printify API Reference