Skip to main content

Hierarchical Organization

The GSS StatsBank organizes statistical data in a three-level hierarchy:
This structure mirrors a file system: Databases are like drives, Topics are like folders, and Tables are like files containing the actual data.

Level 1: Databases

Databases represent major surveys, censuses, or data collection programs. Each database contains related statistical information organized by topic.

Available Databases

The GSS StatsBank includes several databases:
DatabaseDescription
PHC 2021 StatsBank2021 Population and Housing Census data
PHC20102010 Population and Housing Census data
GLSS7Ghana Living Standards Survey Round 7
Ghana Census of Agriculture (GCA)Agricultural census data
Annual Household Income and Expenditure Survey (AHIES)Household income and expenditure statistics
Macro Economic IndicatorsEconomic indicators and statistics
Education(Admin)Educational administrative data
TradeTrade statistics
To retrieve the current list of databases, make a GET request to the API base URL:
URL = "https://statsbank.statsghana.gov.gh:443/api/v1/en/"
response = request(URL) |> req_perform()
response |> resp_body_json()

Level 2: Topics

Within each database, data is organized into thematic topics. Topics group related tables together for easier navigation.

Example: PHC 2021 StatsBank Topics

The 2021 Population and Housing Census database contains these topics:
  • Population - Population counts, distributions, and characteristics
  • Fertility and Mortality - Birth rates, death rates, and related statistics
  • Human Development Indicators - HDI components and related metrics
  • Economic Activity - Employment, occupation, and labor force data
  • Education and Literacy - Educational attainment and literacy rates
  • Multidimensional Poverty - Poverty indices and measurements
  • Housing - Housing characteristics and conditions
  • Water and Sanitation - Access to water sources, sanitation facilities, and waste disposal
  • Structures - Building and structure characteristics
  • ICT - Information and Communication Technology access and usage
  • Difficulties in Performing Activities - Disability and functional difficulty data
To explore topics within a database, append the database name to the base URL:
build_url(URL, "PHC 2021 StatsBank")

Level 3: Tables

Tables contain the actual statistical data. Each table focuses on specific variables and can be queried with filters to extract the exact data you need.

Table Identification

Tables are identified by:
  • The .px file extension
  • A descriptive name indicating the table’s content

Example: Water and Sanitation Tables

The “Water and Sanitation” topic contains multiple tables:
Table NameDescription
waterDisposal_table.pxMethods of liquid waste disposal
mainwater_table.pxMain sources of drinking water
domesticWater_table.pxDomestic water usage
toiletfacility_table.pxToilet facility types and access
toilettype_table.pxClassification of toilet types
solidDisposal_table.pxSolid waste disposal methods
storage_table.pxWater storage methods
timetaken.pxTime taken to fetch water
Each table contains specific variables (dimensions) that can be filtered and selected when querying the data.
To access data about water disposal methods:
Base URL: https://statsbank.statsghana.gov.gh:443/api/v1/en/

Database: PHC 2021 StatsBank

Topic: Water and Sanitation

Table: waterDisposal_table.px
Complete path:
https://statsbank.statsghana.gov.gh:443/api/v1/en/PHC%202021%20StatsBank/Water%20and%20Sanitation/waterDisposal_table.px

Response Format Differences

The API returns different response structures depending on the level:
Key used: dbid
[
  {
    "dbid": "PHC 2021 StatsBank",
    "text": "PHC 2021 StatsBank"
  }
]
Key used: id
[
  {
    "id": "Water and Sanitation",
    "text": "Water and Sanitation"
  }
]
Returns: Metadata including variables, values, and table metadata
{
  "variables": [
    {
      "code": "WaterDisposal",
      "values": [...],
      "valueTexts": [...]
    }
  ]
}
This structural difference is important when programmatically navigating the API - use dbid at the root level and id for all sub-levels.

Build docs developers (and LLMs) love