Git Product home page Git Product logo

printify-api's Introduction

Printify API

Printify's REST API allows your application to manage a Printify shop on behalf of a Printify Merchant. Create products, submit orders, and more...

API Usage Guidelines

developers.printify.com

If you don't know Node.js

Node.js Tutorial for Beginners in 2020

How To Build a Blog with Nest.js, MongoDB, and Vue.js

Machine Learning In Node.js With TensorFlow.js

Install

npm i printify-api --save

Example

var Printify = require('printify-api');

var API = new Printify({
  shop_id: 123456, // global query by shop_id, if not set you must set each function
  access_token:'xxxxxxxxxxxxxxxxxxxxxxxxxx'
});
  // Retrieve a list of all products
  API.Product.fetch().then(data =>{
    console.log(data);
  });

  // support async
  var result = await API.Product.fetch();
  
  // or custom shop_id
  var result = await API.Product.fetch(shop_id);
  
// Retrieve a product
var result = await API.Product.info(product_id);

// or custom shop_id
var result = await API.Product.info(product_id, shop_id);
 // Create a new product
  var data = {
    "title": "Product",
    "description": "Good product",
    "blueprint_id": 384,
    "print_provider_id": 1,
    "variants": [
          {
              "id": 45740,
              "price": 400
          },
          {
              "id": 45742,
              "price": 400
          },
          {
              "id": 45744,
              "price": 400
          },
          {
              "id": 45746 ,
              "price": 400
          }
      ],
      "print_areas": [
        {
          "variant_ids": [45740,45742,45744,45746],
          "placeholders": [
            {
              "position": "front",
              "images": [
                  {
                    "id": "5d15ca551163cde90d7b2203", 
                    "x": 0.5, 
                    "y": 0.5, 
                    "scale": 1,
                    "angle": 0
                  }
              ]
            }
          ]
        }
      ],
  };

  var result = API.Product.create(data);

  // or 
  var result = API.Product.create(data, shop_id);
 // Update a product
  var data = {
    id: 1234,
    title:'Product 1'
  };

  var result = await API.Product.update(data);

  // or
  var result = await API.Product.update(data, shop_id);
// Delete a product
 var result = await API.Product.delete(1234);
// Publish a product
var result = await API.Product.publish(1234);

// Notify that a product was successfully published
var result = await API.Product.publish(1234, 'success');

// Notify that a product publishing has failed
var result = await API.Product.publish(1234, 'error');
 // Retrieve a list of orders
var result = await API.Order.fetch();

// or custom shop_id
var result = await API.Order.fetch(shop_id);
 // Get order details by id
var result = await API.Order.info(order_id);

// or custom shop_id
var result = await API.Order.fetch(order_id, shop_id);
 // Submit an order

var data = {
    "external_id": "2750e210-39bb-11e9-a503-452618153e4a",
    "line_items": [
      {
        "product_id": "5bfd0b66a342bcc9b5563216",
        "variant_id": 17887,
        "quantity": 1
      }
    ],
    "shipping_method": 1,
    "send_shipping_notification": false,
    "address_to": {
      "first_name": "John",
      "last_name": "Smith",
      "email": "[email protected]",
      "phone": "0574 69 21 90",
      "country": "BE",
      "region": "",
      "address1": "ExampleBaan 121",
      "address2": "45",
      "city": "Retie",
      "zip": "2470"
    }
  };

var result = await API.Order.create(data);

// or custom shop_id
var result = await API.Order.create(data, shop_id);
// Send an existing order to production
var result = await API.Order.publish(order_id);

// or custom shop_id
var result = await API.Order.publish(order_id, shop_id);
// Calculate the shipping cost of an order

var order = {
    "line_items": [{
        "product_id": "5bfd0b66a342bcc9b5563216",
        "variant_id": 17887,
        "quantity": 1
    },{
        "print_provider_id": 5,
        "blueprint_id": 9,
        "variant_id": 17887,
        "quantity": 1
    },{
        "sku": "MY-SKU",
        "quantity": 1
    }],
    "address_to": {
        "first_name": "John", // not required
        "last_name": "Smith", // not required
        "email": "[email protected]", // not required
        "phone": "0574 69 21 90", // not required
        "country": "BE",
        "region": "",
        "address1": "ExampleBaan 121",
        "address2": "45",
        "city": "Retie",
        "zip": "2470"
    }
};

var result = await API.Order.shipping_cost(order);

// or custom shop_id
var result = await API.Order.shipping_cost(order, shop_id);
// Retrieve a list of webhooks
var result = await API.Webhook.fetch();

// or custom shop_id
var result = await API.Webhook.fetch(shop_id);
// Retrieve a webhook
var result = await API.Webhook.info(webhook_id);

// or custom shop_id
var result = await API.Webhook.info(webhook_id, shop_id);
// Create a new webhook
var data = {
    "topic": "order:created",
    "url": "https://morioh.com/webhooks/order/created"
}

var result = await API.Webhook.create(data);

// or custom shop_id
var result = await API.Webhook.create(data, shop_id);
// Modify a webhook
var data = {
    id: 12345,
    "url": "https://othersite.com/callback/order/created"
};
var result = await API.Webhook.update(data);

// or custom shop_id
var result = await API.Webhook.update(data, shop_id);
// Events, no test
// The product was deleted.
API.on('product:deleted', function(err, res){
    console.log(res);
});

// The product publishing was started.
API.on('product:publish:started', function(err, res){
    console.log(res);
});

// The product published successfully.
API.on('product:publish:succeeded', function(err, res){
    console.log(res);
});

// The product publishing has failed.
API.on('product:publish:failed', function(err, res){
    console.log(res);
});

// The order was created.
API.on('order:created', function(err, res){
    console.log(res);
});

// The order was updated.
API.on('order:updated', function(err, res){
    console.log(res);
});

// The order was sent to production.
API.on('order:sent-to-production', function(err, res){
    console.log(res);
});

// Some/all items have been fulfilled.
API.on('order:shipment:created', function(err, res){
    console.log(res);
});

// Some/all items have been delivered
API.on('order:shipment:delivered', function(err, res){
    console.log(res);
});

// see more: https://developers.printify.com/#events

printify-api's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

printify-api's Issues

printify-api broken.

Installed the API today to try to implement via my proxy server, and upon declaring:

var API = new Printify({
    shop_id: 123456,
    access_token: 'my-access-token'
});

Without making any calls, I'm getting "TypeError: r is not a constructor" via printify-api\dist\index.js:1:1546 when I try to launch my server to listen.

Assistance on this matter would be greatly appreciated.

Let me know if you need any more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.