printify-sdk-js
Version:
Node.js SDK for the Printify API.
1,659 lines (1,608 loc) • 48.6 kB
text/typescript
import { AxiosRequestConfig } from 'axios';
interface HttpConfig {
accessToken: string;
shopId?: string;
enableLogging?: boolean;
host?: string;
timeout?: number;
}
declare class HttpClient {
private accessToken;
shopId?: string;
private host;
private timeout;
private enableLogging?;
private baseUrl;
constructor(config: HttpConfig);
private logError;
private logRequest;
request<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
}
declare global {
type RequestFn = (url: string, config: Record<string, any>) => Promise<any>;
type method = {
request: RequestFn;
shopId?: string;
};
}
interface PrintProvider {
id: number;
title: string;
location?: Location;
}
interface Placeholder {
position: string;
height: number;
width: number;
}
interface Variant {
id: number;
title: string;
options: {
color: string;
size: string;
};
placeholders: Placeholder[];
}
interface Blueprint {
id: number;
title: string;
description?: string;
brand: string;
model: string;
images: string[];
}
interface ShippingProfile {
variant_ids: number[];
first_item: {
cost: number;
currency: string;
};
additional_items: {
cost: number;
currency: string;
};
countries: string[];
}
interface Location {
address1: string;
address2: string | null;
city: string;
country: string;
region: string;
zip: string;
}
interface Location {
address1: string;
address2: string | null;
city: string;
country: string;
region: string;
zip: string;
}
interface Address {
first_name: string;
last_name: string;
email: string;
phone: string;
country: string;
region: string;
address1: string;
address2?: string;
city: string;
zip: string;
company?: string;
}
interface OrderShipment {
carrier: string;
number: string;
url: string;
delivered_at: string;
}
interface PrintifyConnection {
id: string;
url: string;
}
interface LineItem {
product_id: string;
quantity: number;
variant_id: number;
print_provider_id: number;
cost: number;
shipping_cost: number;
status: string;
metadata: {
title: string;
price: number;
variant_label: string;
sku: string;
country: string;
};
sent_to_production_at?: string;
fulfilled_at?: string;
}
interface ShippingLineItem {
product_id?: string;
variant_id?: number;
quantity: number;
print_provider_id?: number;
blueprint_id?: number;
sku?: string;
}
interface NewLineItem {
product_id?: string;
print_provider_id?: number;
blueprint_id?: number;
variant_id?: number;
print_areas?: {
front?: string | {
src: string;
scale: number;
x: number;
y: number;
angle: number;
}[];
back?: string | {
src: string;
scale: number;
x: number;
y: number;
angle: number;
}[];
};
print_details?: {
print_on_side?: string;
};
sku?: string;
quantity: number;
}
interface ExpressLineItem {
product_id: string;
variant_id: number;
quantity: number;
}
interface Order {
id: string;
address_to: Address;
line_items: LineItem[];
metadata: {
order_type: string;
shop_order_id: number;
shop_order_label: string;
shop_fulfilled_at: string;
};
total_price: number;
total_shipping: number;
total_tax: number;
status: string;
shipping_method: number;
is_printify_express: boolean;
is_economy_shipping: boolean;
shipments: OrderShipment[];
created_at: string;
sent_to_production_at: string;
fulfilled_at: string;
printify_connect: PrintifyConnection;
}
interface CalculateShippingData {
line_items: ShippingLineItem[];
address_to: Address;
}
interface Product {
id: string;
title: string;
description: string;
safety_information?: string;
tags?: string[];
options?: Array<{
name: string;
type: string;
values: Array<{
id: number;
title: string;
}>;
}>;
variants: Array<{
id: number;
sku: string;
cost: number;
price: number;
title: string;
grams: number;
is_enabled: boolean;
is_default: boolean;
is_available: boolean;
is_printify_express_eligible: boolean;
options: number[];
}>;
images: Array<{
src: string;
variant_ids: number[];
position: string;
is_default: boolean;
}>;
created_at: string;
updated_at: string;
visible: boolean;
blueprint_id: number;
print_provider_id: number;
user_id: number;
shop_id: number;
print_areas: Array<{
variant_ids: number[];
placeholders: Array<{
position: string;
images: Array<{
id: string;
name: string;
type: string;
height: number;
width: number;
x: number;
y: number;
scale: number;
angle: number;
}>;
}>;
background: string;
}>;
print_details?: {
print_on_side: 'regular' | 'mirror' | 'off';
};
external?: ExternalProductData[];
is_locked: boolean;
is_printify_express_eligible: boolean;
is_printify_express_enabled?: boolean;
is_economy_shipping_eligible: boolean;
is_economy_shipping_enabled: boolean;
sales_channel_properties?: {
[key: string]: any;
};
views?: Array<{
[key: string]: any;
}>;
}
interface NewProduct {
title: string;
description: string;
blueprint_id: number;
print_provider_id: number;
variants: Array<{
id: number;
price: number;
is_enabled: boolean;
}>;
print_areas: PrintArea[];
}
interface UpdateProductData {
title?: string;
description?: string;
images?: string[];
variants?: any[];
tags?: string[];
keyFeatures?: string[];
shipping_template?: string;
}
interface PrintArea {
variant_ids: number[];
placeholders: {
position: string;
images: {
id: string;
x: number;
y: number;
scale: number;
angle: number;
}[];
}[];
}
interface ExternalProductData {
id: string;
handle: string;
}
interface Shop {
id: number;
title: string;
sales_channel: string;
}
interface ImageUpload {
id: string;
file_name: string;
height: number;
width: number;
size: number;
mime_type: string;
preview_url: string;
upload_time: string;
}
interface Webhook {
topic: string;
url: string;
shop_id: string;
id: string;
}
interface NewWebhook {
topic: string;
url: string;
}
type ListBlueprintsResponse = Blueprint[];
/**
* Retrieve a list of all available blueprints
*
* @returns {Promise<ListBlueprintsResponse>}
*
* @example
* await printify.catalog.listBlueprints();
* // Expected response: [
* // {
* // id: 3,
* // title: "Kids Regular Fit Tee",
* // description: "Description goes here",
* // brand: "Delta",
* // model: "11736",
* // images: [
* // "https://images.printify.com/5853fe7dce46f30f8327f5cd",
* // "https://images.printify.com/5c487ee2a342bc9b8b2fc4d2"
* // ]
* // },
* // {
* // id: 5,
* // title: "Men's Cotton Crew Tee",
* // description: "Description goes here",
* // brand: "Next Level",
* // model: "3600",
* // images: [
* // "https://images.printify.com/5a2ffc81b8e7e3656268fb44",
* // "https://images.printify.com/5cdc0126b97b6a00091b58f7"
* // ]
* // }
* // ]
*/
declare const listBlueprints: (this: method) => Promise<ListBlueprintsResponse>;
type GetBlueprintResponse = {
id: number;
title: string;
description: string;
brand: string;
model: string;
images: string[];
};
/**
* Retrieve a specific blueprint
*
* @param {string} blueprintId - The ID of the blueprint to retrieve
* @returns {Promise<GetBlueprintResponse>}
*
* @example
* const blueprintId = "3";
* const blueprint = await printify.catalog.getBlueprint(blueprintId);
* // Expected response:
* // {
* // "id": 3,
* // "title": "Kids Regular Fit Tee",
* // "description": "Description goes here",
* // "brand": "Delta",
* // "model": "11736",
* // "images": ["https://images.printify.com/5853fe7dce46f30f8327f5cd", "https://images.printify.com/5c487ee2a342bc9b8b2fc4d2"]
* // }
*/
declare const getBlueprint: (this: method, blueprintId: string) => Promise<GetBlueprintResponse>;
type GetBlueprintProviderResponse = PrintProvider[];
/**
* Retrieve a list of all print providers that fulfill orders for a specific blueprint
*
* @param {string} blueprintId - The ID of the blueprint to retrieve print providers for
* @returns {Promise<GetBlueprintProviderResponse>}
*
* @example
* const blueprintId = "3";
* const providers = await printify.catalog.getBlueprintProviders(blueprintId);
* console.log(providers);
* // Expected response:
* // [
* // { "id": 3, "title": "DJ" },
* // { "id": 8, "title": "Fifth Sun" },
* // { "id": 16, "title": "MyLocker" },
* // { "id": 24, "title": "Inklocker" }
* // ]
*/
declare const getBlueprintProviders: (this: method, blueprintId: string) => Promise<GetBlueprintProviderResponse>;
type GetBlueprintVariantsResponse = {
id: number;
title: string;
variants: Variant[];
};
/**
* Retrieve a list of all variants of a blueprint from a specific print provider
*
* @param {string} blueprintId - The ID of the blueprint
* @param {string} printProviderId - The ID of the print provider
* @returns {Promise<GetBlueprintVariantsResponse>}
*
* @example
* const blueprintId = "3";
* const printProviderId = "8";
* const variants = await printify.catalog.getBlueprintVariants(blueprintId, printProviderId);
* console.log(variants);
* // Expected response:
* // {
* // "id": 3,
* // "title": "DJ",
* // "variants": [
* // { "id": 17390, "title": "Heather Grey / XS", "options": { "color": "Heather Grey", "size": "XS" }, "placeholders": [ { "position": "back", "height": 3995, "width": 3153 }, { "position": "front", "height": 3995, "width": 3153 } ] },
* // // Additional variants...
* // ]
* // }
*/
declare const getBlueprintVariants: (this: method, blueprintId: string, printProviderId: string) => Promise<GetBlueprintVariantsResponse>;
type GetVariantShippingResponse = {
handling_time: {
value: number;
unit: string;
};
profiles: ShippingProfile[];
};
/**
* Retrieve the shipping information for all variants of a blueprint from a specific print provider
*
* @param {string} blueprintId - The ID of the blueprint
* @param {string} printProviderId - The ID of the print provider
* @returns {Promise<GetVariantShippingResponse>}
*
* @example
* const blueprintId = "3";
* const printProviderId = "8";
* const shipping = await printify.catalog.getVariantShipping(blueprintId, printProviderId);
* console.log(shipping);
* // Expected response:
* // {
* // "handling_time": { "value": 30, "unit": "day" },
* // "profiles": [
* // { "variant_ids": [ list of variant IDs ], "first_item": { "cost": 450, "currency": "USD" }, "additional_items": { "cost": 0, "currency": "USD" }, "countries": ["US"] },
* // { "variant_ids": [ list of variant IDs ], "first_item": { "cost": 650, "currency": "USD" }, "additional_items": { "cost": 0, "currency": "USD" }, "countries": [ list of countries ] },
* // { "variant_ids": [ list of variant IDs ], "first_item": { "cost": 1100, "currency": "USD" }, "additional_items": { "cost": 0, "currency": "USD" }, "countries": ["REST_OF_THE_WORLD"] }
* // ]
* // }
*/
declare const getVariantShipping: (this: method, blueprintId: string, printProviderId: string) => Promise<GetVariantShippingResponse>;
type ListProvidersResponse = PrintProvider[];
/**
* Retrieve a list of all available print-providers
*
* @returns {Promise<ListProvidersResponse>}
*
* @example
* await printify.catalog.listProviders();
* // Expected response: [
* // {
* // id: 1,
* // title: "SPOKE Custom Products",
* // location: {
* // address1: "89 Weirfield St",
* // address2: null,
* // city: "Brooklyn",
* // country: "US",
* // region: "NY",
* // zip: "11221-5120"
* // }
* // },
* // {
* // id: 2,
* // title: "CG Pro prints",
* // location: {
* // address1: "89 Weirfield St",
* // address2: null,
* // city: "Brooklyn",
* // country: "US",
* // region: "NY",
* // zip: "11221-5120"
* // }
* // },
* // // ...
* // ]
*/
declare const listProviders: (this: method) => Promise<ListProvidersResponse>;
type GetProviderResponse = {
id: number;
title: string;
location: Location;
blueprints: Blueprint[];
};
/**
* Retrieve a specific print-provider and a list of associated blueprint offerings
*
* @param {string} printProviderId - The ID of the print provider to retrieve
* @returns {Promise<GetProviderResponse>}
*
* @example
* const printProviderId = "123456";
* await printify.catalog.getProvider(printProviderId);
* // Expected response: {
* "id": 1,
* "title": "SPOKE Custom Products",
* "location": { "address1": "89 Weirfield St", "address2": null, "city": "Brooklyn", "country": "US", "region": "NY", "zip": "11221-5120" },
* "blueprints": [
* { "id": 265, "title": "Slim Iphone 8", "brand": "Case Mate", "model": "Slim Iphone 8", "images": ["https://images.printify.com/59b261c9b8e7e361c9147b1b.png"] },
* { "id": 266, "title": "Tough Iphone 8", "brand": "Case Mate", "model": "Tough Iphone 8", "images": ["https://images.printify.com/59b26fbfb8e7e36254554a34.png"] }
* // ...
* ]
* }
*/
declare const getProvider: (this: method, printProviderId: string) => Promise<GetProviderResponse>;
declare class Catalog extends HttpClient {
listBlueprints: typeof listBlueprints;
getBlueprint: typeof getBlueprint;
getBlueprintProviders: typeof getBlueprintProviders;
getBlueprintVariants: typeof getBlueprintVariants;
getVariantShipping: typeof getVariantShipping;
listProviders: typeof listProviders;
getProvider: typeof getProvider;
constructor(config: PrintifyConfig);
}
interface ShippingInfo {
type: string;
id: string;
attributes: {
name: string;
};
}
interface ShippingInfoSpecific {
type: string;
id: string;
attributes: {
shippingType: string;
country: {
code: string;
};
variantId: number;
shippingPlanId: string;
handlingTime: {
from: number;
to: number;
};
shippingCost: {
firstItem: {
amount: number;
currency: string;
};
additionalItems: {
amount: number;
currency: string;
};
};
};
}
type GetEconomyShippingInfoResponse = ShippingInfoSpecific;
/**
* Retrieve economy shipping method information
*
* @param {string} blueprintId - The ID of the blueprint
* @param {string} printProviderId - The ID of the print provider
* @returns {Promise<GetEconomyShippingInfoResponse>}
*
* @example
* await printify.v2.catalog.getEconomyShippingInfo('3', '8');
* // Expected response: [
* // [
* // {
* // "type": "variant_shipping_economy_us",
* // "id": "23494",
* // "attributes": {
* // "shippingType": "economy",
* // "country": {
* // "code": "US"
* // },
* // "variantId": 23494,
* // "shippingPlanId": "65a7c0825b50fcd56a018e02",
* // "handlingTime": {
* // "from": 4,
* // "to": 8
* // },
* // "shippingCost": {
* // "firstItem": {
* // "amount": 399,
* // "currency": "USD"
* // },
* // "additionalItems": {
* // "amount": 219,
* // "currency": "USD"
* // }
* // }
* // }
* // }
* // ]
*/
declare const getEconomyShippingInfo: (this: method, blueprintId: string, printProviderId: string) => Promise<GetEconomyShippingInfoResponse>;
type GetExpressShippingInfoResponse = ShippingInfoSpecific;
/**
* Retrieve express shipping method information
*
* @param {string} blueprintId - The ID of the blueprint
* @param {string} printProviderId - The ID of the print provider
* @returns {Promise<GetExpressShippingInfoResponse>}
*
* @example
* await printify.v2.catalog.getExpressShippingInfo('3', '8');
* // Expected response: [
* // [
* // {
* // "type": "variant_shipping_standard_us",
* // "id": "23494",
* // "attributes": {
* // "shippingType": "standard",
* // "country": {
* // "code": "US"
* // },
* // "variantId": 23494,
* // "shippingPlanId": "65a7c0825b50fcd56a018e02",
* // "handlingTime": {
* // "from": 4,
* // "to": 8
* // },
* // "shippingCost": {
* // "firstItem": {
* // "amount": 399,
* // "currency": "USD"
* // },
* // "additionalItems": {
* // "amount": 219,
* // "currency": "USD"
* // }
* // }
* // }
* // }
* // ]
*/
declare const getExpressShippingInfo: (this: method, blueprintId: string, printProviderId: string) => Promise<GetExpressShippingInfoResponse>;
type GetPriorityShippingInfoResponse = ShippingInfoSpecific;
/**
* Retrieve priority shipping method information
*
* @param {string} blueprintId - The ID of the blueprint
* @param {string} printProviderId - The ID of the print provider
* @returns {Promise<GetPriorityShippingInfoResponse>}
*
* @example
* await printify.v2.catalog.getPriorityShippingInfo('3', '8');
* // Expected response: [
* // [
* // {
* // "type": "variant_shipping_priority_us",
* // "id": "23494",
* // "attributes": {
* // "shippingType": "priority",
* // "country": {
* // "code": "US"
* // },
* // "variantId": 23494,
* // "shippingPlanId": "65a7c0825b50fcd56a018e02",
* // "handlingTime": {
* // "from": 4,
* // "to": 8
* // },
* // "shippingCost": {
* // "firstItem": {
* // "amount": 399,
* // "currency": "USD"
* // },
* // "additionalItems": {
* // "amount": 219,
* // "currency": "USD"
* // }
* // }
* // }
* // }
* // ]
*/
declare const getPriorityShippingInfo: (this: method, blueprintId: string, printProviderId: string) => Promise<GetPriorityShippingInfoResponse>;
type GetShippingListInfoResponse = ShippingInfo[];
/**
* Retrieve available shipping list information
*
* @param {string} blueprintId - The ID of the blueprint
* @param {string} printProviderId - The ID of the print provider
* @returns {Promise<GetShippingListInfoResponse>}
*
* @example
* await printify.v2.catalog.getShippingListInfo('3', '8');
* // Expected response: [
* // {
* // "type": "shipping_method",
* // "id": "1",
* // "attributes": {
* // "name": "standard"
* // }
* // },
* // {
* // "type": "shipping_method",
* // "id": "2",
* // "attributes": {
* // "name": "priority"
* // }
* // },
* // {
* // "type": "shipping_method",
* // "id": "3",
* // "attributes": {
* // "name": "express"
* // }
* // },
* // {
* // "type": "shipping_method",
* // "id": "4",
* // "attributes": {
* // "name": "economy"
* // }
* // }
* // ]
*/
declare const getShippingListInfo: (this: method, blueprintId: string, printProviderId: string) => Promise<GetShippingListInfoResponse>;
type GetStandardShippingInfoResponse = ShippingInfoSpecific;
/**
* Retrieve standard shipping method information
*
* @param {string} blueprintId - The ID of the blueprint
* @param {string} printProviderId - The ID of the print provider
* @returns {Promise<GetShippingListInfoResponse>}
*
* @example
* await printify.v2.catalog.getShippingListInfo('3', '8');
* // Expected response: [
* // {
* // "type": "variant_shipping_standard_us",
* // "id": "23494",
* // "attributes": {
* // "shippingType": "standard",
* // "country": {
* // "code": "US"
* // },
* // "variantId": 23494,
* // "shippingPlanId": "65a7c0825b50fcd56a018e02",
* // "handlingTime": {
* // "from": 4,
* // "to": 8
* // },
* // "shippingCost": {
* // "firstItem": {
* // "amount": 399,
* // "currency": "USD"
* // },
* // "additionalItems": {
* // "amount": 219,
* // "currency": "USD"
* // }
* // }
* // }
* // }
* // ]
*/
declare const getStandardShippingInfo: (this: method, blueprintId: string, printProviderId: string) => Promise<GetStandardShippingInfoResponse>;
declare class CatalogV2 extends HttpClient {
getShippingListInfo: typeof getShippingListInfo;
getStandardShippingInfo: typeof getStandardShippingInfo;
getPriorityShippingInfo: typeof getPriorityShippingInfo;
getExpressShippingInfo: typeof getExpressShippingInfo;
getEconomyShippingInfo: typeof getEconomyShippingInfo;
constructor(config: PrintifyConfig);
}
interface ListOrdersResponse {
current_page: number;
data: Order[];
}
/**
* Retrieve a list of orders
*
* @param {number} page - The page number of orders to retrieve
* @returns {Promise<ListOrdersResponse>}
*
* @example
* await printify.orders.list();
* // Expected response: {
* current_page: 2,
* data: [ { id: "5a96f649b2439217 } ]
* }
* printify.orders.list({ page: 2 });
* printify.orders.list({ limit: 5 });
* printify.orders.list({ status: "fulfilled" });
* printify.orders.list({ sku: "168699843" });
*/
declare const list$4: (this: method, options?: {
page?: number;
limit?: number;
status?: string;
sku?: string;
}) => Promise<ListOrdersResponse>;
type GetOrderResponse = Order;
/**
* Get order details by id
*
* @param {string} orderId - The ID of the order to retrieve
* @returns {Promise<GetOrderResponse>}
*
* @example
* const orderId = '5a96f649b2439217d070f507';
* const response = await printify.orders.getOne(orderId);
* // Expected response: {
* // id: "5a96f649b2439217d070f507",
* // address_to: {
* // first_name: "John",
* // last_name: "Smith",
* // region: "",
* // address1: "ExampleBaan 121",
* // city: "Retie",
* // zip: "2470",
* // email: "example@msn.com",
* // phone: "0574 69 21 90",
* // country: "BE",
* // company: "MSN"
* // },
* // line_items: [
* // {
* // product_id: "5b05842f3921c9547531758d",
* // quantity: 1,
* // variant_id: 17887,
* // print_provider_id: 5,
* // cost: 1050,
* // shipping_cost: 400,
* // status: "fulfilled",
* // metadata: {
* // title: "18K gold plated Necklace",
* // price: 2200,
* // variant_label: "Golden indigocoin",
* // sku: "168699843",
* // country: "United States"
* // },
* // sent_to_production_at: "2017-04-18 13:24:28+00:00",
* // fulfilled_at: "2017-04-18 13:24:28+00:00"
* // }
* // ],
* // metadata: {
* // order_type: "external",
* // shop_order_id: 1370762297,
* // shop_order_label: "1370762297",
* // shop_fulfilled_at: "2017-04-18 13:24:28+00:00"
* // },
* // total_price: 2200,
* // total_shipping: 400,
* // total_tax: 0,
* // status: "fulfilled",
* // shipping_method: 1,
* // is_printify_express: false,
* // is_economy_shipping: false,
* // shipments: [
* // {
* // carrier: "usps",
* // number: "94001116990045395649372",
* // url: "http://example.com/94001116990045395649372",
* // delivered_at: "2017-04-18 13:24:28+00:00"
* // }
* // ],
* // created_at: "2017-04-18 13:24:28+00:00",
* // sent_to_production_at: "2017-04-18 13:24:28+00:00",
* // fulfilled_at: "2017-04-18 13:24:28+00:00",
* // printify_connect: {
* // url: "https://example.com/printify_connect_hash",
* // id: "printify_connect_hash"
* // }
* // }
*/
declare const getOne$1: (this: method, orderId: string) => Promise<GetOrderResponse>;
interface SubmitOrderData {
external_id: string;
label?: string;
line_items: NewLineItem[];
shipping_method: number;
is_printify_express: boolean;
is_economy_shipping: boolean;
send_shipping_notification: boolean;
address_to: Address;
}
type SubmitOrderResponse = {
id: string;
};
/**
* Submit an order (this creates a draft, you will send to production separately)
*
* @param {SubmitOrderData} data - The order data to be submitted
* @returns {Promise<SubmitOrderResponse>}
*
* @example
* const data = {
* external_id: '2750e210-39bb-11e9-a503-452618153e4a',
* label: '00012', // optional
* line_items: [{ product_id: '5bfd0b66a342bcc9b5563216', variant_id: 17887, quantity: 1 }],
* shipping_method: 1,
* is_printify_express: false,
* is_economy_shipping: false,
* send_shipping_notification: false,
* address_to: {
* first_name: 'John',
* last_name: 'Smith',
* email: 'example@msn.com',
* phone: '0574 69 21 90',
* country: 'BE',
* region: '',
* address1: 'ExampleBaan 121',
* address2: '45',
* city: 'Retie',
* zip: '2470',
* },
* };
* const response = await printify.orders.submit(data);
* // Expected response: { id: "5a96f649b2439217d070f507" }
*/
declare const submit: (this: method, data: SubmitOrderData) => Promise<SubmitOrderResponse>;
interface SubmitExpressData {
external_id: string;
label: string;
line_items: ExpressLineItem[];
shipping_method: number;
send_shipping_notification: boolean;
address_to: Address;
}
interface ExpressOrder {
type: string;
id: string;
attributes: {
fulfilment_type: string;
line_items: LineItem[];
};
}
type SubmitExpressOrderResponse = {
data: ExpressOrder[];
};
/**
* Submit a Printify Express order
*
* @param {SubmitExpressData} data - The data for the express order
* @returns {Promise<SubmitExpressOrderResponse>}
*
* @example
* const data = {
* external_id: '2750e210-39bb-11e9-a503-452618153e4a',
* label: '00012',
* line_items: [
* { product_id: '5b05842f3921c9547531758d', variant_id: 12359, quantity: 1 },
* { product_id: '5b05842f3921c34764fa478bc', variant_id: 17887, quantity: 1 },
* ],
* shipping_method: 3,
* send_shipping_notification: false,
* address_to: {
* first_name: 'John',
* last_name: 'Smith',
* email: 'example@example.com',
* phone: '0574 69 21 90',
* country: 'BE',
* region: '',
* address1: 'ExampleBaan 121',
* address2: '45',
* city: 'Retie',
* zip: '2470',
* },
* };
* await printify.orders.submitExpress(data);
* // Expected response: {
* data: [
* { type: "order", id: "5a96f649b2439217d070f508", ... },
* { type: "order", id: "5a96f649b2439597d020a9b4", ... }
* ]
* }
*/
declare const submitExpress: (this: method, data: SubmitExpressData) => Promise<SubmitExpressOrderResponse>;
type SendOrderToProductionResponse = {
id: string;
address_to: Address;
line_items: LineItem[];
metadata: {
order_type: string;
shop_fulfilled_at: string;
};
total_price: number;
total_shipping: number;
total_tax: number;
status: string;
shipping_method: number;
is_printify_express: boolean;
is_economy_shipping: boolean;
created_at: string;
};
/**
* Send an existing order to production
*
* @param {string} orderId - The ID of the order to be sent to production
* @returns {Promise<SendOrderToProductionResponse>}
*
* @example
* const orderId = "5d65c6ac01b403000a5d24d3";
* await printify.orders.sendToProduction(orderId);
* // Expected response: { id: "5d65c6ac01b403000a5d24d3", ... }
*/
declare const sendToProduction: (this: method, orderId: string) => Promise<SendOrderToProductionResponse>;
type CalculateShippingResponse = {
standard: number;
express: number;
priority: number;
printify_express: number;
economy: number;
};
/**
* Calculate the shipping cost of an order
*
* @param {CalculateShippingData} data - The data required to calculate shipping
* @returns {Promise<CalculateShippingResponse>}
*
* @example
* const data = {
* 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',
* last_name: 'Smith',
* email: 'example@msn.com',
* phone: '0574 69 21 90',
* country: 'BE',
* region: '',
* address1: 'ExampleBaan 121',
* address2: '45',
* city: 'Retie',
* zip: '2470',
* },
* };
* const shippingCosts = await printify.orders.calculateShipping(data);
* // Expected response: { standard: 1000, express: 5000, priority: 5000, printify_express: 799, economy: 399 }
*/
declare const calculateShipping: (this: method, data: CalculateShippingData) => Promise<CalculateShippingResponse>;
type CancelUnpaidOrderResponse = {
id: string;
address_to: Address;
line_items: LineItem[];
metadata: {
order_type: string;
shop_order_id: string;
shop_order_label: string;
shop_fulfilled_at: string;
};
total_price: number;
total_shipping: number;
total_tax: number;
status: string;
shipping_method: number;
is_printify_express: boolean;
is_economy_shipping: boolean;
created_at: string;
};
/**
* Cancel an unpaid order. Status must be "on-hold" or "payment-not-received"
*
* @param {string} orderId - The ID of the order to be canceled
* @returns {Promise<CancelUnpaidOrderResponse>}
*
* @example
* const orderId = '5dee261dc400914833007902';
* const response = await printify.orders.cancelUnpaid(orderId);
* // Expected response: {
* // id: "5dee261dc400914833007902",
* // address_to: {
* // first_name: "John",
* // last_name: "Smith",
* // email: "example@msn.com",
* // country: "United States",
* // region: "CA",
* // address1: "31677 Virginia Way",
* // city: "Laguna Beach",
* // zip: "92653"
* // },
* // line_items: [
* // {
* // quantity: 1,
* // product_id: "5de6593ebff03b5313567d22",
* // variant_id: 34509,
* // print_provider_id: 6,
* // shipping_cost: 450,
* // cost: 0,
* // status: "canceled",
* // metadata: {
* // title: "Men's Organic Tee - Product 1",
* // variant_label: "S / Red",
* // sku: "3640",
* // country: "United Kingdom"
* // }
* // }
* // ],
* // metadata: {
* // order_type: "api",
* // shop_order_id: "2750e210-39bb-11e9-a503-452618153e4a",
* // shop_order_label: "2750e210-39bb-11e9-a503-452618153e4a",
* // shop_fulfilled_at: "1970-01-01 00:00:00+00:00"
* // },
* // total_price: 0,
* // total_shipping: 0,
* // total_tax: 0,
* // status: "canceled",
* // shipping_method: 1,
* // is_printify_express: false,
* // is_economy_shipping: false,
* // created_at: "2019-12-09 10:46:53+00:00"
* // }
*/
declare const cancelUnpaid: (this: method, orderId: string) => Promise<CancelUnpaidOrderResponse>;
declare class Orders extends HttpClient {
list: typeof list$4;
getOne: typeof getOne$1;
submit: typeof submit;
submitExpress: typeof submitExpress;
sendToProduction: typeof sendToProduction;
calculateShipping: typeof calculateShipping;
cancelUnpaid: typeof cancelUnpaid;
constructor(config: PrintifyConfig);
}
type CreateProductResponse = Product;
/**
* Create a new product
*
* @param {NewProduct} data - The data to create the new product with
* @returns {Promise<CreateProductResponse>}
*
* @example
* const data = {
* title: 'Product',
* description: 'Good product',
* blueprint_id: 384,
* print_provider_id: 1,
* variants: [
* { id: 45740, price: 400, is_enabled: true },
* { id: 45742, price: 400, is_enabled: true },
* { id: 45744, price: 400, is_enabled: false },
* { id: 45746, price: 400, is_enabled: false }
* ],
* print_areas: [
* {
* variant_ids: [45740, 45742, 45744, 45746],
* placeholders: [{ position: 'front', images: [{ id: '5d15ca551163cde90d7b2203', x: 0.5, y: 0.5, scale: 1, angle: 0 }] }]
* }
* ]
* };
* await printify.products.create(data);
* // Expected response: {
* // "id": "5d39b159e7c48c000728c89f",
* // "title": "Mug 11oz",
* // "description": "<desc>",
* // "options": [],
* // "variants": [],
* // "images": [],
* // "created_at": "2019-07-25 13:40:41+00:00",
* // "updated_at": "2019-07-25 13:40:59+00:00",
* // "blueprint_id": 68,
* // "user_id": 1337,
* // "shop_id": 1337,
* // "print_provider_id": 9,
* // "print_areas": [],
* // }
*/
declare const create$1: (this: method, data: NewProduct) => Promise<CreateProductResponse>;
/**
* Delete a product
*
* @param {string} productId - The ID of the product to be deleted
* @returns {Promise<void>}
*
* @example
* const productId = "5cb87a8cd490a2ccb256cec4";
* await printify.products.deleteOne(productId);
* // Expected response: {}
*/
declare const deleteOne$2: (this: method, productId: string) => Promise<void>;
type GetProductResponse = Product;
/**
* Retrieve a product
*
* @param {string} productId *The ID of the product to retrieve
* @returns {Promise<GetProductResponse>}
*
* @example
* const productId = "5d39b159e7c48c000728c89f";
* const product = await printify.products.getOne(productId);
* Expected response: {
* "id": "5d39b159e7c48c000728c89f",
* "title": "Mug 11oz",
* "description": "<desc>",
* "options": [],
* "variants": [],
* "images": [],
* "created_at": "2019-07-25 13:40:41+00:00",
* "updated_at": "2019-07-25 13:40:59+00:00",
* "blueprint_id": 68,
* "user_id": 1337,
* "shop_id": 1337,
* "print_provider_id": 9,
* "print_areas": [],
* }
*/
declare const getOne: (this: method, productId: string) => Promise<GetProductResponse>;
type ListProductsResponse = {
current_page: number;
data: Product[];
first_page_url: string;
from: number;
last_page: number;
last_page_url: string;
next_page_url: string | null;
path: string;
per_page: number;
prev_page_url: string | null;
to: number;
total: number;
};
/**
* Retrieve a list of all products with optional pagination and limit.
*
* @param {{ page?: number; limit?: number }} [option] - pagination and limit options
* @returns {Promise<ListProductsResponse>}
*
* @example
* await printify.products.list();
* await printify.products.list({ page: 2 });
* await printify.products.list({ limit: 5 });
*
* // Expected response:
* // {
* // "current_page": 2,
* // "data": [ { "id": "5d39b159e7c48c000728c89f", "title": "Mug 11oz", ... }, ... ],
* // "total": 22
* // }
*/
declare const list$3: (this: method, options?: {
page?: number;
limit?: number;
}) => Promise<ListProductsResponse>;
/**
- Notify that a product has been unpublished
-
- @param {string} productId - The ID of the product to notify
- @returns {Promise<void>}
-
- @example
- const productId = "5d39b159e7c48c000728c89f";
- await printify.products.notifyUnpublished(productId);
- // Expected response: {}
*/
declare const notifyUnpublished: (this: method, productId: string) => Promise<void>;
interface ProductPublishData {
title: boolean;
description: boolean;
images: boolean;
variants: boolean;
tags: boolean;
keyFeatures: boolean;
shipping_template: boolean;
}
/**
* Publish a product
*
* @param {string} productId - The ID of the product to be published
* @param {PublishData} data - The data to be sent with the publish request
* @returns {Promise<void>}
*
* @example
* const data = { title: true, description: true, images: true, variants: true, tags: true, keyFeatures: true, shipping_template: true };
* await printify.products.publishOne('productId', data);
* // Expected response: {}
*/
declare const publishOne: (this: method, productId: string, data: ProductPublishData) => Promise<void>;
type PublishFailedData = {
reason: string;
};
/**
- Set product publish status to failed. Removes the product from the locked status on the Printify app.
-
- @param {string} productId - The ID of the product to update
- @param {PublishFailedData} data - Data containing reason for the failure
- @returns {Promise<void>}
-
- @example
- const data = { reason: 'Request timed out' };
- await printify.products.setPublishFailed('productId', data);
- // Expected response: {}
*/
declare const setPublishFailed: (this: method, productId: string, data: PublishFailedData) => Promise<void>;
type PublishSucceededData = {
external: ExternalProductData;
};
/**
- Set product publish status to succeeded. Removes the product from the locked status on the Printify app and sets its external property with the handle you provide in the request body.
-
- @param {string} productId - The ID of the product to update
- @param {PublishSucceededData} data - Data containing external properties to set
- @returns {Promise<void>}
-
- @example
- const data = { external: { id: '5941187eb8e7e37b3f0e62e5', handle: 'https://example.com/path/to/product' } };
- await printify.products.setPublishSucceeded('productId', data);
- // Expected response: {}
*/
declare const setPublishSucceeded: (this: method, productId: string, data: PublishSucceededData) => Promise<void>;
type UpdateProductResponse = Product;
/**
* Update a product
*
* @param {string} productId - The ID of the product to be updated
* @param {UpdateProductData} data - The data to be sent with the update request
* @returns {Promise<UpdateProductResponse>}
*
* @example
* const data = { title: 'Product' };
* await printify.products.updateOne('productId', data);
* // Expected response: {
* // "id": "5d39b159e7c48c000728c89f",
* // "title": "Mug 11oz",
* // "description": "<desc>",
* // "options": [],
* // "variants": [],
* // "images": [],
* // "created_at": "2019-07-25 13:40:41+00:00",
* // "updated_at": "2019-07-25 13:40:59+00:00",
* // "blueprint_id": 68,
* // "user_id": 1337,
* // "shop_id": 1337,
* // "print_provider_id": 9,
* // "print_areas": [],
* // }
*/
declare const updateOne$1: (this: method, productId: string, data: UpdateProductData) => Promise<UpdateProductResponse>;
declare class Products extends HttpClient {
create: typeof create$1;
deleteOne: typeof deleteOne$2;
getOne: typeof getOne;
list: typeof list$3;
notifyUnpublished: typeof notifyUnpublished;
publishOne: typeof publishOne;
setPublishFailed: typeof setPublishFailed;
setPublishSucceeded: typeof setPublishSucceeded;
updateOne: typeof updateOne$1;
constructor(config: PrintifyConfig);
}
/**
* Disconnect a shop
*
* @param {string} shopId - The ID of the shop to disconnect
* @returns {Promise<void>}
*
* @example
* const customShopId = "67890";
* await printify.shops.deleteOne(customShopId);
* // Expected response: {}
*/
declare const deleteOne$1: (this: method, customShopId?: string) => Promise<void>;
type ListShopsResponse = Shop[];
/**
* Retrieve a list of shops in a Printify account
*
* @returns {Promise<ListShopsResponse>}
*
* @example
* const shops = await printify.shops.list();
* // Expected response:
* // [
* // { id: 5432, title: "My new store", sales_channel: "My Sales Channel" },
* // { id: 9876, title: "My other new store", sales_channel: "disconnected" }
* // ]
*/
declare const list$2: (this: method) => Promise<ListShopsResponse>;
declare class Shops extends HttpClient {
deleteOne: typeof deleteOne$1;
list: typeof list$2;
constructor(config: PrintifyConfig);
}
/**
* Archive an uploaded image
*
* @param {string} imageId - The ID of the image to be archived
* @returns {Promise<void>}
*
* @example
* const imageId = "5cb87a8cd490a2ccb256cec4";
* await printify.uploads.archive(imageId);
* // Expected response: {}
*/
declare const archive: (this: method, imageId: string) => Promise<void>;
type GetUploadByIdResponse = ImageUpload;
/**
* Retrieve an uploaded image by id
*
* @param {string} imageId - The ID of the image to retrieve
* @returns {Promise<GetUploadByIdResponse>}
*
* @example
* const imageId = "5e16d66791287a0006e522b2";
* const imageData = await printify.uploads.getById(imageId);
* // Expected response:
* // {
* // id: "5e16d66791287a0006e522b2",
* // file_name: "png-images-logo-1.jpg",
* // height: 5979,
* // width: 17045,
* // size: 1138575,
* // mime_type: "image/png",
* // preview_url: "https://example.com/image-storage/uuid1",
* // upload_time: "2020-01-09 07:29:43"
* // }
*/
declare const getById: (this: method, imageId: string) => Promise<GetUploadByIdResponse>;
type ListUploadsResponse = {
current_page: number;
data: ImageUpload[];
first_page_url: string;
from: number;
last_page: number;
last_page_url: string;
next_page_url: string | null;
path: string;
per_page: number;
prev_page_url: string | null;
to: number;
total: number;
};
/**
* Retrieve a list of uploaded images with optional pagination and limit.
*
* @param {number} [page] - Page number
* @param {number} [limit] - Results per page
* @returns {Promise<ListUploadsResponse>}
*
* @example
* await printify.uploads.list();
* await printify.uploads.list(page=2);
* await printify.uploads.list(undefined, limit=5);
*
* // Expected response:
* // {
* // "current_page": 1,
* // "data": [ { "id": "5e16d66791287a0006e522b2", "file_name": "png-images-logo-1.jpg" }, ... ],
* // "total": 2
* // }
*/
declare const list$1: (this: method, page?: number, limit?: number) => Promise<ListUploadsResponse>;
interface UploadImageDataUrl {
file_name: string;
url: string;
}
interface UploadImageDataBase64 {
file_name: string;
contents: string;
}
type UploadImageResponse = ImageUpload;
/**
* Upload an image file via URL or base64-encoded contents
*
* @param {UploadImageDataUrl | UploadImageDataBase64} data - The data to upload (URL or base64-encoded)
* @returns {Promise<UploadImageResponse>}
*
* @example
* const dataUrl = { file_name: '1x1-ff00007f.png', url: 'http://png-pixel.com/1x1-ff00007f.png' };
* const response = await printify.uploads.uploadImage(dataUrl);
*
* const dataBase64 = { file_name: 'image.png', contents: '<base-64-encoded-content>' };
* const response = await printify.uploads.uploadImage(dataBase64);
*/
declare const uploadImage: (this: method, data: UploadImageDataUrl | UploadImageDataBase64) => Promise<UploadImageResponse>;
declare class Uploads extends HttpClient {
archive: typeof archive;
getById: typeof getById;
list: typeof list$1;
uploadImage: typeof uploadImage;
constructor(config: PrintifyConfig);
}
type ListWebhooksResponse = Webhook[];
/**
* Retrieve a list of webhooks
*
* @returns {Promise<ListWebhooksResponse>}
*
* @example
* const webhooks = await printify.webhooks.list();
* // Expected response:
* // [
* // { "topic": "order:created", "url": "https://example.com/webhooks/order/created", "shop_id": "1", "id": "5cb87a8cd490a2ccb256cec4" },
* // { "topic": "order:updated", "url": "https://example.com/webhooks/order/updated", "shop_id": "1", "id": "5cb87a8cd490a2ccb256cec5" }
* // ]
*/
declare const list: (this: method) => Promise<ListWebhooksResponse>;
type CreateWebhookResponse = {
topic: string;
url: string;
shop_id: string;
id: string;
};
/**
* Create a new webhook
*
* @param {NewWebhook} data - The webhook data to be sent in the request body
* @returns {Promise<CreateWebhookResponse>}
*
* @example
* const data = { topic: "order:created", url: "https://example.com/webhooks/order/created" };
* const response = await printify.webhooks.create(data);
* // Expected response:
* // {
* // "topic": "order:created",
* // "url": "https://example.com/webhooks/order/created",
* // "shop_id": "1",
* // "id": "5cb87a8cd490a2ccb256cec4"
* // }
*/
declare const create: (this: method, data: NewWebhook) => Promise<CreateWebhookResponse>;
type UpdateWebhookResponse = {
topic: string;
url: string;
shop_id: string;
id: string;
};
/**
* Modify a webhook
*
* @param {string} webhookId - The ID of the webhook to be updated
* @param {{ url: string }} data - The data to update the webhook with
* @returns {Promise<UpdateWebhookResponse>}
*
* @example
* const data = { url: 'https://example.com/callback/order/created' };
* const response = await printify.webhooks.updateOne('5cb87a8cd490a2ccb256cec4', data);
* // Expected response:
* // {
* // "topic": "order:created",
* // "url": "https://example.com/callback/order/created",
* // "shop_id": "1",
* // "id": "5cb87a8cd490a2ccb256cec4"
* // }
*/
declare const updateOne: (this: method, webhookId: string, data: {
url: string;
}) => Promise<UpdateWebhookResponse>;
type DeleteWebhookResponse = {
id: string;
};
/**
* Delete a webhook
*
* @param {string} webhookId - The ID of the webhook to be deleted
* @returns {Promise<DeleteWebhookResponse>}
*
* @example
* const response = await printify.webhooks.deleteOne('5cb87a8cd490a2ccb256cec4');
* // Expected response:
* // {
* // "id": "5cb87a8cd490a2ccb256cec4"
* // }
*/
declare const deleteOne: (this: method, webhookId: string) => Promise<DeleteWebhookResponse>;
declare class Webhooks extends HttpClient {
list: typeof list;
create: typeof create;
updateOne: typeof updateOne;
deleteOne: typeof deleteOne;
constructor(config: PrintifyConfig);
}
interface PrintifyConfig {
accessToken: string;
shopId?: string;
enableLogging?: boolean;
host?: string;
timeout?: number;
}
declare class PrintifyClient {
shopId?: string;
catalog: Catalog;
orders: Orders;
products: Products;
shops: Shops;
uploads: Uploads;
webhooks: Webhooks;
v2: {
catalog: CatalogV2;
};
constructor(config: PrintifyConfig);
}
export { type Address, type Blueprint, type CalculateShippingData, type ExpressLineItem, type ExternalProductData, type ImageUpload, type LineItem, type Location, type NewLineItem, type NewProduct, type NewWebhook, type Order, type OrderShipment, type Placeholder, type PrintArea, type PrintProvider, type PrintifyConnection, type Product, type ShippingInfo, type ShippingInfoSpecific, type ShippingLineItem, type ShippingProfile, type Shop, type UpdateProductData, type Variant, type Webhook, PrintifyClient as default };