/Printfulpy

python3 wrapper for Printful api

Primary LanguagePythonApache License 2.0Apache-2.0

printfulpy

Requests and responses

Request endpoint All API requests have to be sent to this URL: https://api.printful.com/ If you are using a proxy, make sure that all requests have host header set to api.printful.com.

Request parameters Some mandatory parameters (like object identifiers) must be included in the request URL path GET /orders/123 Additional parameters can be passed as GET variables: GET /orders?offset=10&limit=5 For POST and PUT requests, a more complex data structure can be passed as JSON encoded data in the request body: POST /orders {\"recipient\":{...},\"items\":[...]}

Response body The response body is always a JSON object that contains a response status code (identical to the HTTP status code) and the result of the action. If the status code is 200, then the action was successful. { \"code\": 200, //Response status code \"result\":{//API method return data //... } } Sometimes the response includes paging information to allow to browse larger result sets by adding offset and limit GET parameters to the request URL. { \"code\": 200, //Response status code \"result\":[{//Item 11},{//Item 12}]\"paging\": {\"total\": 12, //Total items available\"offset\": 10, //Items skipped from the beginning\"limit\": 20 //Number of items per page} }

Error response If the API call is not successful, then the response code is not in the 2xx range and the result attribute contains an error description. {\"code\": 404, \"result\": \"Not Found\", \"error\": {\"reason\": \"NotFound\",\"message\": \"Not Found\"} } In general, response codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing, etc.), and codes in the 5xx range indicate an error with Printful's servers.

Timestamps All timestamps from the API are returned as integers in UNIX timestamp format. ### Rate Limits Printful API has a general rate limit of 120 API calls per minute. Additionally, endpoints that perform resource intensive operations (such as mockup generator) have a lower allowed request limit. # Authentication

This Python package is automatically generated by the Swagger Codegen project:

  • API version: 1.0
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen For more information, please visit https://www.printful.com/docs/support

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on Github, you can install directly from Github

pip install git+https://github.com/connorguy/Printfulpy.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import printfulpy 

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import printfulpy

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function
import time
import printfulpy
from printfulpy.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = printfulpy.ApprovalSheetsAPIApi(printfulpy.ApiClient(configuration))
body = NULL # object | POST request body
confirm_hash = 'confirm_hash_example' # str | The confirm hash for the approval sheet you would like to approve.
x_pf_store_id = 'x_pf_store_id_example' # str | Use this to specify which store you want to use (required only for account level token) (optional)

try:
    # Approve a design
    api_response = api_instance.approve_design(body, confirm_hash, x_pf_store_id=x_pf_store_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ApprovalSheetsAPIApi->approve_design: %s\n" % e)

# create an instance of the API class
api_instance = printfulpy.ApprovalSheetsAPIApi(printfulpy.ApiClient(configuration))
x_pf_store_id = 'x_pf_store_id_example' # str | Use this to specify which store you want to use (required only for account level token) (optional)

try:
    # Retrieve a list of approval sheets
    api_response = api_instance.get_approval_sheets(x_pf_store_id=x_pf_store_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ApprovalSheetsAPIApi->get_approval_sheets: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.printful.com

Class Method HTTP request Description
ApprovalSheetsAPIApi approve_design POST /approval-sheets Approve a design
ApprovalSheetsAPIApi get_approval_sheets GET /approval-sheets Retrieve a list of approval sheets
CatalogAPIApi get_categories GET /categories Get Categories
CatalogAPIApi get_category_by_id GET /categories/{id} Get Category
CatalogAPIApi get_product_by_id GET /products/{id} Get Product
CatalogAPIApi get_product_size_guide_by_id GET /products/{id}/sizes Get Product Size Guide
CatalogAPIApi get_products GET /products Get Products
CatalogAPIApi get_variant_by_id GET /products/variant/{id} Get Variant
CountryStateCodeAPIApi get_countries GET /countries Retrieve country list
EcommercePlatformSyncAPIApi delete_store_sync_product DELETE /sync/products/{id} Delete a Sync Product
EcommercePlatformSyncAPIApi delete_store_sync_variant DELETE /sync/variant/{id} Delete a Sync Variant
EcommercePlatformSyncAPIApi get_store_sync_product_by_id GET /sync/products/{id} Get a Sync Product
EcommercePlatformSyncAPIApi get_store_sync_products GET /sync/products Get list of Sync Products
EcommercePlatformSyncAPIApi get_store_sync_variant_by_id GET /sync/variant/{id} Get a Sync Variant
EcommercePlatformSyncAPIApi update_store_sync_variant PUT /sync/variant/{id} Modify a Sync Variant
FileLibraryAPIApi add_file POST /files Add a new file
FileLibraryAPIApi get_file GET /files/{id} Get file
FileLibraryAPIApi thread_colors POST /files/thread-colors Return available thread colors from provided image URL
MockupGeneratorAPIApi create_generator_task POST /mockup-generator/create-task/{id} Create a mockup generation task
MockupGeneratorAPIApi get_printfiles GET /mockup-generator/printfiles/{id} Retrieve product variant printfiles
MockupGeneratorAPIApi get_task GET /mockup-generator/task Mockup generation task result
MockupGeneratorAPIApi get_templates GET /mockup-generator/templates/{id} Layout templates
OAuthAPIApi get_scopes GET /oauth/scopes Get scopes for token
OrdersAPIApi cancel_order_by_id DELETE /orders/{id} Cancel an order
OrdersAPIApi confirm_order_by_id POST /orders/{id}/confirm Confirm draft for fulfillment
OrdersAPIApi create_order POST /orders Create a new order
OrdersAPIApi estimate_order_costs POST /orders/estimate-costs Estimate order costs
OrdersAPIApi get_order_by_id GET /orders/{id} Get order data
OrdersAPIApi get_orders GET /orders Get list of orders
OrdersAPIApi update_order_by_id PUT /orders/{id} Update order data
ProductTemplatesAPIApi delete_product_template DELETE /product-templates/{id} Delete product template
ProductTemplatesAPIApi get_product_template_by_id GET /product-templates/{id} Get product template
ProductTemplatesAPIApi get_product_templates GET /product-templates Get product template list
ProductsAPIApi create_sync_product POST /store/products Create a new Sync Product
ProductsAPIApi create_sync_variant POST /store/products/{id}/variants Create a new Sync Variant
ProductsAPIApi delete_sync_product DELETE /store/products/{id} Delete a Sync Product
ProductsAPIApi delete_sync_variant DELETE /store/variants/{id} Delete a Sync Variant
ProductsAPIApi get_sync_product_by_id GET /store/products/{id} Get a Sync Product
ProductsAPIApi get_sync_products GET /store/products Get Sync Products
ProductsAPIApi get_sync_variant_by_id GET /store/variants/{id} Get a Sync Variant
ProductsAPIApi update_sync_product PUT /store/products/{id} Modify a Sync Product
ProductsAPIApi update_sync_variant PUT /store/variants/{id} Modify a Sync Variant
ReportsAPIApi get_statistics GET /reports/statistics Get statistics
ShippingRateAPIApi calculate_shipping_rates POST /shipping/rates Calculate shipping rates
StoreInformationAPIApi change_packing_slip POST /store/packing-slip Change packing slip
StoreInformationAPIApi get_store GET /stores/{id} Get basic information about a store
StoreInformationAPIApi get_stores GET /stores Get basic information about stores
TaxRateAPIApi calculate_tax_rates POST /tax/rates Calculate tax rate
TaxRateAPIApi get_tax_countries GET /tax/countries Get a list of countries for tax calculation
WarehouseProductsAPIApi get_warehouse_product GET /warehouse/products/{id} Get warehouse product data
WarehouseProductsAPIApi get_warehouse_products GET /warehouse/products Get a list of your warehouse products
WebhookAPIApi create_webhook POST /webhooks Set up webhook configuration
WebhookAPIApi disable_webhook DELETE /webhooks Disable webhook support
WebhookAPIApi get_webhooks GET /webhooks Get webhook configuration

Documentation For Models

Documentation For Authorization

Basic

  • Type: HTTP basic authentication

OAuth

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://www.printful.com/oauth/token
  • Scopes:
  • orders: Read and Write access to Orders
  • orders/read: Read access to Orders
  • stores_list: Read and Write access to Stores
  • stores_list/read: Read access to Stores
  • sync_products: Read and Write access to SyncProducts
  • sync_products/read: Read access to SyncProducts
  • file_library: Read and Write access to File library
  • file_library/read: Read access to File library
  • webhooks: Read and Write access to Webhooks
  • webhooks/read: Read access to Webhooks

Author

devsupport@printful.com