Wrapper around the UPS API for creating shipping labels and fetching a package's tracking status.

Overview

ClassicUPS: A Useful UPS Library

ClassicUPS is an Apache2 Licensed wrapper around the UPS API for creating shipping labels and fetching a package's tracking status. This library by no means encompasses all of the UPS functionality, but it is suitable for some of the most common shipping-related common tasks.

Features

  • Track delivery status of tracking number
  • Create prepaid shipping labels in GIF or EPL (thermal printer) format

Installation

Installation is easy:

$ pip install ClassicUPS

ClassicUPS depends on libxml2 and libxslt. On Ubuntu, the packages are libxml2-dev and libxslt-dev.

Quickstart

Create a UPSConnection object, which gives you access to common UPS methods:

from ClassicUPS import UPSConnection

# Credentials obtained from the UPS website
ups = UPSConnection(license_number,
                    user_id,
                    password,
                    shipper_number,  # Optional if you are not creating a shipment
                    debug=True)      # Use the UPS sandbox API rather than prod

Check the delivery date of a package.

tracking = ups.tracking_info('1Z12345E0291980793')
print tracking.in_transit
print tracking.delivered

Create shipment and save shipping label as GIF file:

from_addr = {
    'name': 'Google',
    'address1': '1600 Amphitheatre Parkway',
    'city': 'Mountain View',
    'state': 'CA',
    'country': 'US',
    'postal_code': '94043',
    'phone': '6502530000'
}
to_addr = {
    'name': 'President',
    'address1': '1600 Pennsylvania Ave',
    'city': 'Washington',
    'state': 'DC',
    'country': 'US',
    'postal_code': '20500',
    'phone': '2024561111'
}
dimensions = {  # in inches
    'length': 1,
    'width': 4,
    'height': 9
}
weight = 10  # in lbs

# Create the shipment. Use file_format='EPL' for a thermal-printer-compatible EPL
shipment = ups.create_shipment(from_addr, to_addr, dimensions, weight,
                               file_format='GIF')

# Print information about our shipment
print shipment.cost
print shipment.tracking_number

