# Thailand Open Data Studio

Thailand Open Data Studio pulls Thai government datasets from dev.data.go.th, provincial gdcatalog hosts and the National Statistical Office API, then joins them into one flat table per run: GDP, GDP per capita, inflation, provincial CPI, labour participation, tourists, life expectancy and population density. Years are converted from Buddhist Era to CE. It costs $0.02 per joined pull, $0.01 for a raw extract, and delivers CSV, JSON or XLSX.

## Key facts

- Price: from $0.02 per joined pull, $20.00 per 1,000
- Pricing model: Pay per event
- Output: JSON, CSV, Excel, XML, RSS via Apify datasets
- Access: Apify Console, REST API, Python and JS clients
- Version: Updated Nov 2026, build 0.1.7
- Usage: 100.0% successful runs (30 days)
- Actor: subimpact/th-open-data-studio

## Who it is for

- Market researchers sizing Thai provinces and regions
- Hospitality and tourism analysts working with provincial arrivals
- Policy and NGO teams comparing health and demographic indicators
- Analysts who need NSO tables out of a portal and into a spreadsheet

## Use cases

### GDP and population in one table

The T1 preset joins GDP, GDP per capita and population at national level in current prices in million baht. That gives a per-head figure you can chart directly, and because the join happens inside the run rather than across two downloads, the year alignment is already handled. Export as xlsx when the table goes to a client deck.

### Headline inflation with provincial CPI

T2 pairs the national headline inflation rate with provincial CPI for all items, so you can show how a province's price level tracks the national story. Use customAgg set to mean if a province reports several CPI lines, and customJoinType left when you want every province kept even where a year is missing.

### Tourism in Nan province

T4 delivers Thai, foreign and total tourists plus visitor counts for Nan province by year. It is a narrow, province-level view rather than a national series, which suits a local hospitality or transport study. Add a webhookUrl and the file is POSTed to a shared drive after each scheduled run, with the verification file reporting the year range covered.

### Life expectancy and death rates

T5 joins life expectancy for men and women from NSO survey data with the death rate, which is the pair a health or insurance analyst needs for a longevity view. Because the source tables come from NSO rather than a single national portal, the join is where most of the work would otherwise go. The AI-ready package documents each field for a model.

### Population, density and non-Thai citizens

T6 combines annual national population, population density and the count of non-Thai citizens. Useful for sizing a service by density rather than raw population, or for tracking how the foreign resident share moves year to year. Buddhist Era years in the source are converted to CE in the output, so the table needs no manual offset.

## Price events

- Joined pull (`joined-pull`): $0.02, lowest tier $0.02. One cross-dataset join delivered as flat CSV/JSON/XLSX (studio mode).
- Data extraction (`extract-pull`): $0.01, lowest tier $0.01. One raw dataset pull (1-5 datasets by ID, no join).

Prices from the Apify Store. Apify shows the final price before each run.

## How it compares with other Apify actors

Price per 1,000 pulls at Apify Store list prices, checked 20 Nov 2026.

