Skip to main content

A Python wrapper to Haver Analytics' RESTful API.

Project description

haver

CircleCI version PyPI Latest Release License Downloads Buy Me A Coffee

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

This library is not an official product of Haver Analytics and is not covered by its customer support. If you encounter any issue or have suggestions for improvements, please feel free to open an issue or submit a pull request.

Installation

pip install haver-api

❗❗❗ Notice ❗❗❗

The ownership of the old haver domain on PyPi (installable as pip install haver) has been passed on to Haver Analytics.

In order to install this library you now need to use the command above.

Running pip install haver will now install Haver Analytics' library

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_API_KEY 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, 2021

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_api-0.8.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

haver_api-0.8.0-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file haver_api-0.8.0.tar.gz.

File metadata

  • Download URL: haver_api-0.8.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for haver_api-0.8.0.tar.gz
Algorithm Hash digest
SHA256 b43e2e359f7a631f66343fbcce3181741e561be35d68bb36123686b2c44b79a1
MD5 a13335bcfc11642804f5ef8154626920
BLAKE2b-256 4d7d58ace33e42c1f56a8136fc3d4bcfefdff8eec6adc927227203863884b502

See more details on using hashes here.

File details

Details for the file haver_api-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: haver_api-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for haver_api-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4793234e55e939d41f8a356750bbc85a7bb24c3ea1dc0bd71df26c292a406fe1
MD5 fed91952cc77eae55a057a331f952585
BLAKE2b-256 cf5252cdb7c58c2a94c289c3a8685c1d9df455b7d94c7d7fa2a67fcc07d38813

See more details on using hashes here.

Supported by

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