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:
- Install development tools:
pip install build twine
- Build the package:
python -m build
- Check the package:
python -m twine check dist/*
- Publish to PyPI:
python -m twine upload dist/*
Note: Only
requestsis required for end users. Build and publish tools are only needed for maintainers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e162278e824088cc3bcd308ca8106894e99586bb5ece7c026094c04d788a8fe
|
|
| MD5 |
a1ee146fdae4129229f85a52ae3a825c
|
|
| BLAKE2b-256 |
5a641b989517cb628576db4442dbe5074dcd5fef24290b760c4be9623b261c79
|
Provenance
The following attestation bundles were made for reliefweb-0.1.4.tar.gz:
Publisher:
python-publish.yml on titusjoyson/reliefweb-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reliefweb-0.1.4.tar.gz -
Subject digest:
4e162278e824088cc3bcd308ca8106894e99586bb5ece7c026094c04d788a8fe - Sigstore transparency entry: 331651098
- Sigstore integration time:
-
Permalink:
titusjoyson/reliefweb-python@64aec62e1275257565c701b3eb78d1b90402fa29 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/titusjoyson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64aec62e1275257565c701b3eb78d1b90402fa29 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1f9370bdfdde58a8e6dc021978fd06c3829a5781aac51f89bf8d38971576f6f
|
|
| MD5 |
f4584f2d2bc797a089b29f8adb4578ea
|
|
| BLAKE2b-256 |
1d0ffc276a848f2043bff39362e78d088ff9dc13b7bf18b0661810b68b9c5a5e
|
Provenance
The following attestation bundles were made for reliefweb-0.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on titusjoyson/reliefweb-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reliefweb-0.1.4-py3-none-any.whl -
Subject digest:
e1f9370bdfdde58a8e6dc021978fd06c3829a5781aac51f89bf8d38971576f6f - Sigstore transparency entry: 331651119
- Sigstore integration time:
-
Permalink:
titusjoyson/reliefweb-python@64aec62e1275257565c701b3eb78d1b90402fa29 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/titusjoyson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64aec62e1275257565c701b3eb78d1b90402fa29 -
Trigger Event:
release
-
Statement type: