API Pagnation - How to Tell The Total Items in a Category?

Ken N.

I want to look at all Items within a Category ID.  On the web, it shows there are 309 items in that particular category.  How do I get the same number within the API call?

For example, I would loop through the API calls 4 times with the offset and limit set to 100.  I need to know how many items are in that category to properly set the loop limit.

Comments

3 comments

  • Comment author
    Chris Muench
    • Official comment

    This appears to be a bug. We will fix as soon as possible

  • Comment author
    Chris Muench

    There is a header x-total-records you can use

    0
  • Comment author
    Ken N.
    • Edited

    This works for the Categories API but not for the Invoices API.  Under the Invoice/Customer module within the POS, the total number of invoices I'm seeing is 700; however, the x-total records response only show 9.

    I also tested using https://phppointofsale.com/api.php#/invoices/searchCustomerInvoices but there's nothing shown for x-total-records

    curl -s --verbose GET "https://mywebsite.phppointofsale.com/index.php/api/v1/invoices/customer" -H "accept: application/json" -H "x-api-key: ****************************************************"

    * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
    * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
    * old SSL session ID is stale, removing
    < HTTP/2 200 
    < date: Sat, 31 Aug 2024 21:39:57 GMT
    < content-type: application/json; charset=utf-8
    < access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, x-api-key
    < access-control-allow-methods: GET, POST, OPTIONS, PUT, PATCH, DELETE
    < access-control-allow-origin: *
    < cache-control: no-store, no-cache, must-revalidate
    < expires: Thu, 19 Nov 1981 08:52:00 GMT
    < pragma: no-cache
    < set-cookie: phppos=***********************************; path=/; HttpOnly; SameSite=Lax
    < vary: Accept-Encoding
    < x-total-records: 9
    < cf-cache-status: DYNAMIC
    < server: cloudflare
    < cf-ray: 8bc02d1a7f93cf12-SJC

    1

Please sign in to leave a comment.