ct_set_key: Set the Comtrade API Key

View source: R/key.R

ct_set_keyR Documentation

Set the Comtrade API Key

Description

Store your UN Comtrade API key for the current session. The key is saved as an R option and optionally as an environment variable for persistence.

Usage

ct_set_key(key, install = FALSE)

Arguments

key

Character. Your Comtrade API subscription key.

install

Logical. If TRUE, also sets the COMTRADE_API_KEY environment variable via Sys.setenv(), which persists for the current R session. For permanent storage, add COMTRADE_API_KEY=your-key to your .Renviron file. Default FALSE.

Details

Get a free API key at https://comtradedeveloper.un.org/. The free tier allows 500 calls per day and up to 100,000 records per call.

Value

Invisibly returns the key.

Examples


ct_set_key("your-subscription-key-here")


comtrade documentation built on April 13, 2026, 5:07 p.m.