Metadata-Version: 2.3
Name: rhowb
Version: 1.0.4
Summary: Data from world bank api
Author: rhozhang
Author-email: rhozhang <rhozhang@163.com>
Requires-Dist: polars>=1.42.1
Requires-Dist: requests>=2.34.2
Requires-Python: >=3.14
Description-Content-Type: text/markdown

# RhoWB: a Python Wrapper to Retrieve Data from World Bank API

Why named RhoWB? Barely any decent names are still available in Pypi.

## Installation

```bash
pip install rhowb
```

## Importing the package

```python
import rhowb as wb
```

## Data Sources in World Bank API

To list all data sources in World Bank, use:

```python
wb.getsources()   # from cache
wb.getsources(fromcache = False)   # from web and update cache file
```

## Topics in World Bank API

To list all topics in World Bank, use:

```python
wb.gettopics()   # from cache
wb.gettopics(fromcache = False)   # from web and update cache file
```

## Regions in World Bank

To list all regions in World Bank, use:

```python
wb.getregions()   # from cache
wb.getregions(fromcache = False)   # from web and update cache file
```

## Income levels in World Bank

WB assigns its economies to four income groups: low, lower-middle, upper-middle, and high. The classifications are updated each year on July 1, based on the GNI per capita of the previous calendar year. For example, the updated income classifications for FY2025, based on the GNI per capita of 2023.

GNI measures are expressed in US dollars using conversion factors derived according to the Atlas method. WB's income classification aims to reflect an economy’s level of development, drawing on Atlas GNI per capita as a broadly available indicator of economic capacity.

The classification of countries into income categories has evolved significantly over the period since the late 1980s. In 1987, 30% of reporting countries were classified as low-income and 25% as high-income countries. Jumping to 2023, these overall ratios have shifted down to 12% in the low-income category and up to 40% in the high-income category.

| FY    | LIC      | LMC            | UMC              | HIC          | Data for Calendar Year |
|:-----:|----------|----------------|------------------|--------------|------------------------|
| 2027  | <= 1175  | [1176, 4635]   | [4636, 14374]    | > 14375      | 2026                   |
| 2026  | <= 1135  | [1136, 4495]   | [4496, 13935]    | > 13935      | 2024                   |
| 2025  | <= 1145  | [1146, 4515]   | [4516, 14005]    | > 14005      | 2023                   |   
| 2024  | <= 1135  | [1136, 4465]   | [4466, 13845]    | > 13845      | 2022                   |
| 2023  | <= 1085  | [1086, 4255]   | [4266, 13205]    | > 13205      | 2021                   |
| 2022  | <= 1045  | [1046, 4095]   | [4096, 12695]    | > 12695      | 2020                   |
| 2021  | <= 1035  | [1036, 4045]   | [4046, 12535]    | > 12535      | 2019                   |
 

To list all income levels in World Bank, use:

```python
wb.listincomelevels()
```

## Economies in World Bank

To list all economies in World Bank, use:

```python
wb.getecons()   # from cache
wb.getecons(fromcache = False)   # from web
```

To query information (id, region, incomelevel, etc.) of a specific economy, use economy id. e.g. to query information of China:

```python
wb.queryeconomy('CHN')
```

To query information of economies in a specific region, use region id. e.g. to query information of economies in East Asia & Pacific:

```python
wb.queryeconomy(region = 'EAS')
```

To query information of economies in a specific income level, use income level id. e.g. to query information of economies of High income:

```python
wb.queryeconomy(incomelevel = 'HIC')
```

## Querying Indicators

To query indicators, use:

```python
wb.queryindicator(name = 'GDP')
```

To restrict data source, use 'source' (source id) option:

```python
wb.queryindicator(name = 'GDP', source = '2')
```

## Retrieving Data

To retrieve total population data of China and India from 2000 to 2025, use:

```python
wb.getdata(
    'SP.POP.TOTL',
    'CHN;IND',
    period = '2000:2025'
)
```