# Save the shipping label to print, email, etc
shipment.save_label(open('label.gif', 'wb'))
Comments
  • Cannot find reference 'UPS Connection' in __init__.py

    Cannot find reference 'UPS Connection' in __init__.py

    This is my first attempt at importing a library from GitHub and actually my first program in Python, so I apologize if I am overlooking something very simple. Any advice would be appreciated.

    I am using python-3.7.3-amd64 and the latest version of PyCharm.

    I believe I did the steps correctly when I imported ClassicUPS into PyCharm by creating a project -> File -> Settings -> (project name) -> Project Interpreter -> (+ symbol) -> Search for ClassicUPS -> Install.

    When I attempt to run the first segment of code, I get the following error: Cannot find reference 'UPS Connection' in init.py

    Code segment:

    from ClassicUPS import UPSConnection
    
    # Credentials obtained from the UPS website
    ups = UPSConnection(license_number,
                        user_id,
                        password,
                        shipper_number,  # Optional if you are not creating a shipment
                        debug=True)      # Use the UPS sandbox API rather than prod
    

    image

    opened by Helix31522 4
  • More shipping services, tweaks for non-us senders et al.

    More shipping services, tweaks for non-us senders et al.

    I had to make some changes before I could use ClassicUPS for our project. These could be useful for others and shouldn't break anything. Thanks for making ClassicUPS available!

    opened by till44 3
  • SSL: CERTIFICATE_VERIFY_FAILED

    SSL: CERTIFICATE_VERIFY_FAILED

    Hello,

    Today, after many years of working, this library is giving me an error. Can someone please help?

    tracking = ups.tracking_info(tracking_number) throws the following exception:

    [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

    Thank you very much

    opened by Helix31522 2
  • xmltodict error

    xmltodict error

    Please see the error message below:

    pip install xmltodict

    ERROR: classicups 0.1.8 has requirement xmltodict==0.4.2, but you'll have xm ltodict 0.12.0 which is incompatible. Installing collected packages: xmltodict Successfully installed xmltodict-0.12.0

    opened by Helix31522 1
  • Module to return Shipment Information vs Activity Information

    Module to return Shipment Information vs Activity Information

    I added the following module under class TrackingInfo(object): but I get the error below when trying to execute print(tracking.shipment)

    I am trying to return the shipment information from the api call and ClassicUPS only gives the ability to see the activity scans.

    `` @property def shipment(self):

        shipment = (self.result.dict_response['TrackResponse']
        ['Shipment'])
        if type(shipment) != list:
            shipment = [shipment]
    
        return shipment
    

    Error: Traceback (most recent call last): File "C:/xxxxx.py", line 20, in <module> print(tracking.shipment) AttributeError: 'TrackingInfo' object has no attribute 'shipment'

    Any advice would be much appreciated.

    opened by Helix31522 1
  • KeyError: Shipment

    KeyError: Shipment

    >>> t = ups.tracking_info('1Z12345E0205271688 ')
    >>> t.in_transit
    

    Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/ClassicUPS/ups.py", line 131, in in_transit in_transit = [x for x in self.shipment_activities File "/usr/local/lib/python2.7/dist-packages/ClassicUPS/ups.py", line 116, in shipment_activities ['Shipment']['Package']['Activity']) KeyError: 'Shipment'

    Should handle if no shipment data is returned in the XML

    opened by flyboy1565 0
  • ERROR CODE

    ERROR CODE

    {'Response': {'TransactionReference': {'XpciVersion': '1.0001'}, 'ResponseStatusDescription': 'Failure', 'ResponseStatusCode': '0', 'Error': {'ErrorSeverity': 'Hard', 'ErrorCode': '10002', 'ErrorDescription': 'The XML document is well formed but the document is not valid'}}}

    opened by varun6661 0
  • Consider transfering package ownership to somebody else

    Consider transfering package ownership to somebody else

    The last commit in this repo was several years ago and work has been done in other repositories. Please think about handing over this package to one of the people who developed this further.

    opened by voidus 1
  • Regularly receive error:

    Regularly receive error: "IOError: [Errno socket error] EOF occurred in violation of protocol (_ssl.c:661)"

    About 80% of the time I receive the error:

    Traceback (most recent call last):
      File "/Users/F/Desktop/delete.py", line 22, in <module>
        tracking = ups.tracking_info('1Z51062E6893884735')
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ClassicUPS/ups.py", line 71, in tracking_info
        return TrackingInfo(self, *args, **kwargs)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ClassicUPS/ups.py", line 108, in __init__
        self.result = ups_conn._transmit_request('track', tracking_request)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ClassicUPS/ups.py", line 65, in _transmit_request
        resp = urllib.urlopen(url, xml.encode('ascii', 'xmlcharrefreplace'))\
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 89, in urlopen
        return opener.open(url, data)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 215, in open
        return getattr(self, name)(url, data)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 443, in open_https
        h.endheaders(data)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1038, in endheaders
        self._send_output(message_body)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 882, in _send_output
        self.send(msg)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 844, in send
        self.connect()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1263, in connect
        server_hostname=server_hostname)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 363, in wrap_socket
        _context=self)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 611, in __init__
        self.do_handshake()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 840, in do_handshake
        self._sslobj.do_handshake()
    IOError: [Errno socket error] EOF occurred in violation of protocol (_ssl.c:661)
    
    

    Do you know how to fix this? Thanks!

    opened by AFishNamedFish 0
Owner
Jay Goel
Jay Goel
Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Richard Kolkovich 904 Jan 2, 2023
An API wrapper around the pythonanywhere's API.

pyaww An API wrapper around the pythonanywhere's API. The name stands for pythonanywherewrapper. 100% api coverage most of the codebase is documented

