[Integrations](https://spiral.ai/integrations) › [opencode](https://spiral.ai/integrations/opencode) › [UN Comtrade data availability](https://spiral.ai/integrations/opencode/un-comtrade-data-availability)

# How to Use UN Comtrade data availability in opencode

Find which reporters and periods have published datasets, with record counts, classifications, and release dates. Use it to check coverage before requesting trade figures.

|  |  |
| --- | --- |
| Model | UN Comtrade data availability |
| Available through | Alexandria |
| Category | Finance |
| Price | $0.00873 per call. |
| Returns | json |
| Runs | In the background |
| Setup | About 2 minutes, no API key |

## Prompts to try with UN Comtrade data availability in opencode

- Use UN Comtrade data availability to inspect Germany's annual goods coverage from 2019 through 2024, then add a coverage table to this project's analysis notebook.
- Use UN Comtrade data availability to look this up and give me the result as a table. Save the result in ./assets.
- Pull the latest numbers from UN Comtrade data availability and tell me what changed since last week.
- Check UN Comtrade data availability and summarize what you find in three bullet points.
- Pull the newest data from UN Comtrade data availability and give me the result as a table.

## How to set up UN Comtrade data availability in opencode

Pick the way that suits you. Each takes about two minutes.

### Use Spiral's MCP server

1. **Add the server**: Leave out `--global` to add Spiral to the current project only. No header and no client ID or secret: opencode registers itself with Spiral.

```bash
opencode mcp add spiral --global --url https://api.spiral.ai/mcp
```

2. **Sign in**: Your browser opens. Sign in to Spiral, pick the organization and click Authorize, then return to the terminal. No API key. Inside opencode, `/mcps` starts the same sign-in.

```bash
opencode mcp auth spiral
```

3. **Check it**: Spiral shows as connected.

```bash
opencode mcp list
```

### Use the Spiral skill

1. **Send opencode this message**: Your agent reads Spiral's skill and sets itself up.

```
set up https://spiral.ai/SKILL.md
```

2. **Sign in or paste a key**: Approve Spiral in the browser, or give the agent a key from the console.

### Use the Spiral CLI

1. **Install and sign in**: Installs the Spiral CLI, signs you in and adds its skill to your coding agents.

```bash
npx -y spiral-cli@latest init
```

### Call the Spiral API

1. **Create an API key**: In the console, under API keys.

2. **Run UN Comtrade data availability**: One request; the result comes back by polling or a webhook.

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "alexandria",
    "model": "comtradeplus-un-org/trade-statistics/data_availability",
    "input": {
      "reporter_code": "<reporter_code>"
    }
  }'
