API only serves 20 pages by default
    This fetches info on all of items and return them as a list

    Assumption: limit of API is not less than 20
491917
def list_of_objects_from_api(url):
    '''
    
    '''
    response = requests.get(url)

    content = json.loads(response.content)
    count = content["meta"]["total_count"]

    if count <= 20:
        return content["items"]
    else:
        items = [] + content["items"]
        num_requests = int(math.ceil(count // 20))

        for i in range(1, num_requests + 1):
            paginated_url = "{}?limit=20&offset={}".format(
                url, str(i * 20))
            paginated_response = requests.get(paginated_url)
            items = items + json.loads(paginated_response.content)["items"]
    return items
64750
def pages(self):
        
        url = self._build_url('pages', base_url=self._api)
        json = self._json(self._get(url), 200)
        return PagesInfo(json) if json else None
65158
def get_page(self, page_number):
        

        if page_number:
            kwargs = dict(self._list_kwargs)
            kwargs['limit'] = self.limit
            kwargs['page'] = page_number

            return self._controller.list(**kwargs)
10211
def fetch(filter_type, request_num, options = {})
      limit_page = options[:limit_page] || MAX_PAGES_DEFAULT
      filter = Filter.new(filter_type, min_time: options[:to])
      page = Page.new(session, filter, options[:from], options[:to])

      # NOTE: filter は report に渡したほうがシンプルじゃない？
      limit_page.times.each_with_object(Report.new(request_num)) do |_, report|
        report.push(page)
        break report if page.last_page? || report.reach_request_num?

        page = page.next
      end
    end
1099185
function pagedGet ({source, method, skip = 0, aggregatedResponse = null, query = null}) {
  const fullQuery = Object.assign({},
    {
      skip: skip,
      limit: pageLimit,
      order: 'sys.createdAt,sys.id'
    },
    query
  )

  return source[method](fullQuery)
    .then((response) => {
      if (!aggregatedResponse) {
        aggregatedResponse = response
      } else {
        aggregatedResponse.items = aggregatedResponse.items.concat(response.items)
      }
      const page = Math.ceil(skip / pageLimit) + 1
      const pages = Math.ceil(response.total / pageLimit)
      logEmitter.emit('info', `Fetched ${aggregatedResponse.items.length} of ${response.total} items (Page ${page}/${pages})`)
      if (skip + pageLimit <= response.total) {
        return pagedGet({source, method, skip: skip + pageLimit, aggregatedResponse, query})
      }
      return aggregatedResponse
    })
}
700688
public List<P> getAllPages(String apfrom, int aplimit) throws Exception {
    String query = "&list=allpages";
    if (apfrom != null && !apfrom.trim().equals("")) {
      query += "&apfrom=" + apfrom;
    }
    query += "&aplimit=" + aplimit;
    Api api = getQueryResult(query);
    List<P> pageRefList = api.getQuery().getAllpages();
    return pageRefList;
  }
760088
def _paginate(url, topkey, *args, **kwargs):
    '''
    
    '''

    ret = salt.utils.http.query(url, **kwargs)
    if 'errors' in ret['dict']:
        return ret['dict']

    lim = int(ret['dict']['page']['limit'])
    total = int(ret['dict']['page']['total'])

    if total == 0:
        return {}

    numpages = (total / lim) + 1

    # If the count returned is less than the page size, just return the dict
    if numpages == 1:
        return ret['dict'][topkey]

    aggregate_ret = ret['dict'][topkey]
    url = args[0]
    for p in range(2, numpages):
        param_url = url + '?offset={0}'.format(lim * (p - 1))
        next_ret = salt.utils.http.query(param_url, kwargs)
        aggregate_ret[topkey].extend(next_ret['dict'][topkey])

    return aggregate_ret
383392
function listAllServers(next) {
        var limit = 1000;
        var offset = 0;
        var allServers = [];
        var firstReq;
        var firstRes;

        var listPageOfServers = function () {
            if (limit !== null) {
                reqOpts.query.limit = limit;
            }
            reqOpts.query.offset = offset;

            self.get(reqOpts, function (err, servers, req, res) {
                if (err) {
                    next(err, null, req, res);
                    return;
                }

                if (!firstReq) {
                    firstReq = req;
                    firstRes = res;
                }

                allServers = allServers.concat(servers);

                if (servers.length < limit) { // Done paging.
                    // For backwards compat, we return the *first* req/res.
                    next(null, allServers, firstReq, firstRes);
                } else {
                    // Need to fetch another page of servers.
                    offset += servers.length;
                    listPageOfServers();
                }
            });
        };

        listPageOfServers();
    }
935940
def items(self, limit=10000):
        
        _limit = 500
        if 'ids' in self.kwargs:
            col = self.kwargs.get('query', {}).get('collection', {}).get('eq', None)
            if col is None:
                raise SatSearchError('Collection required when searching by id')
            return self.items_by_id(self.kwargs['ids'], col)

        items = []
        found = self.found()
        if found > limit:
            logger.warning('There are more items found (%s) than the limit (%s) provided.' % (found, limit))
        maxitems = min(found, limit)
        kwargs = {
            'page': 1,
            'limit': min(_limit, maxitems)
        }
        kwargs.update(self.kwargs)
        while len(items) < maxitems:
            items += [Item(i) for i in self.query(**kwargs)['features']]
            kwargs['page'] += 1

        # retrieve collections
        collections = []
        for c in set([item.properties['collection'] for item in items if 'collection' in item.properties]):
            collections.append(self.collection(c))
            #del collections[c]['links']

        # merge collections into items
        #_items = []
        #for item in items:
        #    import pdb; pdb.set_trace()
        #    if 'collection' in item['properties']:
        #        item = dict_merge(item, collections[item['properties']['collection']])
        #    _items.append(Item(item))

        return Items(items, collections=collections, search=self.kwargs)
445796
function (context, callback) {
            var self = this,
                options,
                offset = 0,
                limit = 0,
                items,
                parameters = context.request.urlInfo.parameter;

            flow()
                .seq("collection", function (cb) {
                    self._findCollection(context, cb, false);
                })
                .seq("query", function (cb) {
                    var query = self.$restHandler.parseQueryForResource(parameters, self);
                    if (!query.query.sort) {
                        // use default sorting
                        var configuration = context.dataSource.getConfigurationForModelClass(this.vars.collection.$modelFactory);
                        if (configuration && configuration.$.defaultSorting) {
                            query.sort(configuration.$.defaultSorting);
                        }
                    }
                    self._modifyCollectionQuery(query, cb);
                })
                .seq("page", function (cb) {

                    this.vars.collection = this.vars.collection.query(this.vars.query);
                    var pageSize = context.dataSource.$.collectionPageSize;

                    if (parameters["limit"]) {
                        limit = parseInt(parameters["limit"]);
                    }

                    if (!limit || isNaN(limit)) {
                        limit = 100;
                    }

                    if (parameters["offset"]) {
                        offset = parseInt(parameters["offset"]);
                    }

                    // calculate page
                    limit = limit > pageSize ? pageSize : limit;

                    this.vars.collection.fetch({limit: limit, offset: offset}, cb);
                })
                .exec(function (err, results) {
                    if (!err) {
                        var response = context.response;

                        // switch context of collection to RestDataSource
                        var collection = results["collection"];
                        items = results["page"].$items;
                        // call compose
                        var processor = self.$restHandler.$restDataSource.getProcessorForCollection(collection);

                        items.forEach(function (item) {
                            var id = item.identifier();
                            if (id) {
                                self._fetchAllHrefsForModel(item, context);
                            }
                        });

                        var itemArray = processor.composeCollection(results["page"], "GET", null);

                        var res = {
                            count: results["collection"].$.$itemsCount,
                            limit: limit,
                            offset: offset,
                            results: itemArray
                        };

                        response.writeHead(200, "", {
                            'Content-Type': 'application/json; charset=utf-8'
                        });

                        response.write(JSON.stringify(res), 'utf8');
                        response.end();

                        callback(null);
                    } else {
                        if (!(err instanceof HttpError)) {
                            var statusCode = 404;
                            if (err === DataSource.ERROR.NOT_FOUND) {
                                statusCode = 404;
                            }
                            err = new HttpError(err, statusCode);
                        }
                        callback(err);
                    }


                });
        }
980017
def play_list_detail(id, limit=20):
    
    if id is None:
        raise ParamsError()
    r = NCloudBot()
    r.method = 'PLAY_LIST_DETAIL'
    r.data = {'id': id, 'limit': limit, "csrf_token": ""}
    r.send()

    return r.response
980848
def all(self):
        
        return self.pages(self.url.page, self.url.max_page)
1074267
def next_page(params = {}, opts = {})
      return self.class.empty_list(opts) unless has_more
      last_id = data.last.id

      params = filters.merge(starting_after: last_id).merge(params)

      list(params, opts)
    end
84762
def list_products(page_size=200, page_index=0, sort="", q=""):
    
    content = list_products_raw(page_size, page_index, sort, q)
    if content:
        return utils.format_json_list(content)
118911
def get_content_items(access_token, limit, page):
	'''
	
	'''

	headers = {'Authorization': 'Bearer ' + str(access_token)}
	content_items_url =\
		construct_content_items_url(enrichment_url, limit, page)

	request = requests.get(content_items_url, headers=headers)
	if request.status_code == 200:

		content_item = request.json()
		return content_item

	return {'status': request.status_code, "message": request.text}
1261929
def all(page = 1, limit = 100, latest = true)
      opts = connection.version == 2 ? {:unseen => latest} : {:latest => latest}
      connection.get(resource_uri, {:query => {:limit => limit, :page => page}.merge(opts)})
    end
1048533
def get_sources_by_member(base_url=BASE_URL_API, limit=LIMIT_DEFAULT):
    
    url = '{}sources-by-member/'.format(base_url)
    page = '{}?{}'.format(url, urlencode({'limit': limit}))
    results = []
    while True:
        data = get_page(page)
        results = results + data['results']
        if data['next']:
            page = data['next']
        else:
            break
    return results