The pipr package allows to easily query the PIP API from R.
Here are a few examples to get you started:
By default, get_stats() returns all available
For the most recent data available.
By default, get_stats will only return data if a survey
is available for the requested country and the
requested year.
get_stats(country = "ALB", povline = 3.2)The fill_gaps argument triggers the interpolation /
extrapolation of poverty estimates when surveys are not available for a
given year.
get_stats() can also be used to compute aggregate
welfare statistics for sub-regions. Only World Bank regions are
currently available, but more sub-regional groupings will become
available in the future.
# World Bank aggregate
get_stats(country = "all", subgroup = "wb_regions")
# List of World Bank regions
get_regions()Finally, a short note on how pipr uses caching. By
default, pipr caches the results of API calls in a local
cache. This is to avoid unnecessary API calls and to speed up subsequent
calls. The cache is stored in a temporary directory and is cleared after
2 hours. Practically, this means that if you call the same function with
the same arguments within 2 hours, the result will be returned from the
cache and not from the API.
Here is what the console will show when caching: 
And here is what it will show if it is retrieving a result from the
cache: 