> ## Documentation Index
> Fetch the complete documentation index at: https://www.worldmonitor.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Armed Conflicts by Country in Python

> Fetch active armed conflicts by country in Python using worldmonitor-sdk, REST /api/conflict/v1/list-ucdp-events, and zero-key sandbox fixtures.

Use this guide to print active armed conflicts by country in Python with the official zero-dependency `worldmonitor-sdk` package (note: PyPI's `worldmonitor` package is unrelated).

## 1. Install and run with `worldmonitor-sdk`

```bash theme={null}
pip install worldmonitor-sdk
```

```python theme={null}
import os
from worldmonitor_sdk import Client

# Pass api_key="wm_..." or set WORLDMONITOR_API_KEY in the environment.
client = Client(api_key=os.environ["WORLDMONITOR_API_KEY"])

# Pull georeferenced UCDP violence events for a country (ISO 3166-1 alpha-2).
payload = client.get(
    "/api/conflict/v1/list-ucdp-events",
    country="UA",
    jmespath="{version: candidateVersion, events: events[0:10].{id: id, country: country, deathsBest: deathsBest, dateStart: dateStart}}",
)

print(f"UCDP candidate version: {payload.get('version')}")
for event in payload.get("events", []):
    print(f"{event['country']} | deaths={event['deathsBest']} | start_ms={event['dateStart']} | id={event['id']}")
```

To fetch combined conflict events (UCDP, unrest, and regional feeds) through the MCP tool surface instead of a single REST route, pass the **country name** (such as `"Ukraine"`) rather than an ISO alpha-2 code: unlike `/api/conflict/v1/list-ucdp-events`, `get_conflict_events` matches `country` against event country names (`"UA"` matches risk scores by region code but drops Ukraine's event rows):

```python theme={null}
result = client.conflict_events(country="Ukraine", limit=10)
print(result)
```

## 2. Try without an API key (public discovery and sandbox)

Before issuing a key at [worldmonitor.app/pro](https://www.worldmonitor.app/pro), you can test SDK connectivity via keyless MCP discovery and run credential-free HTTP smoke tests against static sandbox fixtures (or cache the JSON locally for network-isolated CI). Keep them separate in CI: anonymous MCP discovery does not consume a daily quota, but it is still IP rate-limited (10 calls/minute per IP), whereas static sandbox fixtures are safe for unlimited CI runs.

**Keyless MCP discovery** (verify SDK setup with no API key):

```python theme={null}
from worldmonitor_sdk import Client

public_client = Client()
sources = public_client.call_tool("get_sources", view="summary")
print("Active source summary keys:", list(sources.keys()) if isinstance(sources, dict) else type(sources).__name__)
```

**Deterministic sandbox fixture** (zero credentials, safe for parallel CI; note that `sandbox/index.json` currently publishes a fixture for `get-country-risk.json` rather than `ListUcdpEvents`, so this validates the HTTP client and sandbox envelope rather than the UCDP event parser in Section 1):

```python theme={null}
import json
import urllib.request

req = urllib.request.Request(
    "https://www.worldmonitor.app/sandbox/get-country-risk.json",
    headers={"User-Agent": "worldmonitor-python-guide/1.0 (+https://www.worldmonitor.app)"},
)
with urllib.request.urlopen(req, timeout=15) as response:
    fixture = json.loads(response.read().decode("utf-8"))

print("Sandbox operation:", fixture["operation"]["productionUrl"])
print("Sample envelope keys:", list(fixture["response"]["body"].keys()))
```

See [Sandbox & Test Environment](https://www.worldmonitor.app/docs/sandbox.md) for the complete fixture index at `https://www.worldmonitor.app/sandbox/index.json`.

## 3. Direct REST call without the SDK

If you prefer plain `urllib` or `requests`, send a descriptive `User-Agent` and `X-WorldMonitor-Key`:

```bash theme={null}
curl -sS "https://api.worldmonitor.app/api/conflict/v1/list-ucdp-events?country=UA&jmespath=events%5B0%3A5%5D" \
  -H "X-WorldMonitor-Key: $WORLDMONITOR_API_KEY" \
  -H "User-Agent: my-conflict-script/1.0 (+https://example.com)"
```

## When to use World Monitor vs raw UCDP CSV

* **Use UCDP directly** ([ucdp.uu.se](https://ucdp.uu.se/apidocs/)) when you only need bulk historical CSV downloads under CC BY 4.0 for academic research and do not mind requesting a UCDP token or handling pagination yourself.
* **Use World Monitor** when your script or agent needs cached UCDP GED + monthly Candidate conflict events alongside GDELT escalation signals, Country Instability Index scores (`/api/intelligence/v1/get-country-risk`), shipping disruptions, and server-side [JMESPath projection](https://www.worldmonitor.app/docs/mcp-jmespath.md) under one API key or MCP server.
* Note on ACLED: hosted `worldmonitor.app` does not redistribute ACLED data; conflict scoring combines UCDP conflict floors with GDELT escalation ratios. See [CII Risk Scoring Methodology](https://www.worldmonitor.app/docs/methodology/cii-risk-scores.md) and [API Reference](https://www.worldmonitor.app/docs/api-reference.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.