Library that allows integration with the Shipit API (https://developers.shipit.cl/docs) for Send dispatch requests, check your statements and other actions.
From source:
git clone https://github.com/jeffersonlizar/shipitchile
cd shipitchile
python setup.py install
From PyPi directly:
pip install shipitchile
To use the Shipit API you must have an account and access the "API" menu to Copy your email and access token.
https://clientes.shipit.cl/settings/api
from shipitchile import Shipit
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
shipit.email('EMAIL')
shipit.token('TOKEN')
shipit.environment(Shipit.ENV_DEVELOPMENT)
if you do not pass the environment value by default it starts in production
You can list the regions and communes that Shipit has registered to synchronize your system
shipit.regions()
shipit.communes()
regions = shipit.regions()
print(regions[0]['name'])
// "Arica y Parinacota"
You can send the information of your office and get a quote with the options of cariers available Shipit.
For this it is necessary that you create an instance ** QuotationRequest ** to be sent to the method ** quotation **.
from shipitchile import Shipit, QuotationRequest
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
data = QuotationRequest({
"length": 1,
"width": 1,
"height": 1,
"weight": 1,
"destiny": "Domicilio",
"is_payable": "false",
"commune_id": 295
})
items = shipit.quotation(data)
for item in items['shipments']:
print(item['courier'])
You can send the information of your office and get the cheapest quote.
from shipitchile import Shipit, QuotationRequest
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
data = QuotationRequest({
"length": 1,
"width": 1,
"height": 1,
"weight": 1,
"destiny": "Domicilio",
"is_payable": "false",
"commune_id": 295
})
item = shipit.economic_quotation(data)
print(item['shipment']['total'])
You can get the most convenient quote in both response time (SLA) and price.
from shipitchile import Shipit, QuotationRequest
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
data = QuotationRequest({
"length": 1,
"width": 1,
"height": 1,
"weight": 1,
"destiny": "Domicilio",
"is_payable": "false",
"commune_id": 295
})
item = shipit.best_quotation(data)
print(item['shipment']['total'])
To send a shipping request you must create an ** ShippingRequest ** instance to be sent to the ** request_shipping ** method:
from shipitchile import Shipit, ShippingRequest
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
data = ShippingRequest({
"reference": "S000001",
"full_name": "Jefferson Lizarzabal",
"email": "cliente@gmail.com",
"items_count": 1,
"cellphone": "912341234",
"is_payable": False,
"packing": ShippingRequest.PACKING_NONE,
"shipping_type": ShippingRequest.DELIVERY_NORMAL,
"destiny": ShippingRequest.DESTINATION_HOME,
"courier_for_client": ShippingRequest.COURIER_CHILEXPRESS,
"approx_size": ShippingRequest.SIZE_SMALL,
"address_commune_id": 317,
"address_street": "San Carlos",
"address_number": 123,
"address_complement": None
})
shipping = shipit.request_shipping(data)
print(shipping['id'])
To send a shipping request you must create an ** ShippingRequest ** instance to be sent to the ** request_shipping ** method:
from shipitchile import Shipit, ShippingRequest
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
shipping_list = []
shipping_1 = ShippingRequest({
"reference": "S000002",
"full_name": "Jefferson Lizarzabal",
"email": "cliente@gmail.com",
"items_count": 1,
"cellphone": "912341234",
"is_payable": False,
"packing": ShippingRequest.PACKING_NONE,
"shipping_type": ShippingRequest.DELIVERY_NORMAL,
"destiny": ShippingRequest.DESTINATION_HOME,
"courier_for_client": ShippingRequest.COURIER_CHILEXPRESS,
"approx_size": ShippingRequest.SIZE_SMALL,
"address_commune_id": 317,
"address_street": "San Carlos",
"address_number": 123,
"address_complement": None
})
shipping_list.append(shipping_1)
shipping_2 = ShippingRequest({
"reference": "S000003",
"full_name": "Jefferson Lizarzabal",
"email": "cliente@gmail.com",
"items_count": 1,
"cellphone": "912341234",
"is_payable": False,
"packing": ShippingRequest.PACKING_NONE,
"shipping_type": ShippingRequest.DELIVERY_NORMAL,
"destiny": ShippingRequest.DESTINATION_HOME,
"courier_for_client": ShippingRequest.COURIER_CHILEXPRESS,
"approx_size": ShippingRequest.SIZE_SMALL,
"address_commune_id": 317,
"address_street": "San Carlos",
"address_number": 123,
"address_complement": None
})
shipping_list.append(shipping_2)
shipping = shipit.request_massive_shipping(shipping_list)
You can consult the data of a historical shipping by sending the id delivered by Shipit using the ** shipping ** method:
from shipitchile import Shipit
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
shipping = shipit.shipping(280584)
print(shipping['id'])
print(shipping['reference'])
You can check the history of shipping made per day using the ** all_shipping ** method: By default it will be the current date
from shipitchile import Shipit
shipit = Shipit('EMAIL', 'TOKEN', 'ENV')
date = datetime.date(2018, 1, 26)
history = shipit.all_shipping(date)
for shipping in history:
print(shipping['id'])
You can generate the tracking url easily:
from shipitchile import Shipit
tracking_url = Shipit.tracking_url('chilexpress', 99680722912)
You can get the approximate size in the Shipit format of a package.
from shipitchile import Shipit
size = Shipit.package_size(width = 14, height = 23, length = 45)
Do not hesitate to send me your feedbacks or pull-request to improve this library.
Thanks to kattatzu for create the original version for PHP https://github.com/kattatzu/ShipIt
MIT License
Copyright (c) 2018 Jefferson Lizarzabal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.