• 0
Sign in to follow this  
vittorio

how to retrieve more than 200 items per request

Question

Hi I want to get all items in the books and magazines catagories from Argentina's site. I'm able to get a response but i only get (because of pagination) 200 items maximum.

Is it possible to get all the items?(in this case there are 4 millions items, i know it's a lot.)

Here´s my code:

 

<?php

require '../meliapp/Meli/meli.php';

$meli=new Meli(xxxxxxxxxx , xxxxxxxxxxxxxxxx);

 

if (isset($_GET['code']) ):

          $oAuth = $meli->authorize($_GET['code'], 'http://localhost/meliapp/index.php');
          
          if($oAuth['body']!==NULL || !empty($oAuth['body'])){
                $_SESSION['access_token'] = $oAuth['body']->access_token;
                $_SESSION['token_type'] = $oAuth['body']->token_type;
                $_SESSION['expires_in'] = $oAuth['body']->expires_in;
                $_SESSION['scope'] = $oAuth['body']->scope;
                $_SESSION['user_id'] = $oAuth['body']->user_id;
                $_SESSION['refresh_token'] = $oAuth['body']->refresh_token;
          }

endif;  
if(empty($_SESSION['access_token']) || !isset($_GET['code'])):

          echo "LOGIN NOW:<BR>";
          echo '<a href="' . $meli->getAuthUrl('http://localhost/hgin/meliapp/index.php', Meli::$AUTH_URL['MLA']) . '">Login using MercadoLibre oAuth 2.0</a>';

endif;

$params = array('category' => 'MLA3025', 'limit'=> '200'); 

$items = $meli->get('/sites/MLA/search', $params);

 

The variable $items only holds 200 items. But i know from inspecting $items['body']->paging->total that there are 4 million items.

Is there a way to get all 4 million items at once? or at least more than 200 items maximum per request.

 

Thanks in advance!!!

 

 

 

 

 

 

Edited by vittorio

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

i already tried using offset, i have read the documentation. The question is weather its possible to retrieve more than 200 items per request. I guess that's the limit to not overwhlem the server or whatever. I benchmarked it and it takes around 3 seconds to retrieve 200 items, so it would require close to 17 hours to retrieve the 4 millons items  in the books and magazines category. My question was how do i do to request more items faster, but i'm thinkig there isn´t really a way since the amount of data is huge.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this