# NOT RUN {
## Example API call number 1:
# All exports from China to South Korea, United States and Mexico over all
# years.
ex_1 <- ct_search(reporters = "China",
partners = c("Rep. of Korea", "USA", "Mexico"),
trade_direction = "exports")
nrow(ex_1)
## Example API call number 2:
# All shipments related to shrimp between Canada and all other countries,
# between 2011 and 2015.
# Perform "shrimp" query
shrimp_codes <- ct_commodity_lookup("shrimp",
return_code = TRUE,
return_char = TRUE)
# Make API call
ex_2 <- ct_search(reporters = "Canada",
partners = "All",
trade_direction = "all",
start_date = "2011-01-01",
end_date = "2015-01-01",
commod_codes = shrimp_codes)
nrow(ex_2)
# Access metadata
attributes(ex_2)$url
attributes(ex_2)$time_stamp
attributes(ex_2)$req_duration
# }
Run the code above in your browser using DataLab