[This article was first published on rOpenSci - open tools for open science, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.The Brazilian Institute of Geography and Statistics (IBGE)produces Brazil’s official statistics: the demographic census, the IPCAinflation index1, municipal GDP, and dozens of recurring economic, social andagricultural surveys. Their results are published as thousands of aggregatetables in SIDRA, IBGE’s data retrieval system, and exposed through theIBGE Aggregates API.ibger is an R client for that API. It letsyou discover tables, inspect their metadata, and retrieve data as tidytibbles. The package recently passedrOpenSci software peer review,and version 0.2.1 is on CRAN.ibger grew out of everyday work. We are part of the Strategic MonitoringData Science Team of the Pernambuco state government, in northeasternBrazil, which builds R-based tools to monitor state publicpolicies2. Our dashboards and reports draw on IBGE indicators, and theyare updated by scripts that pull the same tables again and again, often forevery municipality and for many years at once. We wanted that access to bescripted, validated and reproducible, rather than a series of manualdownloads from the SIDRA website. Less than a week after the first CRANrelease, Daniel Vartanian opened anissue explaining that hesplit his calls into smaller chunks by hand to get around the API’slimits, and suggested submitting the package to rOpenSci. Both ideasstuck.This tech note is about one problem that every heavy user of the API runsinto sooner or later: the limit on how many values a single request canreturn, and how ibger works around it.The request limitEach SIDRA table crosses variables, periods, geographic units andclassification categories, so results grow multiplicatively. A modestquestion such as “how much soybean did each of Brazil’s 5,570municipalities produce in each year since 2000?” already means more than140,000 values.The API documentation states a limit of 100,000 values per request. Inpractice, requests start to fail well before that: while developing ibger wesaw a request for 44,560 values succeed and one for 50,130 values fail. Andwhen a request is too large, the API does not say so. It answers with ageneric HTTP 500 error.Here is what happens if we send the soybean query in a single request, withautomatic splitting turned off (chunk = FALSE). We use table 1612(municipal crop production), variable 214 (quantity produced), category 2713of classification 81 (soybeans) and the municipal level "N6":library(ibger)soy