Skip to main content
Version: 0.8.0

Domains

The Domains API provides access to the administrative regions (domains) available in the BPS (Badan Pusat Statistik) Indonesia data system. These domains represent the geographic organizational structure of Indonesia's statistical data collection, ranging from national level to provincial and regency levels.

Understanding domains is crucial for accessing BPS data, as most other API endpoints require a domain code to specify which geographic region's data you want to retrieve. Each domain corresponds to a BPS regional office that collects and manages statistical data for their respective areas.

Available Domain Types

The domains functionality provides several filtering options to retrieve specific types of administrative regions:

Domain Type Options

TypeDescriptionUse Case
DomainType.allAll available domainsGet complete list of all BPS offices
DomainType.provinceProvincial level domains onlyAccess provincial statistical data
DomainType.regencyAll regency/city level domainsAccess local government statistical data
DomainType.regencyByProvinceRegencies within a specific provinceFilter local domains by province

Parameters

ParameterTypeDescription
typeDomainTypeThe type of domain to retrieve (default: DomainType.all)
provinceCodeString?The province code for filtering domains (required if type = DomainType.regencyByProvince)

Examples

1. Get All Available Domains

// Fetch all domains from BPS
final domainResult = await StadataFlutter.instance.list.domains(
type: DomainType.all,
);

final domainList = domainResult.data;
final pagination = domainResult.pagination;

// Print pagination info
print('Current Page: ${pagination.page}');
print('Total Pages: ${pagination.pages}');
print('Data Count in This Page: ${pagination.count}');
print('Per Page: ${pagination.perPage}');
print('Total: ${pagination.total}');
print('------------------------');

// Print the retrieved domain data
for (final domain in domainList) {
print('Domain ID: ${domain.id}'); // Ex. 0000 (National), 3200 (West Java)
print('Name: ${domain.name}'); // Ex. Indonesia, Jawa Barat
print('URL: ${domain.url}'); // Ex. https://www.bps.go.id, https://jabar.bps.go.id
print('------------------------');
}

2. Get Provincial Domains Only

// Fetch only provincial level domains
final provincialResult = await StadataFlutter.instance.list.domains(
type: DomainType.province,
);

// Access provincial BPS offices
for (final province in provincialResult.data) {
print('Province Code: ${province.id}'); // Ex. 3200, 3300, 7300
print('Province Name: ${province.name}'); // Ex. Jawa Barat, Jawa Tengah, Sulawesi Selatan
print('BPS Office URL: ${province.url}');
print('------------------------');
}

3. Get Regencies in a Specific Province

// Fetch regencies/cities in West Java (code: 3200)
final regencyResult = await StadataFlutter.instance.list.domains(
type: DomainType.regencyByProvince,
provinceCode: '3200', // West Java province code
);

// Access regency/city BPS offices
for (final regency in regencyResult.data) {
print('Regency Code: ${regency.id}'); // Ex. 3201, 3202, 3271
print('Regency Name: ${regency.name}'); // Ex. Kab. Bogor, Kab. Sukabumi, Kota Bogor
print('BPS Office URL: ${regency.url}');
print('------------------------');
}

Properties (DomainEntity)

PropertyTypeDescription
idStringUnique identifier for the domain (BPS code)
nameStringThe name of the domain (region)
urlStringURL of the BPS office website for this domain

Common Domain Codes

Here are some frequently used domain codes for reference:

National and Special Regions

Domain CodeNameLevel
0000IndonesiaNational

Major Provinces

Domain CodeNameCapital
1100AcehBanda Aceh
1200Sumatera UtaraMedan
3100DKI JakartaJakarta
3200Jawa BaratBandung
3300Jawa TengahSemarang
3400DI YogyakartaYogyakarta
3500Jawa TimurSurabaya
5100BaliDenpasar
7300Sulawesi SelatanMakassar

Major Cities (Regency Level)

Domain CodeNameProvince
3171Kota Jakarta SelatanDKI Jakarta
3271Kota BogorJawa Barat
3372Kota SurakartaJawa Tengah
3471Kota YogyakartaDI Yogyakarta
3578Kota SurabayaJawa Timur

Usage Workflow

The typical workflow for using domains with other BPS API endpoints:

  1. Discover Available Domains: Use domains() to see what geographic regions are available
  2. Select Target Region: Choose the appropriate domain code based on your data needs
  3. Use Domain Code: Pass the domain code to other API endpoints (publications, news, static tables, etc.)

Complete Example

// 1. Get all available domains
final allDomains = await StadataFlutter.instance.list.domains();
print('Total Available Domains: ${allDomains.data.length}');

// 2. Filter for a specific province (West Java)
final westJavaRegencies = await StadataFlutter.instance.list.domains(
type: DomainType.regencyByProvince,
provinceCode: '3200',
);
print('Regencies in West Java: ${westJavaRegencies.data.length}');

// 3. Use domain code with other APIs
final publications = await StadataFlutter.instance.list.publications(
domain: '3200', // Use West Java domain code
lang: DataLanguage.id,
);
print('Publications from West Java BPS: ${publications.data.length}');

Administrative Structure Context

Indonesia's administrative structure consists of:

  1. National Level (0000): Central BPS Indonesia
  2. Provincial Level (XX00): 34 provinces, each with a BPS provincial office
  3. Regency/City Level (XXXX): 514+ regencies and cities, each with a local BPS office

Each level collects and manages statistical data relevant to their administrative scope. Understanding this hierarchy helps in selecting the appropriate domain for your data needs.

Error Handling

All domain methods return a Future<ListResult<Domain>> and may throw specific exceptions:

  • DomainException: Domain-related errors (invalid province code, etc.)
  • ApiException: Network or API-related errors
  • ApiKeyNotFoundException: Invalid or missing API key
try {
final result = await StadataFlutter.instance.list.domains(
type: DomainType.regencyByProvince,
provinceCode: '3200',
);
// Handle success
print('Found ${result.data.length} regencies in the province');
} on DomainException catch (e) {
print('Domain error: ${e.message}');
// Handle invalid province codes or domain-specific errors
} on ApiException catch (e) {
print('API error: ${e.message}');
// Handle network or API-related errors
} catch (e) {
print('Unexpected error: $e');
}