Skip to main content

Interface to Heliophysics data server API

Project description

Build Status

HAPI Client for Python


pip install hapiclient --upgrade
# or
pip install 'git+' --upgrade

The optional hapiplot package provides basic preview plotting capabilities of data from a HAPI server. The Plotting section of the hapiclient Jupyter Notebook shows how to plot the output of hapiclient using many other plotting libraries.

To install hapiplot, use

pip install hapiplot --upgrade
# or
pip install 'git+' --upgrade

See the Appendix for a fail-safe installation method.

Basic Example

# Get Dst index from CDAWeb HAPI server
from hapiclient import hapi

# See for a list of
# other HAPI servers and datasets.
server     = ''
dataset    = 'OMNI2_H0_MRG1HR'
start      = '2003-09-01T00:00:00'
stop       = '2003-12-01T00:00:00'
parameters = 'DST1800'
opts       = {'logging': True}

# Get data
data, meta = hapi(server, dataset, parameters, start, stop, **opts)

# Plot all parameters
from hapiplot import hapiplot
hapiplot(data, meta)


Basic usage examples for various HAPI servers are given in and the Examples section of a Jupyter Notebook hosted on Google Colab.

See for a list of HAPI servers and datasets.

All of the features are extensively demonstrated in hapi_demo.ipynb, a Jupyter Notebook that can be viewed an executed on Google Colab.

Metadata Model

See also the examples in the Metadata Model section of the hapiclient Jupyter Notebook.

The HAPI client metadata model is intentionally minimal and closely follows that of the HAPI metadata model. We expect that another library will be developed that allows high-level search and grouping of information from HAPI servers. See also issue #106.

Data Model and Time Format

See also the examples in the Data Model section of the hapiclient Jupyter Notebook. The examples include

  1. Fast and well-tested conversion from ISO 8601 timestamp strings to Python datetime objects
  2. Putting the content of data in a Pandas DataFrame object
  3. Creating an Astropy NDArray

A request for data of the form

data, meta = hapi(server, dataset, parameters, start, stop)

returns the Numpy N-D array data and a Python dictionary meta from a HAPI-compliant data server server. The structure of data and meta mirrors the structure of a response from a HAPI server.

The HAPI client data model is intentionally basic. There is an ongoing discussion of a data model for Heliophysics data among the PyHC community. When this data model is complete, a function that converts data and meta to that data model will be included in the hapiclient package.


git clone
cd client-python; pip install -e .

The command pip install -e . creates symlinks so that the local package is used instead of an installed package. You may need to execute pip uninstall hapiclient to ensure the local package is used. To check the version installed, use pip list | grep hapiclient.

To run tests before a commit, execute

make repository-test

To run an individual unit test in a Python session, use, e.g.,

from hapiclient.test.test_hapi import test_reader_short


Submit bug reports and feature requests on the repository issue tracker.


Fail-safe installation

Python command line:

import os
print(os.popen("pip install hapiclient").read())

The above executes and displays the output of the operating system command pip install hapiclient using the shell environment associated with that installation of Python.

This method addresses a problem that is sometimes encountered when attempting to use pip packages in Anaconda. To use a pip package in Anaconda, one must use the version of pip installed with Anaconda (it is usually under a subdirectory with the name anaconda/) as opposed to the one installed with the operating system. To see the location of pip used in a given Python session, enter print(os.popen("which pip").read()).

Project details

Download files

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

Files for hapiclient, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size hapiclient-0.2.1.tar.gz (29.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page