/
Python SDK Sample: Get all items
Python SDK Sample: Get all items
# retrieve all items using chunking if necessary import ultracart from ultracart.rest import ApiException from ultracart import ApiClient from pprint import pprint import time config = ultracart.Configuration() # this key is valid only in the UltraCart development system. You need to supply a valid simple key here. config.api_key['x-ultracart-simple-key'] \ = '4256aaf6dfedfa01582fe9a961ab0100216d737b874a4801582fe9a961ab0100' config.debug = True config.verify_ssl = True # Development only. Set to True for production. api_client = ApiClient(configuration=config, header_name='X-UltraCart-Api-Version', header_value='2017-03-01') api_instance = ultracart.ItemApi(api_client) # The item expansion is huge. Only use what you need. # see https://www.ultracart.com/api/#resource_item.html # see https://www.ultracart.com/api/#Topic3 expand = 'auto_order,auto_order_steps,checkout,kit_definition,options,physical,pricing,' \ 'pricing.tiers,restriction,shipping,shipping.methods,tax,variations' def get_items_chunk(offset=0, limit=200): items_response = api_instance.get_items(offset=offset, limit=limit) if items_response.success: return items_response.items # if unsuccessful, return empty array return [] items = [] try: iteration = 1 offset = 0 limit = 200 need_more_records = True while need_more_records: print("executing iteration " + str(iteration)) block_of_items = get_items_chunk(offset, limit) items.extend(block_of_items) offset = offset + limit need_more_records = len(block_of_items) == limit time.sleep(3) # pace your calls or the rate limiter was slam down on your script. pprint(items) except ApiException as e: print("Exception when calling ItemApi->get_items: %s\n" % e)
, multiple selections available,
Related content
Python SDK Sample: Get an Auto Order
Python SDK Sample: Get an Auto Order
More like this
API
More like this
Python SDK Sample: Fulfillment
Python SDK Sample: Fulfillment
More like this
PHP SDK Sample: Querying items and then looking at auto order settings and schedule
PHP SDK Sample: Querying items and then looking at auto order settings and schedule
More like this
C# SDK Sample: Downloading Orders
C# SDK Sample: Downloading Orders
More like this
PHP SDK Sample: Query all auto orders
PHP SDK Sample: Query all auto orders
More like this