Giter Club home page Giter Club logo

Comments (3)

bookernath avatar bookernath commented on July 17, 2024 1

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.

For V2, best practice is to take the count and your desired page size to determine the total number of pages over which you'll need to paginate to get all objects, and then paginate them. As per your error message, the maximum page size is 250.

To use the V3 API with this library, you can create an OAuthAPIConnection object directly and change the pathing to /v3/ like so:

v3client = bigcommerce.connection.OAuthConnection(client_id=client_id,
                                                      store_hash=store_hash,
                                                      access_token=access_token,
                                                      api_path='/stores/{}/v3/{}')

This will allow you to use the low-level CRUD interface to interact with the JSON directly, as a workaround for now. An API call would then look like this:

products_response = v3client.get('/catalog/products?limit=%s&page=%s'
                                   % (page_size, current_page))

And you could access the pagination object in the response like this:

products_response['meta']['pagination']

from bigcommerce-api-python.

sabotagebeats avatar sabotagebeats commented on July 17, 2024

from bigcommerce-api-python.

sabotagebeats avatar sabotagebeats commented on July 17, 2024

Thanks this seems to work:

pCounter = 1 #count the pages - 1st page
totalpages = 1 #currently total pages is 1, changes upon loading api
lookupcategory = 0 #0 for all

api = bigcommerce.api.BigcommerceApi(client_id=clientID, store_hash=store_hash, access_token=accessToken)
count = api.Products.count(category=lookupcategory)
totalpages = count // 250
totalpages = totalpages + 1
print 'There are', count, 'items','in', totalpages, 'total pages'

while pCounter <= totalpages:
    product = api.Products.all(category=lookupcategory, page=pCounter)
    pCounter += 1

from bigcommerce-api-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.