Skip to contents

Authentification

Two helper functions for setting and getting your own key in the environment variable of R.

set_primary_comtrade_key()
Set your primary Comtrade API key in the environment variable
get_primary_comtrade_key()
get_primary_comtrade_key

Getting data from comtrade

This is the main function to get data from the comtrade API.

get_comtrade_data()
Get trade data from the Comtrade API

Helper functions for parameters

These functions validate and re-format the input for the API call.

check_params()
check_params
check_clCode()
Check HS classification parameter
check_cmdCode()
Check commodity_code parameter
check_flowCode()
Check flow_direction parameter
check_freq()
Check frequency parameter
check_date()
Check date parameter
check_partnerCode()
Check partner parameter
check_reporterCode()
Check reporter parameter

Helper functions for request

These functions form the httr2 request, execute it and process the result

build_comtrade_request()
Build a valid request object from the checked parameters
perform_comtrade_request()
Performs the request to the Comtrade API
process_comtrade_response()
Processes the response object

Datasets

These datasets are used internally to verify the validity of reporter and partner codes, as well as commodity codes

HS
HS Codes for that data
PARTNER
PARTNER Codes for that data
REPORTER
REPORTER Codes for that data