/myshipper

Django web app api for getting USPS rates and Labels

Primary LanguagePython

#My Shipper API

API for getting rates and generating labels from USPS.

GET rates/

Query Parameter Notes
o_zip required, Origin Zip Code
d_zip required, Destination Zip Code
lbs required, Weight in pounds
mail_class optional, USPS Service type of: Priority,First Class,Standard Post,Media Mail, Library Mail
fcm_type required if mail_class = First Class; of: LETTER, Flat, Parcel, Postcard, or Package Service
oz optional, Weight in ounces, if over 1 lb
container optional, useful for USPS container types, default=VARIABLE
size optional, used for USPS weight types, default=REGULAR, can be REGULAR or LARGE
length required if size is LARGE, in inches
width required if size is LARGE in inches
height required if size is LARGE in inches
girth required if size is LARGE in inches
machinable required if mail_class is First Class and fcm is Letter or Flat, either true or false

####Sample GET Request with Required Parameters Only

/rates/?o_zip=78756&d_zip=78701&lbs=2

####Sample Response

{"data": [{"Rate": "19.15", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup>"}, {"Rate": "19.15", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Hold For Pickup"}, {"Rate": "44.95", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Flat Rate Boxes"}, {"Rate": "44.95", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Flat Rate Boxes Hold For Pickup"}, {"Rate": "19.99", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Flat Rate Envelope"}, {"Rate": "19.99", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Flat Rate Envelope Hold For Pickup"}, {"Rate": "19.99", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Legal Flat Rate Envelope"}, {"Rate": "19.99", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Legal Flat Rate Envelope Hold For Pickup"}, {"Rate": "19.99", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Padded Flat Rate Envelope"}, {"Rate": "19.99", "Mail Class": "Priority Mail Express 1-Day<sup>™</sup> Padded Flat Rate Envelope Hold For Pickup"}, {"Rate": "5.95", "Mail Class": "Priority Mail 1-Day<sup>™</sup>"}, {"Rate": "17.90", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Large Flat Rate Box"}, {"Rate": "12.65", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Medium Flat Rate Box"}, {"Rate": "5.95", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Small Flat Rate Box"}, {"Rate": "5.75", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Flat Rate Envelope"}, {"Rate": "5.90", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Legal Flat Rate Envelope"}, {"Rate": "6.10", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Padded Flat Rate Envelope"}, {"Rate": "5.75", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Gift Card Flat Rate Envelope"}, {"Rate": "5.75", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Small Flat Rate Envelope"}, {"Rate": "5.75", "Mail Class": "Priority Mail 1-Day<sup>™</sup> Window Flat Rate Envelope"}, {"Rate": "3.17", "Mail Class": "Media Mail Parcel"}, {"Rate": "3.02", "Mail Class": "Library Mail Parcel"}]}

####Sample GET Request with Mail Class Specified

/rates/?o_zip=78756&d_zip=78701&lbs=2&mail_class=priority

####Sample Response

{"data": [{"Rate": "5.95", "Mail Class": "Priority Mail 1-Day<sup>™</sup>"}]}

GET label/

Query Parameter Notes
f_name required, Sender Name
f_company optional, Sender company name
f_address_1 optional, Sender Address Line 1, for apartment, suite number, etc.
f_address_2 required, Sender Address Line 2, street address
f_city required, Sender City
f_state required, Sender State Code, two characters eg. TX or WA
f_zip5 required, Sender Zip Code
f_zip4 optional, Sender +4 Zip Code
to_name required, Receiver Name
to_company optional, Receiver company name
to_address_1 optional, Receiver Address Line 1, for apartment, suite number, etc.
to_address_2 required, Receiver Address Line 2, street address
to_city required, Receiver City
to_state required, Receiver State Code, two characters eg. TX or WA
to_zip5 required, Receiver Zip Code
to_zip4 optional, Receiver +4 Zip Code
weight required, Weight in ounces
mail_class required, USPS Service type of: Priority,First Class,Standard Post,Media Mail, Library Mail
container optional, useful for USPS container types, default=VARIABLE
size optional, used for USPS weight types, default=REGULAR, can be REGULAR or LARGE
length required if size is LARGE, in inches
width required if size is LARGE in inches
height required if size is LARGE in inches
girth required if size is LARGE in inches

####Sample GET Request with Required Parameters Only python

URL = '/label/?o_zip=78756&d_zip=78701&lbs=2'
params={'f_name':'Sophie Hernandez', 'f_address_2':'5310 Joe Sayers Ave Apt 120',\
        'f_city':'Austin','f_state':'TX','f_zip5':78756,'to_name':'Ben','to_address_2':'101 West 6th Street #405','to_city':'Austin',\
        'to_zip5':78701,'to_state':'tx', 'mail_class':'Priority','weight':2}
response = requests.get(URL, params=params)

200

Sample Response

link to PDF of label