All data sources

US Foreign Trade

No authcensus-trade

US imports & exports time series — Census Foreign Trade (no auth). 8 endpoints (hs / porths / statehs / naics × imports / exports). searchExports / searchImports filter HS or NAICS + country + month. searchTradeByPort and searchTradeByState slice by US port / state. getTradeBalance fetches both directions in parallel. getCountryCodes is a built-in CTY_CODE↔ISO map (top 30 partners + USMCA/OECD/NATO/APEC). lookupHsCode is a chapter index (27 fuels, 28/29/39 chem, 72/73 steel, 84/85 machinery, 26 ores). upstream quirk: exports use ALL_VAL_MO + E_COMMODITY; imports use GEN_VAL_MO + I_COMMODITY — search dispatches on direction. upstream quirk: country codes are Census Schedule C/D — NOT ISO. Mexico=2010, Canada=1220, China=5700. Optional CENSUS_API_KEY raises the 500/day per-IP cap.

Provenance

PublisherUS Foreign Trade

Freshness & coverage

FreshnessFreshness not declared
GeographicNot declared
TemporalNot declared
AuthenticationNo credentials required

Methods (8)

  • searchExports

    read

    US exports by HS or NAICS code, country, month. Auto-routes to /exports/hs vs /exports/naics.

    Required paramstime

    Uses ALL_VAL_MO + E_COMMODITY. Default COMM_LVL=HS4. Slice by time to cap.

  • searchImports

    read

    US imports by HS or NAICS code, country, month. Auto-routes to /imports/hs vs /imports/naics.

    Required paramstime

    Uses GEN_VAL_MO + I_COMMODITY (NOT ALL_VAL_MO; that is exports-only).

  • searchTradeByPort

    read

    HS commodity × US port × country (porths endpoints). Filter by port code.

    Required paramsdirectionhsCodetime

    Port codes are Census 4-digit identifiers (e.g. 5301=Houston).

  • searchTradeByState

    read

    HS commodity × US state × country (statehs endpoints). Filter by state postal code.

    Required paramsdirectionhsCodetime

    State filter is uppercase 2-letter (TX, CA, LA).

  • getTradeBalance

    read

    Convenience: fetches both directions, returns {exportsValue, importsValue, balance}.

    Required paramshsCodetime

    Hits 2 upstream endpoints in parallel. Sum is in dollars.

  • getCountryCodes

    read

    Built-in Census Schedule C/D ↔ ISO lookup. Top 30 partners + USMCA/OECD/NATO/APEC.

    Pass searchText to filter ("mex" → Mexico=2010). No upstream call.

  • lookupHsCode

    read

    Built-in HS chapter index for petroleum, petrochem, steel, machinery, ores.

    In-memory; covers chapters 26/27/28/29/39/72/73/84/85.

  • getServiceInfo

    read

    Endpoints, common variables, country-code system, value-field asymmetry, time formats.

    30-day cache. Use to discover the api before composing queries.