bigcommerce / bigcommerce-api-python Goto Github PK
View Code? Open in Web Editor NEWPython client library for Bigcommerce API
Home Page: https://pypi.python.org/pypi/bigcommerce
License: MIT License
Python client library for Bigcommerce API
Home Page: https://pypi.python.org/pypi/bigcommerce
License: MIT License
Currently, I'm using the following to update information about a single product.
api.Products.get(1234).update(inventory_level=20)
Is there a way to update multiple products? I've tried something like this, but got a 404 error.
api.Products.get([123, 456]).update(inventory_level=20)
ERROR:
404 Not Found @ products/[123,456]: b'[{"status":404,"message":"The requested resource was not found."}]'
BigCommerce allow 10 product updates at a time, so I'm trying to see if that is possible.
https://developer.bigcommerce.com/api-reference/catalog/catalog-api/products/updateproducts
I am new to bigCommerce so bare with me please. Any help is appreciated.
I am working with ex_login_token.py
... I expect the JWT token to be able to log me in. ((SSO))
when i go to use the token https://myURL.com/login/token/<jwt-login-token>
i get redirected instead to the login page of my bc store with the error Invalid login..
I have a working flask app installed in my bigcommerce store. I might need to merge that app and the python script somehow so that the APP_CLIENT_SECRET
is works. but i have little knowledge in a lot of places. I need help filling a few gaps
api.BlogTags.all() should retrieve all the Blog Tags
It should work similar to api.BlogPosts.all() where it retrieves all Blog Posts
The API documentation can be found here:
https://developer.bigcommerce.com/api-reference/marketing/store-content-api/blog-posts/getallblogtags
Trying to execute api.BlogTags.all() results in error:
AttributeError: module 'bigcommerce.api' has no attribute 'BlogTags'
I need to create a customer and force them to reset their passwords on login. I tried the following...
api.Customers.create(first_name=first, last_name=last, email=email, force_reset=True)
-or-
api.Customers.create(first_name=first, last_name=last, email=email, _authentication:{force_reset=True})
ClientRequestException: 400 Bad Request @ customers: [{"status":400,"message":"The field 'force_reset' is not supported by this resource."}]
How can i use the api to set reset_pass_on_login
to true?
when i do something lile this
BCPYTHONCLIENT.Orders.get(10).update(custom_status='Completed')
update succefully
resturns an errror
bigcommerce.exception.ClientRequestException: 400 Bad Request @ orders/10: b'[{"status":400,"message":"The field 'custom_status' is not supported by this resource."}]'
I'm trying to use the v3 Products API's, but I need to filter by "id:not_in". As far as I know, Python does not allow colons in variable names. So what is the work-around to this?
I expect that all the filters using a colon will not work.
# v3 products
include_fields = "sku, price"
sort = "sku"
id:not_in = "689"
endpoint = '/catalog/products'
response = api.get(endpoint, include_fields=include_fields, id:not_in=id:not_in, limit=5, page=1, sort=sort)
The expected result would be a list of products where the IDs are not in the list of IDs.
id:not_in = "689"
NameError: name 'not_in' is not defined
Use above filter to reproduce.
This code:
#!/usr/bin/env python2
import bigcommerce
import bigcommerce.api
BIG_URL = 'store-45eg5.mybigcommerce.com'
BIG_USER = 'henry'
BIG_KEY = '10f0f4f371f7953c4d7d7809b62463281f15c829'
api = bigcommerce.api.BigcommerceApi(host=BIG_URL, basic_auth=(BIG_USER, BIG_KEY))
def get_category_id(name):
get_request = api.Categories.get(name)
try:
cat_list = api.Categories.all(name=name)
if cat_list:
return cat_list[0]['id']
else:
return None
except:
return None
def create_category(name):
rp = api.Categories.create(name)
if rp.status == 201:
return rp.json()['id']
else:
return get_category_id(name)
create_category('anothertestingcat')
Gives this traceback:
Traceback (most recent call last):
File "./bigcommerceimporter.py", line 50, in
create_category('anothertestingcat')
File "./bigcommerceimporter.py", line 44, in create_category
rp = api.Categories.create(name)
File "/home/henry/big_test_zone/local/lib/python2.7/site-packages/bigcommerce/api.py", line 57, in
return lambda _args, *_kwargs: (getattr(self.resource_class, item))(_args, connection=self.connection, *_kwargs)
TypeError: create() got multiple values for keyword argument 'connection'
I believe this is a bug/glitch in or around line 57 in api.py. It looks like lambda from getattr is getting called with "connection" as a keyword argument when it shouldn't be.
The pip install fails to install streql on python 2.7 on Windows7. It complains that it cannot find vcvarsall.bat. I looked through the API and noticed that streql is only imported, but not used in the code. I was able to use the api on Windows7 by removing that line in connection.py. I don't want to have to install microsoft Visual Anything unless I have to.
Hi Team, hopefully this is right place to ask, if not, I'd appreciate if you can direct me.
I'm the founder of cloudquery.io, a high performance open source ELT framework.
Our users are interested in an BigCommerce plugin, but as we cannot maintain all the plugins ourselves, I was curious if this would be an interesting collaboration, where we would help implement an initial source plugin, and you will help maintain it.
This will give your users the ability to sync BigCommerce data to any of their datalakes/data-warehouses/databases easily using any of the growing list of CQ destination plugins.
Best,
Yevgeny
As pointed out in #21 NotLoggedInException
is unused in the client library. In v0.11 this should be removed entirely.
I recently ran across a problem where a customer has 100 skus for a product. The API only allows me to get the first 50.
opts.update({"limit": 50, "page": 1})
for product in self.con.Products.all(**opts):
for sku in product.skus():
print sku
It would be nice if we could pass parameters to the sub resource's all/get method and have it cascade to the connection instance to perform the gets
stop = False
skuopts = {"limit": 50, "page": 1}
while not stop:
for sku in product.skus(**skuopts):
print sku
My other option would be to iterate using the SubResource explicitly and passing in the product id and the product's connection, but the connection property is privatized.
opts.update({"limit": 50, "page": 1})
for product in self.con.Products.all(**opts):
stop = False
skuopts = {"limit": 50, "page": 1}
while not stop:
for sku in self.con.ProductSkus.all(product.id, product._connection, **skuopts):
print sku
This would require exposing the connection object from within the parent resource.
in requests library, total_pages returned in json.
products = api.Products.all()
does not return all items, it returns only the first page of items.
products = api.Products.all(page=2)
produces second page but does not return total pages.
products = api.Products.all(limit=250)
produces 250 items, no total_pages
count = api.Products.count()
products = api.Products.all(limit=count)
fails with exception: bigcommerce.exception.ClientRequestException: 413 Request Entity Too Large @ products: [{"status":413,"message":"The specified limit exceeds the maximum allowed.","details":{"max_limit":250}}]
This makes it impossible to iterate pagination within the bigcommerce-api-python library.
api = bigcommerce.api.BigcommerceApi(client_id=clientID, store_hash=store_hash, access_token=accessToken)
count = api.Products.count()
products = api.Products.all(limit=count)
Would be nice to have a method that generates the authorize URL
Also, the developer site doesn't document what the authorize URL is. I had to guess what it is:
https://login.bigcommerce.com/oauth2/authorize
api = bigcommerce.api.BigcommerceApi(
client_id=config['bigcommerce'].get('client_id'),
store_hash=context, access_token='')
token = api.oauth_fetch_token(
config['bigcommerce'].get('client_secret'), code, context, scope,
config['bigcommerce'].get('redirect_uri'))
print(token)
{'access_token': '', 'scope': '', 'user':, 'context': ''}
Python 3.6.3
bigcommerce==0.18.0
api = bigcommerce.api.BigcommerceApi(
client_id=config['bigcommerce'].get('client_id'),
store_hash=context, access_token='')
token = api.oauth_fetch_token(
config['bigcommerce'].get('client_secret'), code, context, scope,
config['bigcommerce'].get('redirect_uri'))
bigcommerce.exception.ClientRequestException: 406 Not Acceptable @ https://login.bigcommerce.com/oauth2/token: b'{"error":"Invalid format."}'
Upgrade bigcommerce to 0.18.0 (from the bigcommerce==0.17.3)
pip install bigcommerce==0.18.0
running in powershell terminal
should be documented at https://developer.bigcommerce.com/ as per https://github.com/bigcommerce/bigcommerce-api-python#further-documentation
no documentation
go to https://developer.bigcommerce.com/ there is no documentation for this library.
When printing each of the costumers, an address section should appear, just like when making a GET request to the clients (https://api.bigcommerce.com/stores/{{store-hash}}/v3/customers?include=addresses)
The address attribute does not appear
customers=api.Customers.all()
print(customers)
I'm trying to unset the price value on all the variations of a product.
product = api.Products.get(productId)
variations = product.skus()
for variation in variations:
print("-- Setting Variations Back To Regular Price")
variation_object = product.skus(variation.id)
variation_object.update(price="")
Above snippet sets all the product variations price to 0.00
instead of null
. I'm not sure if this is an API issue, or a Python issue. Any suggestions or feedback would be much appreciated.
Hi, I'm having 429 error getting information from the api
I'm creating the client object with:
BigcommerceApi(
client_id=settings.BIGCOMMERCE_APP_CLIENT_ID,
store_hash=self.store_hash,
access_token=self.access_token,
rate_limiting_management={
'min_requests_remaining': 3,
'wait': True,
'callback_function': None
})
And it still gets error
Not exception
Exception raised
I were trying to get products data from an customer that have a lot of skus and products
for product in self.client.Products.iterall():
# some processing ...
skus = product.skus() # <- here it raises
# more code ...
How get items of shipment using this lib?
Doc of shipment has point "items" https://developer.bigcommerce.com/api/objects/v2/shipment
order = client.Orders.get(1)
shipment = order.shipments()[0]
# or
shipments = client.OrderShipments.all(1)[0] # id of order
# it returns <function items>
items = shipments.items
# it returns a list of fields without items
items = shipments.items()
# it returns KeyError: 'items'
shipment['items']
How can I get it using this lib?
Hi, when can we expect API v3 endpoints to be supported?
Every time I send a GET request to pull data from Big Commerce, I get a Memory Address with a python dictionary inside it.
How can I get just the python dictionary inside it instead?
Zip should be returned as a payment method in the PaymentMethods API resource when it is enabled.
Zip is not returned as a payment method.
We see 500 errros for some of our requests. Below is the stack trace we see in python (you can see that accessing Store.all() triggers the error). Any help would be much appreciated.
Task bigcommerce_app.helpers.
import_orders.import_orders with id 251b17ba-0bea-4f7e-964a-2d262115905c raised exception:
"ServerException('500 Internal Server Error @ store: An error has occurred.',)"
Task was called with args: (<APIUser: API User [email protected]>,) kwargs: {}.
The contents of the full traceback was:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python2.7/site-packages/celery/app/trace.py", line 238, in trace_task
R = retval = fun(*args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/celery/app/trace.py", line 416, in __protected_call__
return self.run(*args, **kwargs)
File "./bigcommerce_app/helpers/import_orders.py", line 18, in import_orders
return get_unimported_orders(client, apiuser)
File "./bigcommerce_app/helpers/import_orders.py", line 44, in get_unimported_orders
storeinfo = get_storeinfo(client)
File "./bigcommerce_app/helpers/import_orders.py", line 22, in get_storeinfo
store = client.Store.all()
File "/app/.heroku/python/lib/python2.7/site-packages/bigcommerce/api.py", line 55, in <lambda>
return lambda *args, **kwargs: (getattr(self.resource_class, item))(*args, connection=self.connection, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/bigcommerce/resources/base.py", line 82, in all
request = cls._make_request('GET', cls.resource_name, connection, params=params)
File "/app/.heroku/python/lib/python2.7/site-packages/bigcommerce/resources/base.py", line 42, in _make_request
return connection.make_request(method, url, data, params, headers)
File "/app/.heroku/python/lib/python2.7/site-packages/bigcommerce/connection.py", line 120, in make_request
return self._handle_response(url, response)
File "/app/.heroku/python/lib/python2.7/site-packages/bigcommerce/connection.py", line 154, in _handle_response
raise ServerException("%d %s @ %s: %s" % (res.status_code, res.reason, url, res.content), res)
ServerException: 500 Internal Server Error @ store: An error has occurred.
Not super pressing but a tag for version0.13.0
was created on github but wasn't published to the cheese shop.0.12.0
the following code should enable google shopping
google = api.GoogleProductSearchMappings.all(idNo).update(enabled=True)
print google
google = api.GoogleProductSearchMappings.all(idNo).update(enabled=True)
print google
NONE
No change in item google shopping settings
google = api.GoogleProductSearchMappings.all(idNo).update(enabled=True)
print google
deletecustomfield = api.ProductCustomFields.get(productidnumber,fieldidnumber).delete
should delete the custom field
still exists after
try to delete custom field
Should I somehow clear any session on the api after using it for future use.
In bigcommerce/hello-world-app-python-flask at line #93 it mentions a side-effect behavior, or maybe I got it wrong.
Currently some of my app unit-tests pass or fail on a simple api connection test and the error is Authorization
issue. I'm wondering if I need to take care of clearing the "session" object or some sort after using the api for couple of store.
By the way, shopify python api wrapper requires clearing the session header after api usage to be able to use it for another api connection:
shopify.ShopifyResource.clear_session()
I have this code for rate limiting:
def ratelimit():
print("Ratelimit Called")
api = bigcommerce.api.BigcommerceApi(client_id='xxxx', store_hash='xxxx,
access_token='xxxx',
rate_limiting_management={'min_requests_remaining': 3,
'wait': True,
'callback_function': ratelimit()})
for product in api.Products.iterall():
...
The rate limit function is only being fired once at the start of the program, and I'm getting this error:
bigcommerce.exception.RateLimitingException: 429 Too Many Requests @ products: b''
list(client.OrderStatuses.iterall())
should yield a list identical (in this case, since there's only one page) to client.OrderStatuses.all()
iterall()
appears to infinite loop, presumably because it doesn't accept a page parameter, ignores that field and therefore will always return rows.
It seems like the simplest fix here would be to define an override, either through mixin or directly on any listable model which doesn't support paging.
I am trying to update the customer password in one of my applications. Sample code:
import bigcommerce
big_commerce_url_info = xxx
big_commerce_store_hash = xxx
big_commerce_client_id = xxx
big_commerce_auth_token = xxx
customer_id = xxx
password = xxx
try:
api = bigcommerce.api.BigcommerceApi(client_id=big_commerce_client_id, store_hash=big_commerce_store_hash, access_token=big_commerce_auth_token)
api.Customers.get(customer_id).update(_authentication=dict(password=password))
except Exception as e:
print("ERROR: ", str(e))
It should update the password every single time.
It updates the password most of the times for most customers but some times it randomly gives the following error:
ERROR: 400 Bad Request @ customers/1705: b'[{"status":400,"message":"The field \'password\' is invalid."}]'
Just run the code multiple times and it will randomly fail at some point.
From the documentation in the following URL, you would think you can create, delete, and delete_all videos for a product:
https://developer.bigcommerce.com/legacy/v2-catalog-products/v2-product-videos
newer documentation:
https://developer.bigcommerce.com/api-reference/catalog/catalog-api/product-videos/
I expected that you would be able to something like this and it create a video:
video = api.ProductVideos.create(parentid=product_id, url=video_url)
If I try to create a video I get the following error:
AttributeError: type object 'ProductVideos' has no attribute 'create'
product_id = "id of product"
video_url = "some youtube video url"
video = api.ProductVideos.create(parentid=product_id, url=video_url)
api = bigcommerce.api.BigcommerceApi(
client_id=clientID,
store_hash=store_hash,
access_token=accessToken)
count = api.Products.count()
print(count)
prints count
api = bigcommerce.api.BigcommerceApi(
client_id=clientID,
store_hash=store_hash,
access_token=accessToken)
count = api.Products.count()
AttributeError: type object 'Products' has no attribute 'count'
python 3 pip install bigcommerce-api
running in powershell terminal
I built in sleep "delay" and "max_retries" into my original version of the API to address the 509 errors. I do not want to have to wrap every operation throughout my application to address the retries. I'd prefer it be built into the API so that it is transparent. It could also be configurable when instantiating the API class.
The 429's are nice in that it gives you a "retry-after" in the header.
What are your thoughts on this? Is there a good reason that this should not be part of the API?
Thank you.
Getting price of ProductDiscountRules
It returns without price like this: "{'id':, 'product_id':, 'type': 'percent', 'type_value': 0, 'min': 1, 'max': 3}"
the process i executed is 1) cloned git repository into my PC , 2) created an app in https://developer.bigcommerce.com/ , 3) copied the app key and app secret in config.py, 4) ran the app.py and then while installing my app it asked for confirmation and when i clicked it there is no response except just showing installing...
The README.md suggests that api.Products.iterall()
and api.Products.count()
should exist but they do not appear to.
Also, the releases page says that the last release was 2019. They're haven't been any substantial updates since then?
Also, the forum entry at #59 says the following:
Hi @sabotagebeats, the pagination values you're referring to come from the V3 BC API, whereas this library is for the older V2 API and has not yet been updated for V3.
Has V3 been since released?
Lastly, when I call (api).Products.all()
for some page equal-to-or-greater-than the page-count (the page after the last page of results), I get a single string with a value of "_connection" back. So, when there are products, we get a Product. Otherwise, we get a string with "_connection". I would expect an empty result or, at worst, a None. Can you explain what's going on here? How is pagination supposed to work? I'm having issues finding documentation and what little documentation is available (above) seems broken or inaccurate. Since the source-code is reflective, there are no clues there, either.
products = api.Products.all(name='toy')
Should yield all products with the keyword 'toys' in the title as per "Filters can be applied to all methods as keyword arguments"
https://pypi.org/project/bigcommerce/
I only get results when the keyword filter is an exact match, rather than a partial match.
products = api.Products.all(name='toy')
Could this be used as a connector for bigcommerce and Odoo?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.