Python client for querying publicly accessible soil profile and fertilizer recommendation workflows across Morocco.
turba-client
A Python client for querying publicly accessible soil profile and fertilizer recommendation workflows across Morocco.
Query site-level fertilizer recommendations from geographic coordinates, inspect available crops and yield-target ranges, and scale from one field to many with a clean Python API and CLI.
---
## Why `turba_client`?
`turba_client` is a production-friendly Python library that makes it easy to query **site-specific NPK fertilizer recommendations** from **fertimap.ma** using only a field location, with optional agronomic overrides.
It is designed for researchers, agronomists, and developers who want a reproducible way to move from:
- **coordinates**
- to **site context**
- to **available crops and yield targets**
- to **fertilizer recommendations**
- and finally to **batch processing and downstream analysis**
The library supports both **single-field workflows** and **multi-field pipelines**, with a clean Python interface and command-line support.
---
## What you can do with it
With `turba_client`, you can:
- query a site from its **longitude** and **latitude**
- inspect soil and administrative context returned for that site
- list the crops available at that location
- request recommendations for:
- one crop or many crops
- one target-yield level or many target-yield levels
- explicit numeric target yields
- override selected field values when needed:
- `crop_name`
- `target_yield_level`
- `ph`
- `matiere_organique_pct`
- `p_assimilable_mgkg_p2o5`
- `k_mgkg_k2o`
- process many fields at once from a DataFrame or CSV
- map user column names to the library schema before batch processing
---
## Installation
### From PyPI
```bash
pip install turba-client
````
### Development install
```bash
pip install -e .[dev]
```
---
## Quick start
```python
from turba_client import TurbaClient
client = TurbaClient()
df = client.get_recommendations(
longitude=-7.616,
latitude=33.589,
crop_name="Wheat (Rainfed)", …