github: Make calls to the github API

githubR Documentation

Make calls to the github API

Description

Provides a structured list of the specified resource from the the github API.

Usage

gh(path, proxy_url = NULL, token = NULL)

github_api(path, proxy_url = NULL, token = NULL)

rate_limit(proxy_url = NULL, token = NULL)

Arguments

path

Character string with path to the API resource.

proxy_url

Character string defining a network proxy in the form host:port. Default is NULL in which case the API call will not use a proxy.

token

Character string holding a github personal access token (PAT) to be used for requests that requires authorization. Default value is NULL in which case the request will be unauthorized unless PAT can be obtained from the environmental variable GITHUB_PAT.

Details

For most use cases only gh() will be relevant. The helper function github_api() do the actual lifting while rate_limit() handles API rate limits.

Value

A list of class github_api containing the parsed content, API resource path and the response object. For rate_limit() the path is always "/rate_limit" and can hence be used to detect if the limit is exceeded (without being counted as a request itself). If the allowed API rate is exceeded gh() will return a message stating the fact and simple suggestions on how to remedy the problem.

Examples

## Get all branches of a repository. If the api rate limit is exceeded this
## function will return NULL and an informative message
gh("repos/Rapporteket/sship/branches")

## helper functions that will normally not be used
github_api("/rate_limit")
rate_limit()

sship documentation built on Dec. 28, 2022, 2:01 a.m.