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)

In addition, a search function is also available to allow the user to search series by their descriptions, for example as:

haver.search(query='employment')

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}.

Finally, a database of available recessions can be obtained as

haver.recessions()

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.3.0.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

haver-0.3.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for haver-0.3.0.tar.gz
Algorithm Hash digest
SHA256 07862f471b398392432678f02ed8bdc8bed2bccb5da2b7f6c6c6ec9437291d67
MD5 6df77576abdc473c86c7fa1d67da7ab5
BLAKE2b-256 6ec4e6a7892eb1cbbef15a9d3ed0285fa6d3f0e752a6e6e0d634f319806184d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: haver-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 581bf4f963323ddcb5d998b366278a4970bed861ab88c958896fdeb4ddbf2819
MD5 e2267391132f47f6ea5b7f2eeb5e1b23
BLAKE2b-256 52cfa484f2394eac51c9a1a2c6237ef771e6100091ed58e1bef36d2e6a1c83a9

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