New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

printful-request

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

printful-request

Simple request wrapper for Printful, with authorization management.

latest
Source
npmnpm
Version
1.3.0
Version published
Weekly downloads
12
-75%
Maintainers
1
Weekly downloads
 
Created
Source

printful-request

Simple Node.js request wrapper for Printful, with authorization management. Not to be used client-side.

VERSION 2.0 USERS: You will want to use Printful API Tokens, and NOT API KEYS. Read migration guide.

Quickstart

const { PrintfulClient, request } = require("printful-request");

const printful = new PrintfulClient("PRINTFUL_API_TOKEN");

printful.get("orders").then(({ result }) => console.log(result));

// Or with a simple request

request("orders", {
  token: "PRINTFUL_API_TOKEN",
  params: { limit: 1 },
}).then(({ result }) => console.log(result));

Examples

Refer to the Printful API Documentation for possible URLs. This library acts as a small layer for parsing JSON, and passing API keys as authorization headers.

GET

const { PrintfulClient, request } = require("printful-request");

const printful = new PrintfulClient("PRINTFUL_API_TOKEN");

printful.get("orders").then(({ result }) => console.log(result));

// or using request

request("orders", { token: "PRINTFUL_API_TOKEN" }).then(({ result }) =>
  console.log(result)
);

GET with params

const { PrintfulClient, request } = require("printful-request");

const printful = new PrintfulClient("PRINTFUL_API_TOKEN");

printful
  .get("orders", { limit: 5, offset: 10 })
  .then(({ result }) => console.log(result));

// or using request

request("orders", {
  token: "PRINTFUL_API_TOKEN",
  params: { limit: 5, offset: 10 },
}).then(({ result }) => console.log(result));

POST

const { PrintfulClient, request } = require("printful-request");

const printful = new PrintfulClient("PRINTFUL_API_TOKEN");

printful
  .get("orders/estimate-costs", {
    recipient: { name: "..." },
    items: [{ id: "..." }],
  })
  .then(({ result }) => console.log(result));

// or using request

request("orders/estimate-costs", {
  token: "PRINTFUL_API_TOKEN",
  params: { recipient: { name: "..." }, items: [{ id: "..." }] },
}).then(({ result }) => console.log(result));

PUT

const { PrintfulClient, request } = require("printful-request");

const printful = new PrintfulClient("PRINTFUL_API_TOKEN");

printful
  .get("orders/{id}", {
    id: "...",
    confirm: true,
  })
  .then(({ result }) => console.log(result));

// or using request

request("orders/{id}", {
  token: "PRINTFUL_API_TOKEN",
  params: { id: "...", confirm: true },
}).then(({ result }) => console.log(result));

DELETE

const { PrintfulClient, request } = require("printful-request");

const printful = new PrintfulClient("PRINTFUL_API_TOKEN");

printful.delete("orders/{id}").then(({ result }) => console.log(result));

// or using request

request("orders/{id}", {
  token: "PRINTFUL_API_TOKEN",
  method: "DELETE",
}).then(({ result }) => console.log(result));

Keywords

printful

FAQs

Package last updated on 14 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts