•  » Requests
  •  » 50.43 GB in Piwigo API JSON yesterday alone

#1 2024-10-22 14:34:35

head_dunce
Member
2019-12-09
29

50.43 GB in Piwigo API JSON yesterday alone

I wrote an OpenCart extension that uses the Piwigo API's for the 10,000+ customer photos I have. It works, but the API calls that I do to keep the pages sorted by rating are clearly not written for what I wanted to do. Yesterday alone the JSON returns from Piwigo were over 50 GB.

Here is the gallery that uses the Piwigo APIs -
https://www.carguygarage.com/index.php? … egory_id=3

The main problem is I have to return the sorting of all the images when any of the individual image pages are loaded so that I can load the 10 previous and 10 next images in the slider. That returns about 18 MB for the first API call. Then I have to do 20 API calls to get the names/ratings of all the images loaded in the slider. And this all needs to happen quickly when a person clicks on an image in the gallery or reaches the end of the slider.

The first API call I use is -
format=json&method=pwg.categories.getImages&cat_id=3&page=0&per_page=20000&order=rating_score DESC

I spent many hours trying to avoid that call by doing other calls based upon what image was selected, but there were always problems that didn't have solutions. For example an image might not having a rating, or an image might have the same rating as another image, so these create multiple API calls to try and resolve which end up being a bigger mess.

Ideally I'd love to see an API call where I can specify the order, specify the starting image, and have it return X amount of image information before it and X after it. Maybe that can be added?

Piwigo is pretty awesome, been using it for years now. Thanks for listening!

Offline

 

#2 2024-10-22 21:38:38

head_dunce
Member
2019-12-09
29

Re: 50.43 GB in Piwigo API JSON yesterday alone

Humm... I think what I'm going to do is try and store the 18MB json in Valkey and set the cache for a 24 hours. That will be a simple solution for now.

Offline

 

#3 2024-10-22 22:01:23

head_dunce
Member
2019-12-09
29

Re: 50.43 GB in Piwigo API JSON yesterday alone

Ok, that works nicely for a quick fix.

Offline

 
  •  » Requests
  •  » 50.43 GB in Piwigo API JSON yesterday alone

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2025 · Contact