Coder Social home page Coder Social logo

printful's Introduction

printful

Printful API Client for Python 3

The Printful API client wrapper makes life a bit easier when working with the API. This is an update from the original Python 2.7 client library that was provided here . The module requires an API key as input. The key can be generated in the store settings of your Printful account.

Quickstart

from printful import Printful
pf = Printful(key)
orders = pf.get('orders')

The Printful class extends the Requests library so data, param, json, etc. can be passed just as you would with requests.

address = {
    'recipient': {
        'country_code': 'US',
        'state_code': 'CA'
    },
    'items': [
        {'variant_id': 1, 'quantity': 1},
        {'variant_id': 1118, 'quantity': 2}
    ]
}

pf.post('shipping/rates', json=address)

Or, retrieve only certain orders using offset and limit.

pf.get('orders', params={'offset': 5, 'limit':10})

is equivalent to:

pf.get('orders&offset=10&limit=5')

printful's People

Contributors

siegerts avatar stuartgl avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

printful's Issues

Support for API keys ends March 2023

Hey! Great job on making life easier for us but unfortunately, the API key support is ending. It is my request that you update this module to support public and private tokens...

no api

PrintfulAPIException: Server Response 400: No product name

I am trying to create order but unable to understand why the error says No product name. Get commads are working file but post always gives me this error.

URL : 'https://api.printful.com/orders'

called like
pf.post(URL, json=order_dict)
where order_dict is below json

{'json': {
    'external_id': 28,
    'shipping': 'STANDARD',
    'recipient': {
        'name': 'Gemini Furniture',
        'address1': '317 Fairchild Dr',
        'address2': '',
        'city': 'Fairfield',
        'state_code': 'CA',
        'state_name': 'California',
        'country_code': 'US',
        'country_name': 'United States',
        'zip': '94535',
        'phone': '(941)-284-4875',
        'email': '[email protected]',
        'tax_number': False,
        },
    'items': [{
        'id': 1,
        'external_id': 248,
        'variant_id': '3128670962',
        'sync_variant_id': '266252696',
        'external_variant_id': '620589ad6e6fc7',
        'warehouse_product_variant_id': 1,
        'quantity': 1.0,
        'price': '13.00',
        'retail_price': 12.5,
        'name': 'Short-Sleeve Unisex T-Shirt - Black Heather / XS',
        'product': {
            'variant_id': '3128670962',
            'product_id': '266252696',
            'image': 'https://files.cdn.printful.com/products/71/4141_1581412215.jpg'
                ,
            'name': 'Short-Sleeve Unisex T-Shirt - Black Heather / XS',
            },
        'files': [],
        'options': [],
        'sku': '',
        }],
    'retail_costs': {
        'currency': 'USD',
        'subtotal': 14.38,
        'discount': '0',
        'shipping': '5.00',
        'digitization': '0',
        'tax': '0',
        'vat': '0',
        'total': 14.38,
        },
    'gift': {'subject': 'To John', 'message': 'Have a nice day'},
    'packing_slip': {
        'email': '[email protected]',
        'phone': '+371 28888888',
        'message': 'Message on packing slip',
        'logo_url': 'http://www.your-domain.com/packing-logo.png',
        'store_name': 'Your store name',
        },
    }, 'verify': True,
        'headers': {'Authorization': 'Basic YWp5c3djdnktaWV3Mi04bjVrOml1NmwtOW5yeGtrYnZhbDVp',
                    'User-Agent': 'Printful API Python Library 1.2',
                    'Content-Type': 'application/json'}}

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.