Creates a connection object that holds server URL, authentication token,
and configuration. This object is passed as the first argument to all
brapiR2 functions. No global state is used.
Usage
brapi_connection(
url,
token = NULL,
version = "v2",
path = "brapi",
user_agent = NULL,
page_size = 1000L,
timeout = 120
)Arguments
- url
Character. Base URL of the BrAPI server (e.g.
"https://test-server.brapi.org"). Trailing slashes are removed.- token
Character or NULL. An existing Bearer token for authentication. If NULL, you can authenticate later with
brapi_login()orbrapi_login_oauth2().- version
Character. BrAPI version path segment. Default
"v2".- path
Character. URL path segment before the version, for servers that do not serve BrAPI at
/brapi/. Default"brapi". GRIN-Global instances, for example, use"gringlobal/brapi".- user_agent
Character or NULL. Overrides the user agent brapiR2 sends with each request. The default identifies the package, its version, and the httr2 and R versions in use.
- page_size
Integer. Number of records per page for paginated requests. Default 1000.
- timeout
Numeric. Request timeout in seconds. Default 120.
Examples
# Connect to the public BrAPI test server (no auth needed)
con <- brapi_connection("https://test-server.brapi.org")
con
#>
#> ── BrAPI Connection
#> • Server: <https://test-server.brapi.org>
#> • Version: v2
#> • Auth: ✗ no token
#> • Page size: 1000
#> • Timeout: 120s
#> • Cache: disabled
# Connect with an existing token
con <- brapi_connection("https://my-breedbase.org", token = "my_token_here")
# Connect to a server that serves BrAPI under a different path
con <- brapi_connection("https://npgsweb.ars-grin.gov",
path = "gringlobal/brapi")