null 7 Dec 11, 2022
An API wrapper around Discord API.

NeoCord This project is work in progress not for production use. An asynchronous API wrapper around Discord API written in Python. Features Modern API

Izhar Ahmad 14 Jan 3, 2022
An API wrapper around the pythonanywhere's API.

pyaww An API wrapper around the pythonanywhere's API. The name stands for pythonanywherewrapper. 100% API coverage Most of the codebase is documented

null 7 Dec 11, 2022
Telegram Bot Repo Capable of fetching the following Info via Anilist API inspired from AniFluid and Nepgear

Telegram Bot Repo Capable of fetching the following Info via Anilist API inspired from AniFluid and Nepgear Anime Airing Manga Character Scheduled Top

Rikka-Chan 2 Apr 1, 2022
A python package for fetching informations from GitHub API

Py-GitHub A python package for fetching informations from GitHub API Made with Python3 (C) @FayasNoushad Copyright permission under MIT License Licens

Fayas Noushad 6 Nov 28, 2021
A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer.

pushbullet-python A Python wrapper around the Pushbullet API to send different types of push notifications to your phone or/and computer. Installation

Janu Lingeswaran 1 Jan 14, 2022
A light wrapper around FedEx's SOAP API.

Python FedEx SOAP API Module Author: Greg Taylor, Radek Wojcik Maintainer: Python FedEx Developers License: BSD Status: Stable What is it? A light wra

null 155 Dec 16, 2022
Wrapper around the Mega API

python-mega Overview Wrapper around the Mega API. Based on the work of Julien Marchand. Installation Install using pip, including any optional package

Juan Riaza 104 Nov 26, 2022
A Python wrapper around the OpenWeatherMap web API

PyOWM A Python wrapper around OpenWeatherMap web APIs What is it? PyOWM is a client Python wrapper library for OpenWeatherMap (OWM) web APIs. It allow

Claudio Sparpaglione 740 Dec 18, 2022
A Python wrapper around the Soundcloud API

soundcloud-python A friendly wrapper around the Soundcloud API. Installation To install soundcloud-python, simply: pip install soundcloud Or if you'r

SoundCloud 83 Dec 12, 2022
Wrapper around the latest Tuenti API

python-tuenti Overview Wrapper around the latest Tuenti API. Installation Install using pip, including any optional packages you want... $ pip install

Juan Riaza 10 Mar 7, 2022
A Python wrapper around the Twitter API.

Python Twitter A Python wrapper around the Twitter API. By the Python-Twitter Developers Introduction This library provides a pure Python interface fo

Mike Taylor 3.4k Jan 1, 2023
A Python wrapper around the Twitter API.

Python Twitter A Python wrapper around the Twitter API. By the Python-Twitter Developers Introduction This library provides a pure Python interface fo

Mike Taylor 3.4k Jan 1, 2023
An asyncio Python wrapper around the Discord API, forked off of Rapptz's Discord.py.

Novus A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. A full fork of Rapptz's Discord.py library, with

Voxel Fox 60 Jan 3, 2023
An async-ready Python wrapper around FerrisChat's API.

FerrisWheel An async-ready Python wrapper around FerrisChat's API. Installation Instructions Linux: $ python3.9 -m pip install -U ferriswheel Python 3

FerrisChat 8 Feb 8, 2022
Fetching tweets and integrating it with Kafka and PySpark

KafkaPySpark Zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties Kafka Server bin/kafka-server-start.sh config/server.properties Kafka

Priyansh 2 Dec 29, 2021
API which uses discord+mojang api to scrape NameMC searches/droptime/dropping status of minecraft names, and texture links

API which uses discord+mojang api to scrape NameMC searches/droptime/dropping status of minecraft names, and texture links

null 2 Dec 22, 2021
🚀 An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase ?? Links |Join the discord

Pincer 125 Dec 26, 2022