| Actor | Price per 1,000 pulls (Free plan) | Higher plans (Gold) | Start fee per run | Platform usage | Users | Rating | Last build |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Thailand Open Data Studio — Gov Data Joins (this API) | $20.00 | $20.00 | None | Included | 2 | No reviews yet | 18 Nov 2026 |
| [CKAN Open Data Exporter: Government Datasets & Files](https://apify.com/doggo/ckan-opendata-exporter) | Charges per result row from a CKAN portal, plus a start fee per run. | Same unit, see the first price column | $0.01 | Included | 3 | No reviews yet | 3 Jul 2026 |

### Where CKAN Open Data Exporter: Government Datasets & Files is stronger

- Works across thousands of CKAN government portals, not just one country
- Dataset search and metadata export as well as data rows
- Accepts any portal domain you point it at

### Where this API is stronger

- Cross dataset joins with six ready presets for Thai economic and social series
- Buddhist era years converted to Gregorian and licence attribution attached
- Output delivered as joined rows rather than raw portal records

No Store actor is built for Thailand's dev.data.go.th and NSO data as a joined series; the closest is a general CKAN exporter that can pull rows from government portals. Ours adds the join presets, year conversion and attribution that turn those datasets into analysis ready output. Buyers who just want raw portal records can use the exporter.

Prices are Apify Store list prices, checked 20 Nov 2026. Platform usage 'Paid separately' means Apify bills compute on top of the event price. Check each listing before you buy.

## Input

- `mode` (string, optional): studio = value layer (presets, joins, AI-ready package). extract = raw data pull of 1-5 datasets by ID (cheaper per-pull event).
- `datasetIds` (array, optional): For mode=extract: list of Thai resource ids (CKAN UUIDs) or NSO table codes (OS_/LFS_/IMD_/PHS_/OLD_ prefix) to pull raw (1-5). Leave empty to use studio mode.
- `preset` (string, optional): Join bundle. T1 = GDP & Economy by Year. T2 = Inflation & CPI by Year. T3 = Labour Market by Year. T4 = Tourism by Year (Nan). T5 = Health & Longevity by Year. T6 = Demography & Migration by Year. custom = bring your own dataset ids.
- `customDatasets` (array, optional): For preset=custom: list of Thai resource ids (CKAN UUIDs) or NSO table codes to join (2-6). Leave empty to use a preset.
- `customKey` (array, optional): For preset=custom: key parts to join on. Use 'year' (auto-extracted from year/YEAR/ปี/TIME_PERIOD fields, Buddhist Era converted to CE) or raw field names. All datasets must share these keys.
- `customJoinType` (string, optional): inner keeps only keys present in every dataset; left keeps all keys from the first dataset.
- `customParams` (string, optional): For preset=custom: JSON object of extra API params applied to every dataset, e.g. {"filters": {"AREA": "ทั่วราชอาณาจักร"}}.
- `customAgg` (string, optional): none = keep raw rows (last value per key). sum = aggregate numeric values per key. mean = average numeric values per key.
- `format` (string, optional): File format delivered to the key-value store (dataset records are always JSON).
- `webhookUrl` (string, optional): POST the result file to this URL after the run (3 retries with backoff). Leave empty to skip.
- `aiReady` (boolean, optional): Also emit JSON Schema + data dictionary + sample rows for LLM/RAG ingestion.
- `includeAttribution` (boolean, optional): Attach source/licence metadata sidecar to every output (Open Data Common / CC).

### Example input

```json
{
  "mode": "studio",
  "preset": "T1"
}
```

## Output fields

- `mode` (any): 
- `preset` (any): 
- `rows` (any): 
- `format` (any): 
- `files` (any): 
- `year_range` (any): 
- `run_url` (any): 

## Sample output

Trimmed from one of our own test runs. Personal data is redacted.

```json
[
  {
    "year": 1995,
    "gdp_million_baht": 4217611.999,
    "gdp_per_capita_baht": 71543.456,
    "population_thousands": 58951.75066
  },
  {
    "year": 1996,
    "gdp_million_baht": 4638607,
    "gdp_per_capita_baht": 77835.632,
    "population_thousands": 59594.9032
  }
]
```

## How to run it

1. Leave mode at studio and pick a preset, for example T1 for GDP and economy by year, or T6 for demography and migration.
2. Set format to csv, json or xlsx, and leave aiReady on if a model will query the table later.
3. For your own indicators, set preset to custom and list two to six dataset ids in customDatasets, using CKAN resource UUIDs or NSO table codes.
4. Run in the Apify Console and open the Dataset tab; the summary record reports rows, format, files and the year range in CE.
5. Download the joined file from the key-value store as <preset>_join.csv, or take the attribution and verification sidecars with it.

### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/subimpact~th-open-data-studio/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode":"studio","preset":"T1"}'
```

### Python

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("subimpact/th-open-data-studio").call(run_input={
      "mode": "studio",
      "preset": "T1"
    })

for item in client.dataset(run["default_dataset_id"]).iterate_items():
    print(item)
```

### JavaScript

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('subimpact/th-open-data-studio').call({
  "mode": "studio",
  "preset": "T1"
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();

console.log(items);
```

### n8n

Use the Apify node (Run an Actor).
Actor ID: subimpact/th-open-data-studio
Input JSON: paste the example input below.

## Limits

- The tourism preset covers Nan province only, not national arrivals.
- Source coverage varies by dataset, so a joined table can hold empty cells where a province or year is not published.
- A custom join needs dataset ids in advance: CKAN resource UUIDs or NSO table codes.
- Attribution terms differ per source record, so check the sidecar before republishing a table.

## FAQ

### What does one pulled report cost?

$0.02 per joined pull, which is one cross-dataset join delivered as a flat file, and $0.01 for a raw extract pull of one to five datasets by ID. Thai government data itself is free; the price covers the join, the year conversion and the packaging.

### Which sources does it read?

The dev.data.go.th catalogue of more than 39,000 datasets, provincial datastore hosts under gdcatalog.go.th, and the National Statistical Office API at catalogapi.nso.go.th. All are public, so no API key or account is needed.

### How are Buddhist Era years handled?

They are converted to CE by subtracting 543, both in the joined output and in the year key used for joins. You get a normal Gregorian year column, so the table drops straight into a chart or a database without a manual offset.

### What are the six presets?

T1 GDP and economy, T2 inflation and CPI, T3 labour market, T4 tourism for Nan province, T5 health and longevity, and T6 demography and migration. Set preset to custom when your indicators are not in that list.

### Can I pull a specific NSO table?

Yes. In extract mode, datasetIds accepts NSO table codes such as OS_02_0015_01, or CKAN resource UUIDs from the catalogue, between one and five per run. That returns the raw table with per-dataset files and a manifest, without any join or reshape.

### What licence applies to the output?

Datasets are published under Open Data Common or a Creative Commons attribution licence, as stated on each source record. The run writes an attribution sidecar that lists the sources used, so the correct credit travels with the file.

### Which formats can I get?

json, csv and xlsx, chosen with format. The rows are also in the Dataset tab for a one click export, and the same file is stored in the key-value store, plus a verification file with the row count and year range.

## Links

- Page: https://subimpact.net/apis/th-open-data-studio/
- Category: https://subimpact.net/apis/category/open-data/
- Run on Apify: https://apify.com/subimpact/th-open-data-studio
- All data APIs: https://subimpact.net/apis/
- Catalogue JSON: https://subimpact.net/apis/catalogue.json
