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 .

Supported Endpoints

  • reports
  • disasters
  • jobs
  • training
  • sources
  • countries
  • blog
  • books
  • references

Usage

from reliefweb.client import ReliefWebClient
from reliefweb.fields import get_fields_for_type

# 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)

# Fetch blog
blog = client.get_blog(limit=5)
print("Blog:", blog)

# Fetch books
books = client.get_books(limit=5)
print("Books:", books)

# Fetch references
references = client.get_references(limit=5)
print("References:", references)

# Fetch disasters
disasters = client.get_disasters(limit=5, fields=get_fields_for_type("disasters"))
print("Disasters:", disasters)

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.

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

Fetch blog posts from ReliefWeb API.

  • Parameters and return value are the same as get_reports.

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

Fetch books from ReliefWeb API.

  • Parameters and return value are the same as get_reports.

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

Fetch references from ReliefWeb API.

  • Parameters and return value are the same as get_reports.

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

Fetch disasters 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.4.tar.gz (5.7 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.4-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reliefweb-0.1.4.tar.gz
  • Upload date:
  • Size: 5.7 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.4.tar.gz
Algorithm Hash digest
SHA256 4e162278e824088cc3bcd308ca8106894e99586bb5ece7c026094c04d788a8fe
MD5 a1ee146fdae4129229f85a52ae3a825c
BLAKE2b-256 5a641b989517cb628576db4442dbe5074dcd5fef24290b760c4be9623b261c79

See more details on using hashes here.

Provenance

The following attestation bundles were made for reliefweb-0.1.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: reliefweb-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 3.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e1f9370bdfdde58a8e6dc021978fd06c3829a5781aac51f89bf8d38971576f6f
MD5 f4584f2d2bc797a089b29f8adb4578ea
BLAKE2b-256 1d0ffc276a848f2043bff39362e78d088ff9dc13b7bf18b0661810b68b9c5a5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for reliefweb-0.1.4-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