Skip to main content

A Python wrapper to Haver Analytics' RESTful API.

Project description

haver-api

CircleCI version

PyPI Latest Release License Downloads Buy Me A Coffee

The haver-api 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 soon 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, 2018

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.9.0.tar.gz (30.7 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.9.0-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: haver_api-0.9.0.tar.gz
  • Upload date:
  • Size: 30.7 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.9.0.tar.gz
Algorithm Hash digest
SHA256 52fa177c6e1f1f18a8e486deb9cf72bdba7e5e9e735687396488c9a7b52508bb
MD5 8da2285963195353c14ff59d094b5719
BLAKE2b-256 7a39f6f34ba1b81752d361cd697c180da630825f5e42a47f31776aeff4742356

See more details on using hashes here.

File details

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

File metadata

  • Download URL: haver_api-0.9.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.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56a2a47f32cee49e5623c89b2350a84798194c21330c908d16a47f16e96f70ac
MD5 df670111a334869d6d415fb6a20ab43d
BLAKE2b-256 7ccf59d075831c760f6b143e76785dbce0b42288811b7d1cb3a4cd2cfdc62832

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