9
I will give an example to explain my doubt:
I need to recover information from images coming from an API, this image bank returns JSON’s with information of the images I need, in all there are 33 million images and I will order 100 in 100 thousand.
The structure of a JSON if I requested 2 images would be:
{
"meta":{
"limit":2,
"offset":0,
"total_count":33640457
},
"objects":[
{
"artist":"sunyyasyed",
"grid_thumb_url":"http://grid.unlistedimages.com/64830460.jpg",
"id":64830460,
"image_name":"k13762459",
"preview_url":"http://comps.unlistedimages.com/ulcomp/CSP/CSP992/k13762459.jpg",
"ratio":0.8895689,
"resource_uri":"/api/v1.0/image/64830460/",
"subscription_allowed":true,
"thumbnail_url":"http://photos.unlistedimages.com/thumbs/CSP/CSP992/k13762459.jpg",
"title":"100 Business, Web, and Office Icons",
"type":"PHOTO"
},
{
"artist":"kevron2001",
"grid_thumb_url":"http://grid.unlistedimages.com/62322357.jpg",
"id":62322357,
"image_name":"k10882629",
"preview_url":"http://comps.unlistedimages.com/ulcomp/CSP/CSP990/k10882629.jpg",
"ratio":1.25,
"resource_uri":"/api/v1.0/image/62322357/",
"subscription_allowed":true,
"thumbnail_url":"http://photos.unlistedimages.com/thumbs/CSP/CSP990/k10882629.jpg",
"title":"Sunset with open Bible",
"type":"PHOTO"
}
]
}
Each image block has 13 lines, meaning at the end JSON will have ~1,300,000 lines, is there a limit to generating a JSON file? it may be that this file (with 43MB of text) may cause problems if I need to read it
To say one thing, "paging" is something that goes beyond web pages, even if the term implies this, if you developed the API soon you can think of a kind of control of
LIMIT
viaGET
. After all it’s not just because life’s webapis use cute urls that invalidates the use of querystring, something like this:/api/foo/bar
and/api/foo/bar?pag=2
seems to me a great output, and the rest you solve in the application by creating a "on-demand" control. Note that the LIMIT is on the server side of the API.– Guilherme Nascimento
@Guilhermenascimento There is the limit parameter, so much so that the JSON itself contains the values, is that in this case as there are 33million images, it would take a long time to return small batches so I decided 100mil per batch. Ended up lasting 8 hours, were 337 lots with 100mil images each, a total of 14GB of plain text :D.
– Leonardo Bonetti
That’s why I mentioned one about creating a control on demand, the control would have a timeout that would add up to the current page, thus avoiding server wear and tear of your own network, of course this at the production level. But it’s just a suggestion.
– Guilherme Nascimento
Ahhhh, I understood the purpose of the comment :D,this API who did it was not me, is an image distributor so I do not have this control, but really they have no control , I was 8 hours direct ordering A lot information, and I wasn’t even notified
– Leonardo Bonetti