Skip to content

Instantly share code, notes, and snippets.

@sharoonthomas
Created September 2, 2016 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharoonthomas/d8bba71ea73c37f37dad3a06d45518a6 to your computer and use it in GitHub Desktop.
Save sharoonthomas/d8bba71ea73c37f37dad3a06d45518a6 to your computer and use it in GitHub Desktop.
Get shipments from fulfil using API
import os
from datetime import date
from pprint import pprint
from fulfil_client import Client
client = Client('<subdomain>', os.environ['FULFIL_API_KEY'])
Shipment = client.model('stock.shipment.out')
def get_shipments(start_date, end_date):
"Return shipments between start and end date"
shipments = Shipment.search_read(
[
('effective_date', '>=', start_date),
('effective_date', '<=', end_date),
('state', '=', 'done'),
],
None, # pagination/offset
None, # pagination/limit
None, # ordering
[
'code',
'effective_date',
'customer.rec_name',
'delivery_address.country.name',
#'delivery_address.full_address',
'tracking_number.rec_name',
'order_numbers',
]
)
return shipments
if __name__ == '__main__':
shipments = get_shipments(
date(2016, 8, 1),
date(2016, 8, 30),
)
pprint(shipments)
@sharoonthomas
Copy link
Author

  1. Before you run the script, install the python API client::

pip install fulfil_client

  1. Then, replace the subdomain with your fulfil.io subdomain. For example, if you access your account at best_buy.fulfil.io, then the subdomain is best_buy.
  2. Export the API key to env.

export FULFIL_API_KEY=REPLACETHISWITHYOURAPIKEY

  1. Run the script

python get_shipments.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment