Package: pyecwid
pyecwidPython wrapper for Ecwid REST APIRequirementsAPI token and Store ID fromEcwid CPApps -> My AppsPython 3RequestsInstallation$python-mpipinstallpyecwidChangeLogBREAKING: Major changes (when 0.1.x released)Broke up the different endpoints (Customers, Orders, Products, etc) into different classes that accept the EcwidAPI (or EcwidAPIMock) object.Added Mixins that can be used to quickly implement new Endpoints without duplicating code.Added an Ecwid class that contains properties with each endpoint initialised.Some methods have changed names.TodoReimplement product_variations and other mixins for subobjects of items.Implemented FeaturesStandard possible commands for endpoints:add({item}) - add item (dict)delete(id) - remove itemget_by_id(id) - get item details (returns a single {item})update(id, {values}) - update item with values (dict)Getting multiple items:  Will deal with pagination and return a list of "items" node.Optional: pass "collate_items=False" to any of these commands and full results will be returned.  Note - pagination will not be handled automatically.   Useful to find total counts etc.get() - get all itemsget_by_keyword('keyword') - search for items by keywordget_by_params({params}) - search for items by paramaters (dict)EndpointStatusStandard commandsExtra commandsCouponsalpha - currently unable to testadd, delete, get, get_by_id, get_by_params, updateCustomersalpha - currently unable to testadd, delete, get, get_by_id, get_by_keyword, updateget_by_email, get_by_nameOrdersalpha - currently unable to testadd, delete, get, get_by_id, get_by_params, updateProductsworkingadd, delete, get, get_by_id, get_by_keyword, get_by_params, updateProductTypes (classes)workingadd, delete, get, get_by_id, updateSimple InitialisationfrompyecwidimportEcwidecwid=Ecwid(api_token,store_id)EcwidAPI ArgumentsArgumentRequiredDescriptionDefault Valueapi_tokenYesThe secret_ or public_ token for your store.store_idYesThe ID of your store.skip_testNoTrue/False.  Skips test call to API during initiaization (used in tests)Falsebase_urlNoReplace the hard coded URLNote: format includes {0} for store_id'https://app.ecwid.com/api/v3/{0}/'Sample:  Search products and pprintfrompprintimportpprintfrompyecwidimportEcwidecwid=Ecwid('public_ASDF','1234567')# Search by Keyworditems=ecwid.products.get_by_keyword('sunglasses')pprint(items)# Search by Paramatersparams={'createdFrom':'2016-04-25','createdTo':'2020-12-25'}items=ecwid.products.get_by_params(params)pprint(items)# Get all products and use lambda function to search resultsitems=ecwid.products.get()usb_list=list(filter(lambdaitems:'USB'initems.get('name'),items))pprint(usb_list)Sample:  Add item (remove first if it exists) then modify details.frompyecwidimportEcwidimportjson,timeecwid=Ecwid('public_ASDF','1234567')# Import an item from JSON filewithopen('./samplejson/product.json')asjson_file:new_product=json.load(json_file)# Check if item already exists.  If so remove.product_search=ecwid.products.get_by_keyword(new_product['sku'])iflen(product_search)>0:exisiting_item_id=product_search[0]['id']result=ecwid.products.delete(exisiting_item_id)ifresult==1:print("Existing item removed")time.sleep(2)new_item_id=ecwid.products.add(new_product)updated_data={'name':'My New Product'}result=ecwid.products.update(new_item_id,updated_data)print(result.text)Sample: Just importing required endpointsfrompyecwidimportEcwidAPIfrompyecwid.endpointsimportProductsAPI_TOKEN='secret_ASDF'API_STORE='1234567'ecwid=EcwidAPI(API_TOKEN,API_STORE)products=Products(ecwid)results=products.get()Debugging: Use EcwidAPIMock for console logging calls.frompyecwidimportEcwidMockecwid=EcwidMock(API_TOKEN,API_STORE)result=ecwid.products.get()ORfrompyecwidimportEcwidAPIMockfrompyecwid.endpointsimportProductsecwid=EcwidAPIMock(API_TOKEN,API_STORE)products=Products(ecwid)results=products.get()