Skip to main content

HDX CLI tool kit for commandline interaction with HDX

Project description

HDX CLI Toolkit

Overview

This toolkit provides a commandline interface to the Humanitarian Data Exchange (HDX) to allow for bulk modification operations and other administrative activities such as getting id values for users and organization. It is useful for those managing HDX and developers building data pipelines for HDX. The currently supported commands are as follows:

  configuration              Print configuration information to terminal
  download                   Download dataset resources from HDX
  get_organization_metadata  Get an organization id and other metadata
  get_user_metadata          Get user id and other metadata
  list                       List datasets in HDX
  print                      Print datasets in HDX to the terminal
  quickcharts                Upload QuickChart JSON description to HDX
  remove_extras_key          Remove extras key from a dataset
  scan                       Scan all of HDX and perform an action
  showcase                   Upload showcase to HDX
  update                     Update datasets in HDX
  update_resource            Update a resource in HDX

In the most part it is a thin wrapper to the hdx-python-api library written by Mike Rans.

The library requires some configuration, described below, to authenticate to the HDX instance.

Installation

hdx-cli-toolkit is a Python application published to the PyPI package repository, therefore it can be installed easily with:

pip install hdx_cli_toolkit

Users may prefer to make a global, isolated installation using pipx which will make the hdx-toolkit commands available across their projects:

pipx install hdx_cli_toolkit

hdx-toolkit can then be updated with:

pipx install --force hdx_cli_toolkit

hdx-cli-toolkit uses the hdx-python-api library, this requires the following to be added to a file called .hdx_configuration.yaml in the user's home directory.

hdx_key_stage: "[an HDX API token from the staging HDX site]"
hdx_key: "[an HDX API token from the prod HDX site]"
default_organization: "[your organization]"

The default_organization is required for the configuration command and can be supplied using the --organization= commandline parament. If not defined it will default to hdx.

A user agent (hdx_cli_toolkit_*) is specified in the ~/.useragents.yaml file with the * replaced with the users initials.

hdx-cli-toolkit:
    preprefix: [YOUR_ORGANIZATION]
    user_agent: hdx_cli_toolkit_ih

Usage

The hdx-toolkit is built using the Python click library. Details of the currently implemented commands can be revealed by running hdx-toolkit --help, and details of the arguments for a command can be found using hdx-toolkit [COMMAND] --help

A detailed guide can be found in the USERGUIDE.md file

Contributions

For developers the code should be cloned installed from the GitHub repo, and a virtual enviroment created:

python -m venv venv
source venv/Scripts/activate

And then an editable installation created:

pip install -e .

The library is then configured, as described above.

This project uses a GitHub Action to run tests and linting. It requires the following environment variables/secrets to be set in the test environment:

HDX_KEY - secret. Value: fake secret
HDX_KEY_STAGE - secret. Value: a live API token for the stage server
HDX_SITE - environment variable. Value: stage
USER_AGENT - environment variable. Value: hdx_cli_toolkit_gha
PREPREFIX - - environment variable. Value: [YOUR_organization]

Most tests use mocking in place of HDX, although the test_integration.py suite runs against the stage server.

New features should be developed against a GitHub issue on a separate branch with a name starting GH[issue number]_. PULL_REQUEST_TEMPLATE.md should be used in preparing pull requests. Versioning is updated manually in pyproject.toml and is described in the template, in brief it is CalVer YYYY.MM.Micro.

Publication

Publication to PyPI is done automatically when a release is created.

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

hdx_cli_toolkit-2025.3.1.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

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

hdx_cli_toolkit-2025.3.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file hdx_cli_toolkit-2025.3.1.tar.gz.

File metadata

  • Download URL: hdx_cli_toolkit-2025.3.1.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hdx_cli_toolkit-2025.3.1.tar.gz
Algorithm Hash digest
SHA256 201dac1b3efb192bd02824b86b0c79c6e18a6697109d4b612ec4a3fed52e331c
MD5 592178963a8bf81f88718277bac5fd37
BLAKE2b-256 4b658b41d0e53bdbfb8bc38c4dc8b2e46f378a1e829cb10d0d120b83a7cc9fdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for hdx_cli_toolkit-2025.3.1.tar.gz:

Publisher: publish.yaml on OCHA-DAP/hdx-cli-toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hdx_cli_toolkit-2025.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hdx_cli_toolkit-2025.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 100bbefbd79761bb7b59a0b8bda9469de7c37e1f6085b7042bda5304f9438ce8
MD5 a341dca3f48fa710b10e1d41f1df30b8
BLAKE2b-256 87e71d8c7b5328cd7b14f9c3e561622fdc2a1c15ab9dde958fd7a7e67df976dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for hdx_cli_toolkit-2025.3.1-py3-none-any.whl:

Publisher: publish.yaml on OCHA-DAP/hdx-cli-toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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