<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# API Reference — Dark Web Reconnaissance

## Tor

### Service Control
```bash
sudo systemctl start tor
sudo systemctl status tor
```

### Connectivity Check
```bash
torsocks curl -s https://check.torproject.org/api/ip
```

### SOCKS Proxy Config
```
SOCKS5: 127.0.0.1:9050
Control Port: 127.0.0.1:9051
```

### Python via Tor
```python
import requests
proxies = {"http": "socks5h://127.0.0.1:9050", "https": "socks5h://127.0.0.1:9050"}
resp = requests.get("http://example.onion/", proxies=proxies, timeout=30)
```

## Ahmia.fi

### Search
```bash
curl -s "https://ahmia.fi/search/?q=example.com"
```

### API
```bash
curl -s "https://ahmia.fi/api/search/?q=example.com" | jq '.results[].url'
```

## DarkSearch.io

### Search API
```bash
curl -s "https://darksearch.io/api/search?query=example.com&page=1"
```

### Response Fields
```json
{"total": 100, "data": [{"title": "...", "link": "http://...onion/", "description": "..."}]}
```

## IntelligenceX API

### Search
```bash
curl -s -H "x-key: $INTELX_KEY" \
  "https://2.intelx.io/intelligent/search" \
  -d '{"term": "example.com", "maxresults": 100}'
```

### Get Results
```bash
curl -s -H "x-key: $INTELX_KEY" \
  "https://2.intelx.io/intelligent/search/result?id=$SEARCH_ID"
```

### Media Types
```
0 - All
1 - Paste sites
2 - Dark web
3 - Public web
24 - Dark web (Tor)
```

## OnionScan

### Basic Scan
```bash
onionscan --verbose http://example.onion
```

### JSON Report
```bash
onionscan --jsonreport report.json http://example.onion
```

## stem (Tor Control Library)

### List Circuits
```python
from stem.control import Controller
with Controller.from_port(port=9051) as ctrl:
    ctrl.authenticate()
    for circ in ctrl.get_circuits():
        print(circ.status, circ.path)
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| `INTELX_API_KEY` | IntelligenceX API key |
| `TOR_SOCKS_PORT` | Tor SOCKS port (default: 9050) |
| `TOR_CONTROL_PORT` | Tor control port (default: 9051) |