```

Then paste one of the prompts above: opencode finds UN Comtrade data availability on Spiral, shows the price and runs it.

Setup guide in the docs: https://spiral.ai/docs/quickstarts/opencode

## UN Comtrade data availability tools and prices

- [UN Comtrade (comtradeplus.un.org) · Data availability](https://spiral.ai/tools/alexandria/comtradeplus-un-org/trade-statistics/data_availability) (Alexandria): $0.00873 per call.

## Settings you can ask for

| Setting | Allowed values | Default | Description |
| --- | --- | --- | --- |
| period |  | — | Period(s) YYYY or YYYYMM, comma-separated; omit for every period. Pattern: ^\d{4}(\d{2})?(,\d{4}(\d{2})?)*$. |
| freq_code | A, M | A | Frequency: A annual (period YYYY), M monthly (period YYYYMM). |
| type_code | C, S | C | Type of trade: C commodities (goods), S services. |
| tariffline |  | — | Query the tariffline dataset catalogue instead of the standard one. |
| classification | HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS | HS | Product classification in the URL path: HS (as reported, any HS edition), H0-H6 (a specific HS edition), S1-S4 (SITC), BE/BE5 (BEC), EB/EB10/EB02/EBS (EBOPS, services). |

## What can you do with UN Comtrade data availability in opencode?

Build an internal trade dashboard that pairs country and product figures with coverage, code descriptions, and publication notes. Coding agents can turn UN Comtrade results into tables and charts while preserving the reporter, period, and classification behind each observation.

### Prepare an internal country trade briefing

Build a Germany briefing with historical trade totals, world trade share, and machinery exports. Check available periods and publication notes, resolve product codes, examine national product detail, and identify recent revisions before presenting the figures.

### Compare potential export markets

Compare coffee imports into Germany, Japan, and the United States using a common reported year. Resolve coffee categories, check coverage and compilation notes, compare partner totals, and inspect national product detail; add each market's overall trade totals and world share for context.

### Maintain a monthly trade monitor

Watch Japan's new and revised releases, then refresh affected periods in an internal monitor. Combine headline totals, world share, and selected product flows with national tariff-line detail, keeping publication notes alongside the updated figures.

### Investigate bilateral reporting differences

Compare US imports from China with China's exports to the United States for the same product and year. Verify classifications and coverage, inspect valuation and partner-attribution notes, and examine national commodity detail before interpreting the difference.

### Build a historical trade study

Study Brazil's trade totals over available decades and add product-level comparisons for periods with suitable coverage. Use reference classifications and publication notes to document changes, then compare world trade share over the overlapping available years.

### Examine national product detail

Investigate the national commodity lines beneath a US static-converter import category. Compare those records with the standardized product total, check the reported classification and compilation notes, and revisit the analysis when a revised dataset appears.

### Update a quarterly economic review

Refresh an internal review of Canada, Mexico, and the United States with MBS trade totals and available world-share observations. Use releases, coverage information, and publication notes to explain which periods changed and which countries still lack comparable observations.

### Refresh a research dataset after revisions

Maintain an internal dataset on Kenya's trade, including headline totals, coffee exports, national commodity detail, and world share. Use new release notices to select affected periods, reference tables to label observations, and publication notes to explain revisions.

## Overview

- [Alexandria](https://spiral.ai/providers/alexandria)
- [All opencode guides](https://spiral.ai/integrations/opencode)

## UN Comtrade data availability in other agents

- [Amp](https://spiral.ai/integrations/amp/un-comtrade-data-availability)
- [ChatGPT](https://spiral.ai/integrations/chatgpt/un-comtrade-data-availability)
- [Claude](https://spiral.ai/integrations/claude-desktop/un-comtrade-data-availability)
- [Claude Code](https://spiral.ai/integrations/claude-code/un-comtrade-data-availability)
- [Cline](https://spiral.ai/integrations/cline/un-comtrade-data-availability)
- [Codex](https://spiral.ai/integrations/codex/un-comtrade-data-availability)
- [Cursor](https://spiral.ai/integrations/cursor/un-comtrade-data-availability)
- [Devin](https://spiral.ai/integrations/devin/un-comtrade-data-availability)
- [dots](https://spiral.ai/integrations/dots/un-comtrade-data-availability)
- [Factory Droid](https://spiral.ai/integrations/factory-droid/un-comtrade-data-availability)
- [Gemini](https://spiral.ai/integrations/gemini/un-comtrade-data-availability)
- [Gemini CLI](https://spiral.ai/integrations/gemini-cli/un-comtrade-data-availability)
- [Google Antigravity](https://spiral.ai/integrations/antigravity/un-comtrade-data-availability)
- [goose](https://spiral.ai/integrations/goose/un-comtrade-data-availability)
- [Grok](https://spiral.ai/integrations/grok/un-comtrade-data-availability)
- [Grok Build](https://spiral.ai/integrations/grok-build/un-comtrade-data-availability)
- [Hermes](https://spiral.ai/integrations/hermes/un-comtrade-data-availability)
- [Instinct](https://spiral.ai/integrations/instinct/un-comtrade-data-availability)
- [Manus](https://spiral.ai/integrations/manus/un-comtrade-data-availability)
- [Muse](https://spiral.ai/integrations/muse/un-comtrade-data-availability)
- [Muse Code](https://spiral.ai/integrations/muse-code/un-comtrade-data-availability)
- [n8n](https://spiral.ai/integrations/n8n/un-comtrade-data-availability)
- [Notion](https://spiral.ai/integrations/notion/un-comtrade-data-availability)
- [OpenClaw](https://spiral.ai/integrations/openclaw/un-comtrade-data-availability)
- [Perplexity](https://spiral.ai/integrations/perplexity/un-comtrade-data-availability)
- [Raycast](https://spiral.ai/integrations/raycast/un-comtrade-data-availability)
- [VS Code](https://spiral.ai/integrations/vscode/un-comtrade-data-availability)
- [Windsurf](https://spiral.ai/integrations/windsurf/un-comtrade-data-availability)
- [Zapier](https://spiral.ai/integrations/zapier/un-comtrade-data-availability)

## More opencode guides

- [U.S. Treasury upcoming auctions](https://spiral.ai/integrations/opencode/u-s-treasury-upcoming-auctions)
- [UN Comtrade dataset metadata](https://spiral.ai/integrations/opencode/un-comtrade-dataset-metadata)
- [U.S. Treasury interest expense](https://spiral.ai/integrations/opencode/u-s-treasury-interest-expense)
- [UN Comtrade historical trade totals](https://spiral.ai/integrations/opencode/un-comtrade-historical-trade-totals)
- [U.S. Treasury historical debt outstanding](https://spiral.ai/integrations/opencode/u-s-treasury-historical-debt-outstanding)
- [UN Comtrade imports and exports](https://spiral.ai/integrations/opencode/un-comtrade-imports-and-exports)

## Questions about UN Comtrade data availability in opencode

**Can opencode use UN Comtrade data availability?**

Yes. Add Spiral to opencode as an MCP server, and opencode can find and run UN Comtrade data availability like any built-in tool.

**How much does UN Comtrade data availability cost in opencode?**

$0.00873 per call. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your opencode plan is separate.

**Do I need an Alexandria account to use UN Comtrade data availability in opencode?**

No. Spiral runs UN Comtrade data availability on its own Alexandria account. You sign in to Spiral once and never paste a key.

**How long does it take to set up UN Comtrade data availability in opencode?**

About two minutes: add the server, then sign in, then check it.

**Does opencode wait while UN Comtrade data availability runs?**

UN Comtrade data availability runs in the background. opencode starts the run, checks on it and gives you the json when it's ready.

**Which countries and historical periods does UN Comtrade cover?**

UN Comtrade contains goods and services statistics from nearly 200 countries and areas, with coverage extending back to 1962. Its standardized trade data leaves gaps where a country has not reported.

**How often does UN Comtrade update country data?**

There is no fixed country release date or refresh schedule. UN Comtrade processes submissions as they arrive, and the recent releases list covers first publications and revisions from the last seven days.

**Can I recover an earlier version of a revised dataset?**

UN Comtrade keeps only the latest version of each dataset and has no permanent archive of earlier versions. A published figure can therefore change after its initial release.

**Does UN Comtrade identify individual buyers or suppliers?**

No. It excludes exporter and importer names and contact details, shipment dates, and origin or destination port details; its statistics describe country trade rather than individual transactions.

**Why can two countries report different values for the same trade?**

UN Comtrade identifies three main causes of merchandise trade asymmetry: different partner attribution, CIF versus FOB valuation, and different trade systems. Publication notes help establish which practices each reporter uses.

