KosmoKrator

data

World Bank Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the World Bank KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.worldbank.*. Use lua_read_doc("integrations.worldbank") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic World Bank workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.worldbank.list_countries({query = "example_query", region = "example_region", income_level = "example_income_level"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("worldbank"))' --json
kosmo integrations:lua --eval 'print(docs.read("worldbank.list_countries"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local worldbank = app.integrations.worldbank
local result = worldbank.list_countries({query = "example_query", region = "example_region", income_level = "example_income_level"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.worldbank, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.worldbank.default.* or app.integrations.worldbank.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need World Bank, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

World Bank Lua API Reference

Namespace: app.integrations.worldbank

This integration uses the public World Bank Indicators API v2. No API key is required. Responses are normalized into compact agent-facing arrays while preserving World Bank IDs and codes.

Discovery Tools

Countries

worldbank_countries({ query?, region?, income_level? })

Lists countries and filters out aggregate rows. Use query for local filtering by country name or ISO code. Use region and income_level with World Bank codes.

local countries = app.integrations.worldbank.worldbank_countries({
  region = "LCN",
  income_level = "UMC"
})

worldbank_country_info({ code })

Gets country or aggregate metadata by code.

local brazil = app.integrations.worldbank.worldbank_country_info({
  code = "BR"
})

Regions, Income Levels, Lending Types

worldbank_regions({ page?, per_page? })

Lists region and aggregate codes.

worldbank_income_levels({})

Lists income-level codes such as HIC, UMC, LMC, and LIC.

worldbank_lending_types({})

Lists lending-type codes such as IBD, IDX, IDB, and LNX.

Sources and Indicators

worldbank_sources({ page?, per_page? })

Lists World Bank data sources. Source 2 is World Development Indicators.

worldbank_source_indicators({ source_id, page?, per_page? })

Lists indicator series available in a source.

local source_indicators = app.integrations.worldbank.worldbank_source_indicators({
  source_id = "2",
  per_page = 25
})

worldbank_indicators({ query? })

Searches World Development Indicators by keyword. With no query, returns a curated list of common indicator codes.

worldbank_indicator_info({ indicator })

Gets detailed metadata for one indicator, including source note, source organization, and topics.

local gdp = app.integrations.worldbank.worldbank_indicator_info({
  indicator = "NY.GDP.MKTP.CD"
})

Topics and Languages

worldbank_topics({ topic_id? })

Lists World Bank topics. When topic_id is supplied, lists indicators in that topic.

worldbank_languages({})

Lists global and local language codes supported by the World Bank API.

Data Tools

Single Indicator Data

worldbank_get_data({ indicator, countries?, date_range?, mrnev?, per_page? })

Fetches observations for one indicator. countries is a semicolon-separated list of country or aggregate codes; defaults to all. date_range accepts World Bank range syntax such as 2000:2023. mrnev returns most recent non-empty values.

local data = app.integrations.worldbank.worldbank_get_data({
  indicator = "SP.POP.TOTL",
  countries = "US;CN;BR",
  date_range = "2020:2023"
})

Multi-Indicator Data

worldbank_multi_indicator_data({ indicators, countries?, source?, date_range?, footnote?, per_page? })

Fetches multiple semicolon-separated indicators from one source. The World Bank V2 API requires a source for multiple indicator calls. The API supports up to 60 indicators in one request; this tool enforces that limit before calling upstream.

local data = app.integrations.worldbank.worldbank_multi_indicator_data({
  countries = "CHN;AGO",
  indicators = "SI.POV.DDAY;SP.POP.TOTL",
  source = "2",
  date_range = "2000:2010"
})

Compare Countries

worldbank_compare_data({ indicator, countries, date_range? })

Compares one indicator across countries. Without date_range, the tool requests the most recent non-empty value per country.

local comparison = app.integrations.worldbank.worldbank_compare_data({
  indicator = "NY.GDP.MKTP.CD",
  countries = "US;CN;DE;JP"
})

Common Indicator Codes

CodeMeaning
NY.GDP.MKTP.CDGDP, current US dollars
NY.GDP.MKTP.KD.ZGGDP growth, annual percent
NY.GDP.PCAP.CDGDP per capita, current US dollars
FP.CPI.TOTL.ZGInflation, consumer prices, annual percent
SL.UEM.TOTL.ZSUnemployment, percent of labor force
SP.POP.TOTLTotal population
SP.DYN.LE00.INLife expectancy at birth
SI.POV.GINIGini index
EN.ATM.CO2E.PCCO2 emissions per capita
Raw agent markdown
# World Bank Lua API Reference

Namespace: `app.integrations.worldbank`

This integration uses the public World Bank Indicators API v2. No API key is required. Responses are normalized into compact agent-facing arrays while preserving World Bank IDs and codes.

## Discovery Tools

### Countries

`worldbank_countries({ query?, region?, income_level? })`

Lists countries and filters out aggregate rows. Use `query` for local filtering by country name or ISO code. Use `region` and `income_level` with World Bank codes.

```lua
local countries = app.integrations.worldbank.worldbank_countries({
  region = "LCN",
  income_level = "UMC"
})
```

`worldbank_country_info({ code })`

Gets country or aggregate metadata by code.

```lua
local brazil = app.integrations.worldbank.worldbank_country_info({
  code = "BR"
})
```

### Regions, Income Levels, Lending Types

`worldbank_regions({ page?, per_page? })`

Lists region and aggregate codes.

`worldbank_income_levels({})`

Lists income-level codes such as `HIC`, `UMC`, `LMC`, and `LIC`.

`worldbank_lending_types({})`

Lists lending-type codes such as `IBD`, `IDX`, `IDB`, and `LNX`.

### Sources and Indicators

`worldbank_sources({ page?, per_page? })`

Lists World Bank data sources. Source `2` is World Development Indicators.

`worldbank_source_indicators({ source_id, page?, per_page? })`

Lists indicator series available in a source.

```lua
local source_indicators = app.integrations.worldbank.worldbank_source_indicators({
  source_id = "2",
  per_page = 25
})
```

`worldbank_indicators({ query? })`

Searches World Development Indicators by keyword. With no query, returns a curated list of common indicator codes.

`worldbank_indicator_info({ indicator })`

Gets detailed metadata for one indicator, including source note, source organization, and topics.

```lua
local gdp = app.integrations.worldbank.worldbank_indicator_info({
  indicator = "NY.GDP.MKTP.CD"
})
```

### Topics and Languages

`worldbank_topics({ topic_id? })`

Lists World Bank topics. When `topic_id` is supplied, lists indicators in that topic.

`worldbank_languages({})`

Lists global and local language codes supported by the World Bank API.

## Data Tools

### Single Indicator Data

`worldbank_get_data({ indicator, countries?, date_range?, mrnev?, per_page? })`

Fetches observations for one indicator. `countries` is a semicolon-separated list of country or aggregate codes; defaults to `all`. `date_range` accepts World Bank range syntax such as `2000:2023`. `mrnev` returns most recent non-empty values.

```lua
local data = app.integrations.worldbank.worldbank_get_data({
  indicator = "SP.POP.TOTL",
  countries = "US;CN;BR",
  date_range = "2020:2023"
})
```

### Multi-Indicator Data

`worldbank_multi_indicator_data({ indicators, countries?, source?, date_range?, footnote?, per_page? })`

Fetches multiple semicolon-separated indicators from one source. The World Bank V2 API requires a `source` for multiple indicator calls. The API supports up to 60 indicators in one request; this tool enforces that limit before calling upstream.

```lua
local data = app.integrations.worldbank.worldbank_multi_indicator_data({
  countries = "CHN;AGO",
  indicators = "SI.POV.DDAY;SP.POP.TOTL",
  source = "2",
  date_range = "2000:2010"
})
```

### Compare Countries

`worldbank_compare_data({ indicator, countries, date_range? })`

Compares one indicator across countries. Without `date_range`, the tool requests the most recent non-empty value per country.

```lua
local comparison = app.integrations.worldbank.worldbank_compare_data({
  indicator = "NY.GDP.MKTP.CD",
  countries = "US;CN;DE;JP"
})
```

## Common Indicator Codes

| Code | Meaning |
|------|---------|
| `NY.GDP.MKTP.CD` | GDP, current US dollars |
| `NY.GDP.MKTP.KD.ZG` | GDP growth, annual percent |
| `NY.GDP.PCAP.CD` | GDP per capita, current US dollars |
| `FP.CPI.TOTL.ZG` | Inflation, consumer prices, annual percent |
| `SL.UEM.TOTL.ZS` | Unemployment, percent of labor force |
| `SP.POP.TOTL` | Total population |
| `SP.DYN.LE00.IN` | Life expectancy at birth |
| `SI.POV.GINI` | Gini index |
| `EN.ATM.CO2E.PC` | CO2 emissions per capita |
Metadata-derived Lua example
local result = app.integrations.worldbank.list_countries({query = "example_query", region = "example_region", income_level = "example_income_level"})
print(result)

Functions

list_countries Read

List or search countries from the World Bank. Optional query filters by name. Filter by region (EAS, ECS, LCN, MEA, NAC, SAS, SSF) or income level (HIC, UMC, LMC, LIC).

Lua path
app.integrations.worldbank.list_countries
Full name
worldbank.worldbank_countries
ParameterTypeRequiredDescription
query string no Search query — country name or ISO code to filter results.
region string no Filter by region code: EAS (East Asia), ECS (Europe & Central Asia), LCN (Latin America), MEA (Middle East), NAC (North America), SAS (South Asia), SSF (Sub-Saharan Africa).
income_level string no Filter by income level: HIC (High), UMC (Upper Middle), LMC (Lower Middle), LIC (Low).
country_info Read

Get detailed information for a specific country by ISO code, including region, income level, lending type, capital city, and coordinates.

Lua path
app.integrations.worldbank.country_info
Full name
worldbank.worldbank_country_info
ParameterTypeRequiredDescription
code string yes ISO country code (e.g. "US", "CN", "DE").
regions Read

List World Bank aggregate regions and region codes used for filtering country and aggregate data.

Lua path
app.integrations.worldbank.regions
Full name
worldbank.worldbank_regions
ParameterTypeRequiredDescription
page integer no Optional page number.
per_page integer no Optional page size. Defaults to 100.
income_levels Read

List World Bank income level codes such as HIC, UMC, LMC, and LIC.

Lua path
app.integrations.worldbank.income_levels
Full name
worldbank.worldbank_income_levels
ParameterTypeRequiredDescription
No parameters.
lending_types Read

List World Bank lending type codes such as IBD, IDX, IDB, and LNX.

Lua path
app.integrations.worldbank.lending_types
Full name
worldbank.worldbank_lending_types
ParameterTypeRequiredDescription
No parameters.
sources Read

List World Bank data sources, including source IDs needed for source-specific and multi-indicator queries.

Lua path
app.integrations.worldbank.sources
Full name
worldbank.worldbank_sources
ParameterTypeRequiredDescription
page integer no Optional page number.
per_page integer no Optional page size. Defaults to 100.
source_indicators Read

List indicator series available in a World Bank data source. Source 2 is World Development Indicators.

Lua path
app.integrations.worldbank.source_indicators
Full name
worldbank.worldbank_source_indicators
ParameterTypeRequiredDescription
source_id string yes World Bank source ID, such as 2 for World Development Indicators.
page integer no Optional page number.
per_page integer no Optional page size. Defaults to 100.
search_indicators Read

Search economic indicators by keyword. If no query is provided, returns common indicators. Use the indicator code with `worldbank_get_data` to fetch data. Common indicator codes: {$indicators}

Lua path
app.integrations.worldbank.search_indicators
Full name
worldbank.worldbank_indicators
ParameterTypeRequiredDescription
query string no Search keyword for indicators (e.g. "GDP", "inflation", "education"). If omitted, returns common indicators.
indicator_info Read

Get metadata for a World Bank indicator code, including source, source note, source organization, and topics.

Lua path
app.integrations.worldbank.indicator_info
Full name
worldbank.worldbank_indicator_info
ParameterTypeRequiredDescription
indicator string yes World Bank indicator code, such as NY.GDP.MKTP.CD.
topic_categories Read

List the 21 World Bank topic categories (e.g., Education, Health, Economy). Optionally provide a topic ID to list indicators in that topic.

Lua path
app.integrations.worldbank.topic_categories
Full name
worldbank.worldbank_topics
ParameterTypeRequiredDescription
topic_id string no Topic ID to list indicators for that topic. Omit to see all available topics.
languages Read

List global and local language codes supported by the World Bank API v2.

Lua path
app.integrations.worldbank.languages
Full name
worldbank.worldbank_languages
ParameterTypeRequiredDescription
No parameters.
get_indicator_data Read

Fetch economic indicator data for one or more countries from the World Bank. Supports date ranges and most-recent-value mode. Use `worldbank_indicators` to find indicator codes and `worldbank_countries` to find ISO codes.

Lua path
app.integrations.worldbank.get_indicator_data
Full name
worldbank.worldbank_get_data
ParameterTypeRequiredDescription
indicator string yes World Bank indicator code (e.g. "NY.GDP.MKTP.CD", "SP.POP.TOTL"). Use worldbank_indicators to find codes.
countries string no Semicolon-separated ISO country codes (e.g. "US;CN;DE"). Use "all" for global data (default).
date_range string no Date range filter (e.g. "2020:2023", "2023", "2000:2023"). Omit to use mrnev (most recent value).
mrnev string no Number of most recent non-empty values to return per country (default: "1" when no dateRange).
per_page string no Number of results per page (default: "100", max: 500).
multi_indicator_data Read

Fetch data for multiple semicolon-separated indicators from a single World Bank source. The V2 API allows up to 60 indicators.

Lua path
app.integrations.worldbank.multi_indicator_data
Full name
worldbank.worldbank_multi_indicator_data
ParameterTypeRequiredDescription
indicators string yes Semicolon-separated indicator codes, such as SI.POV.DDAY;SP.POP.TOTL.
countries string no Semicolon-separated country codes. Defaults to all.
source string no Source ID. Defaults to 2 for World Development Indicators.
date_range string no Date range such as 2000:2010.
footnote boolean no Include footnote detail when true.
per_page integer no Optional page size. Defaults to 100.
compare_countries Read

Compare a single economic indicator across multiple countries. Returns the most recent value for each country side-by-side. Use `worldbank_indicators` to find indicator codes.

Lua path
app.integrations.worldbank.compare_countries
Full name
worldbank.worldbank_compare_data
ParameterTypeRequiredDescription
indicator string yes World Bank indicator code (e.g. "NY.GDP.MKTP.CD", "SP.POP.TOTL"). Use worldbank_indicators to find codes.
countries string yes Semicolon-separated ISO country codes (e.g. "US;CN;DE;JP").
date_range string no Date range filter (e.g. "2020:2023"). Omit to get most recent value per country.