Skip to main content

Python client library for the ReliefWeb API

Project description

ReliefWeb Python Library

A Python client library for the ReliefWeb API.

Installation

pip install .

Usage

from reliefweb.client import ReliefWebClient

# Initialize client
client = ReliefWebClient()

# Fetch reports
reports = client.get_reports(
    filters={"country": {"eq": "ETH"}},
    fields=["id", "date", "title"],
    sort=[{"date": "desc"}],
    limit=5,
    offset=0,
    presets=None
)
print("Reports:", reports)

# Fetch jobs
jobs = client.get_jobs(
    filters={"status": {"eq": "active"}},
    fields=["id", "title", "date"],
    sort=[{"date": "desc"}],
    limit=5
)
print("Jobs:", jobs)

# Fetch training
training = client.get_training(
    filters=None,
    fields=["id", "title", "date"],
    sort=[{"date": "desc"}],
    limit=5
)
print("Training:", training)

ReliefWebClient Methods

get_reports(filters=None, fields=None, sort=None, limit=10, offset=0, presets=None)

Fetch reports from ReliefWeb API.

  • filters (dict, optional): Filtering parameters (e.g., { "country": { "eq": "ETH" } }).
  • fields (list, optional): Fields to include in results (e.g., ["id", "date", "title"]).
  • sort (list, optional): Sorting options (e.g., [{"date": "desc"}]).
  • limit (int, optional): Number of results to return.
  • offset (int, optional): Offset for pagination.
  • presets (list, optional): Presets to apply (e.g., ["expat"]).
  • Returns: dict (API response)

get_jobs(filters=None, fields=None, sort=None, limit=10, offset=0, presets=None)

Fetch jobs from ReliefWeb API.

  • Parameters and return value are the same as get_reports.

get_training(filters=None, fields=None, sort=None, limit=10, offset=0, presets=None)

Fetch training events from ReliefWeb API.

  • Parameters and return value are the same as get_reports.

Constructor: ReliefWebClient(api_key=None)

Initialize the client. If you have an API key, pass it as api_key.

Running Tests

To run the unit tests, use:

python -m unittest tests/test_client.py

Development & Testing

For development and testing, install all dependencies with:

pip install -r requirements-dev.txt

This will install tools for building, publishing, linting, and testing in addition to the runtime requirements.

Features

  • Simple interface for ReliefWeb API endpoints
  • Handles authentication and pagination

License

MIT

Maintainers & Contributors

To build and publish this package to PyPI:

  1. Install development tools:
    pip install build twine
    
  2. Build the package:
    python -m build
    
  3. Check the package:
    python -m twine check dist/*
    
  4. Publish to PyPI:
    python -m twine upload dist/*
    

Note: Only requests is required for end users. Build and publish tools are only needed for maintainers.

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

reliefweb-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

reliefweb-0.1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file reliefweb-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for reliefweb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e51ca0610e40757b830564c40e8b8b57bef0fbe1306b257d786a8e15aa86f3fd
MD5 fc0120cb85501853a185cea5098c7538
BLAKE2b-256 200fc1cb7cc075844c405b275cff1d2640239053fc7f5a87569143f4551edd49

See more details on using hashes here.

Provenance

The following attestation bundles were made for reliefweb-0.1.1.tar.gz:

Publisher: python-publish.yml on titusjoyson/reliefweb-python

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

File details

Details for the file reliefweb-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: reliefweb-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for reliefweb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f452f8cdcf9c5683d968a7f640a9605076f72eb53187fd23712b66a476a4fc9e
MD5 089872bd362918e928e5f361d3465f2c
BLAKE2b-256 f93004726c89cd2e33badecdadc210fcf4951157f5d7ec7f9787bf7849b16c64

See more details on using hashes here.

Provenance

The following attestation bundles were made for reliefweb-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on titusjoyson/reliefweb-python

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