Skip to main content

A Python wrapper to Haver Analytics' RESTful API.

Project description

haver

CircleCI version PyPI Latest Release License Buy Me A Coffee

The haver library provides a convenient wrapper to Haver Analytics' RESTful API.

Installation

pip install haver

How to

Connection and Authentication

from haver import Haver

haver = Haver(api_key='<your-haver-API-token>')

The class Haver also accepts keyword arguments to be passed to requests, which handles the connection to the API under the hood. In this way, by passing e.g. verify and proxy parameters, users can access Haver databases from behind firewalls. For example:

haver = Haver(api_key='<your-haver-API-key>',
              verify=False, # Or local path to certificates 
              proxies={'http': 'http://proxy-username:proxy-password@proxy-server.com:8080',
                       'https': 'http://proxy-username:proxy-password@proxy-server.com:8080'})

Instead of passing the API key explicitely each time, the user can also set an environmental variable HAVER_TOKEN containing the API key. In this case connection will be as simple as haver = Haver().

Obtaining your API Key

You can find your API key at this link.

Exploring available resources

All available databases can easily be listed as

haver.get_databases()

which will return a dictionary with keys the database names and values the corresponding database description:

{'UNPOP': 'U.N. Population Statistics',
 'EPFRECA': 'Fund Country Allocations',
 'EUFIN': 'Financial Data',
 ...
 }

Further information on each dataset can be obtained via the method haver.database_info, and series within each database can be listed e.g. as

haver.get_series(database='UNPOP', full_info=True)

Querying data

In order to retrieve data, the user has the option of querying one series at a time via the dedicated method

haver.read(database='EUDATA', series='N997CE')

which returns data in dictionary format, or querying multiple series as

haver.read_df(haver_codes=['N997CE@EUDATA','N025CE@EUDATA'])

where individual haver_codes are created by joining series and database names as {series}@{database}.

Author

Luca Mingarelli, 2024

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

haver-0.4.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

haver-0.4.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file haver-0.4.0.tar.gz.

File metadata

  • Download URL: haver-0.4.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for haver-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b6f39213def6d7adaa132bc3be28ebad08edbca59361bd5f2db7cde02dba1ccf
MD5 daa989693a8fefaae6f1c2967acf1fad
BLAKE2b-256 e35dc0760d4cfb3dd4370c346f96409453806a94e2fb2160582d5eb619e1ef03

See more details on using hashes here.

File details

Details for the file haver-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: haver-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for haver-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aafb2077cd3653cc1eb0c5fe7eccd25920eacec9adf88fdd488b3dfc29da6ca6
MD5 66cf9ea018c35e13b098496ffa541326
BLAKE2b-256 a34d3d8b345c7e4674f879dcb9754b0a98b56a7f0a0b82dec138d51c1d3e9819

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page