IMF WEO 2022 missing?

I see the october 2022 here: dbnomics-source-data / imf-source-data · GitLab

But its not in the API here: IMF | DBnomics

Any help on getting most recent IMF WEO through dbnomincs?

I don’t see it through the api either:

provider_code= 'IMF'
provider_data_string= f'{provider_code}'
providers_json= requests.get(provider_data_string).json()
imf_datasets= [code['code'] for code in providers_json['datasets']['docs']]
'WEO:2022-10' in imf_datasets


The dataset WEO:2022-10 is indeed on DBnomics: IMF/WEO:2022-10 | DBnomics

It is well referenced in the category tree on the IMF provider page: IMF | DBnomics

The response of the API is paginated, and as you’re doing a low-level API call, you have to iterate over the pages by yourself.

In the response you may found (I did not try):

providers_json["datasets"]["num_found"] == 96
providers_json["datasets"]["limit"] == 50

So you can pass a larger limit, calling

Or you could do something like:

def fetch_provider_dataset_codes(provider_code, page_num = 0, limit = 50):
    offset = page_num * limit
    provider_datasets_url = f'{provider_code}?offset={offset}'
    response_json = requests.get(provider_datasets_url).json()
    num_found = response_json["datasets"]["num_found"]
    return num_found, [code['code'] for code in response_json['datasets']['docs']]

provider_code = "IMF"
limit = 50
num_found, imf_dataset_codes = fetch_provider_dataset_codes(provider_code, page_num=0)
num_pages = round(num_found / limit)
for page_num in range(1, num_pages):
    imf_dataset_codes.extend(fetch_provider_dataset_codes(provider_code, page_num=page_num))

assert 'WEO:2022-10' in imf_dataset_codes == True

got it! thank you so much

I run your code and the assertion error doesn’t check out:

AssertionError                            Traceback (most recent call last)
c:\Users\yosty\Greenmantle LLC\Research - greenmantle\trade\ in <module>
     42     imf_dataset_codes.extend(fetch_provider_dataset_codes(provider_code, page_num=page_num))
---> 44 assert 'WEO:2022-10' in imf_dataset_codes == True


the list of codes should be zipped more efficiently but this is working:

provider_code = "IMF"
limit = 50
num_found, _ = fetch_provider_dataset_codes(provider_code, page_num=0)
num_pages = round(num_found / limit)
imf_dataset_codes= []
for page_num in range(0, num_pages):
    _, temp_codes= fetch_provider_dataset_codes(provider_code, page_num=page_num)
    imf_dataset_codes= imf_dataset_codes + temp_codes

'WEO:2022-10' in imf_dataset_codes

You’re right, I forgot to extract the dataset codes from the tuple. Thank you for the fix!

Thank you for your help!