Get Valid Variables for a Trade Dataset
census_trade_get_dataset_variablesList valid Census API variable names for any trade dataset and direction, preventing unknown-variable errors when querying exports or imports.
Instructions
List every valid Census API variable (field) name for a specific dataset + trade direction, straight from the Census API's own metadata.
Use this before calling census_trade_query_exports/imports when you're unsure which variable names are valid to put in the "get" or "filters" parameters - the Census API rejects unknown variable names with a 400 error, and valid variables differ by dataset (e.g. "SITC" is only valid on the sitc dataset, not hs).
Args:
direction ('exports' | 'imports'): which trade direction's variable list to fetch
dataset (string): dataset code, e.g. 'hs', 'naics', 'statehs' (see census_trade_list_datasets for the full list)
response_format ('markdown' | 'json'): output format (default 'markdown')
Returns: For each variable - its name, human-readable label, whether it's required, and its type (string/int/datetime).
Examples:
Use when: "What fields can I request from the imports NAICS endpoint?"
Use when: You got a "unknown variable" error from census_trade_query_exports and need to find the correct name
Don't use when: You just want dataset descriptions, not field-level detail - use census_trade_list_datasets instead
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataset | Yes | Which commodity classification / geography dataset to query: 'hs' (Harmonized System, most detailed commodity codes, by country+district), 'naics' (industry classification, by country+district), 'enduse' (broad economic-use categories, by country+district), 'sitc' (Standard International Trade Classification, by country+district), 'usda' (agricultural vs. non-agricultural, by country+district), 'hitech' (Advanced Technology Products, by country+district), 'statehs' (HS codes by U.S. state instead of district, 2/4/6-digit only), 'statenaics' (NAICS by U.S. state instead of district, 2/3/4-digit only), 'porths' (HS codes by U.S. port instead of district, 2/4/6-digit only). Use list_trade_datasets for full descriptions. | |
| direction | Yes | Trade direction: 'exports' or 'imports'. | |
| response_format | No | Output format: 'markdown' for a human-readable table, or 'json' for machine-readable structured data. | markdown |