gh_page: Get multiple pages from the GitHub API

Description Usage Arguments Value Examples

View source: R/github-api.R

Description

This function is used when requesting a collection of entities. GitHub sets a maximum page size of 100, so if more are request multiple requests are made and the results are combined. Each page uses gh_request() to retrieve the contents.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gh_page(
  url,
  n_max = 1000,
  page_size = 100,
  headers = NULL,
  accept = "application/vnd.github.v3+json",
  token = getOption("github.token"),
  proxy = getOption("github.proxy"),
  ...
)

Arguments

url

(string) The address of the API endpoint.

n_max

(integer, optional) Maximum number to return. Default: 1000.

page_size

(integer, optional) The size of each page. Default: 100.

headers

(character, optional) Headers to add to the request. Default: NULL.

accept

(string, optional) The mime format to accept when making the call. Default: "application/vnd.github.v3+json".

token

(string or Token, optional) An authorisation token to include with the request. If NULL the OAuth process is triggered. Default: NULL.

proxy

(character, optional) The proxy server to use to connect to the github API. If NULL then no proxy is used. Can be set in the option github.proxy or the environment variable GITHUB_PROXY. Default: NULL.

...

Parameters passed to gh_request().

Value

A github list object consisting of the response, parsed into a list, with the attributes:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 

  # First 20 users
  gh_page(
    url   = "https://api.github.com/users",
    n_max = 20
  )

  # First 150 users (two pages)
  gh_page(
    url   = "https://api.github.com/users",
    n_max = 150
  )


## End(Not run)

ChadGoymer/githapi documentation built on Oct. 22, 2021, 10:56 a.m.