FAQ¶
Frequently asked questions about the RepeaterBook Python Client.
General Questions¶
Is this an official RepeaterBook.com project?¶
No. RepeaterBook Python Client is an independent, community-maintained library that provides programmatic access to RepeaterBook.com's public API. It is not affiliated with, endorsed by, or officially supported by RepeaterBook.com.
What is the RepeaterBook Python Client?¶
The RepeaterBook Python Client is an unofficial, third-party Python library that provides programmatic access to the RepeaterBook.com database of amateur radio repeaters worldwide. It allows you to download, query, and analyze repeater data for various amateur radio applications.
Do I need an API key?¶
Yes. As of RepeaterBook's 2026-03-03 API policy, the export endpoints require an approved per-user API token (an rbuapp_... token), sent via the X-RB-App-Token header.
Getting one takes about a minute, and you do not need to register an application — this library is already registered as RepeaterBook Python Client (App #114):
- Create a free RepeaterBook account, or log in to an existing one.
- Go to API Applications.
- Find RepeaterBook Python Client (App #114) and generate a token for it.
- Pass the resulting
rbuapp_...token toRepeaterBookAPI, ideally from an environment variable:
import os
from repeaterbook.services import RepeaterBookAPI
api = RepeaterBookAPI(app_token=os.environ["REPEATERBOOK"])
The default User-Agent already matches App #114, so the token works as-is — don't override app_name, app_version, or app_contact. See the Authentication guide for details.
Never share or distribute a token. This library is a distributed client: each user generates their own token against App #114. RepeaterBook's policy prohibits embedding a shared app_... token in source code, installers, or public repositories.
Please also be respectful of their servers by:
- Using the built-in caching (enabled by default)
- Not making excessive requests
- Respecting the cache TTL
What data is available?¶
RepeaterBook.com provides comprehensive repeater data including:
- Frequencies (input/output)
- Location (lat/lon)
- Callsign and trustee
- Access tones (CTCSS/DCS)
- Digital mode capabilities (DMR, P25, NXDN, etc.)
- Network affiliations
- Status and access type
- Notes and additional information
Is the data accurate?¶
The data comes directly from RepeaterBook.com, which is community-maintained. Accuracy varies by region and how recently the information was updated. Always verify critical information (especially for emergency communications) through local sources.
Which countries are supported?¶
RepeaterBook covers repeaters worldwide. Major coverage includes:
- North America: USA, Canada, Mexico
- Europe: Most European countries
- Asia: Japan, South Korea, Taiwan, and others
- Oceania: Australia, New Zealand
- South America: Brazil, Argentina, Chile, and others
- Africa: South Africa and others
ExportQuery.countries takes pycountry country objects, and the query sends
each country's name — so the lookup has to succeed before the query can.
pycountry.countries.get(name=...) matches the official name exactly and
returns None otherwise, which is easy to trip over:
import pycountry
pycountry.countries.get(name="South Korea") # -> None
pycountry.countries.search_fuzzy("South Korea")[0] # -> Korea, Republic of
Prefer get(alpha_2="KR") when you know the code, and fall back to
search_fuzzy() for free-form names.
Installation Issues¶
ModuleNotFoundError: No module named 'repeaterbook'¶
Make sure you've installed the package:
If using a virtual environment, ensure it's activated:
ImportError with SQLModel or aiohttp¶
These are dependencies that should be installed automatically. Try:
Or install dependencies explicitly:
SSL Certificate Errors¶
On some systems (especially macOS), you may encounter SSL errors. Install certificates:
Or upgrade certifi:
Usage Issues¶
asyncio.run() gives "Event loop is closed" error¶
This happens when running in Jupyter notebooks. Use this pattern instead:
# In Jupyter/IPython
await api.download(query=ExportQuery(countries={brazil}))
# In regular Python scripts
import asyncio
asyncio.run(api.download(query=ExportQuery(countries={brazil})))
Database file is locked¶
This occurs when multiple processes access the same database. Solutions:
- Use different database files for concurrent access
- Close the handle when you are done -- use
RepeaterBookas a context manager, or callclose()-- so the file is free for whatever comes next - Use a single RepeaterBook instance per database file
# Good
with RepeaterBook(database="repeaters.db") as rb:
results1 = rb.query(...)
results2 = rb.query(...)
# Bad (multiple instances to same file)
rb1 = RepeaterBook(database="repeaters.db")
rb2 = RepeaterBook(database="repeaters.db") # May cause lock
Queries return empty results¶
Check:
- Data exists: Have you populated the database?
# Check if database has data
all_repeaters = rb.query()
print(f"Database has {len(all_repeaters)} repeaters")
- Query conditions are correct:
# Use Status enum, not strings
from repeaterbook.models import Status
results = rb.query(Repeater.operational_status == Status.ON_AIR)
- Geographic bounds are reasonable:
Cache not working¶
The cache should work automatically. To debug:
import asyncio
import os
from repeaterbook.services import RepeaterBookAPI
async def inspect_cache():
api = RepeaterBookAPI(app_token=os.environ["REPEATERBOOK"])
# `cache_dir()` is an async method -- it creates the directory on first
# call -- not a plain attribute.
cache = await api.cache_dir()
print(f"Cache dir: {cache}")
# Entries are named `api_cache_<sha256-of-url>.json`, one per request URL.
# A query that fans out to both the NA and ROW endpoints yields two.
print(f"Cache files: {[p.name async for p in cache.iterdir()]}")
asyncio.run(inspect_cache())
To clear the cache, from code:
This deletes only the entries the library wrote, leaves the directory and its
.gitignore in place, and is a no-op that returns 0 if nothing was ever
cached. Or, from a shell:
Either way, the next request for any URL goes to the network. Note that this is separate from the SQLite database — see How do I start over with fresh data?.
Distance calculations seem wrong¶
Verify:
- Units: Default is kilometers
# Use miles instead
from haversine import Unit
radius = Radius(origin=location, distance=50, unit=Unit.MILES)
- Coordinates: Ensure lat/lon are correct
# Check repeater coordinates
for rep in results:
print(f"{rep.callsign}: {rep.latitude}, {rep.longitude}")
- Use filter_radius() after square():
Performance Issues¶
Download is very slow¶
- Check internet connection: API depends on network speed
- Use cache: Subsequent requests use cached data
- Limit scope: Download specific states/regions instead of entire countries
# Instead of entire USA
query = ExportQuery(countries={usa}) # Slow!
# Download specific states
query = ExportQuery(countries={usa}, state_ids={"06"}) # California (FIPS code)
Queries are slow¶
- Use square() before filter_radius():
# Efficient
candidates = rb.query(square(radius)) # Fast: SQL indexed
nearby = filter_radius(candidates, radius) # Slower: but fewer items
# Inefficient
all_reps = rb.query() # Gets everything
nearby = filter_radius(all_reps, radius) # Slow: calculates all distances
- Add query conditions to limit results:
# Add more filters to reduce result set
results = rb.query(
square(radius),
Repeater.operational_status == Status.ON_AIR, # Filters out off-air
band(Bands.M_2) # Only 2m band
)
- Use LIMIT for large result sets:
from sqlmodel import Session, select
# `RepeaterBook` opens a session per call internally and exposes the engine,
# so build your own `Session` when you need a statement it can't express.
# Keep it inside the `with rb:` block: `rb.close()` disposes the engine, and
# a session built on it should be finished with before that happens.
statement = select(Repeater).limit(100)
with RepeaterBook(database="repeaters.db") as rb:
with Session(rb.engine) as session:
results = session.exec(statement).all()
Database is getting large¶
The SQLite database can grow with many repeaters. To optimize:
# Compact database
import sqlite3
conn = sqlite3.connect('repeaterbook.db')
conn.execute('VACUUM')
conn.close()
Or start fresh — see the next question.
How do I start over with fresh data?¶
There are two things on disk, and "fresh" usually means clearing both:
- The database (
repeaterbook.db) holds the repeaters. - The response cache (
.repeaterbook_cache/) holds raw API responses for up tomax_cache_age(an hour by default). Adownload()whose response is still cached is served from that file, not from RepeaterBook.
Emptying only the database therefore does not get you new data: the next
populate() refills it from the cached response, with the same rows you just
removed. Clear both:
import asyncio
import os
from repeaterbook import RepeaterBook
from repeaterbook.services import RepeaterBookAPI
async def start_over():
api = RepeaterBookAPI(app_token=os.environ["REPEATERBOOK"])
with RepeaterBook() as rb:
# Cache first: if this fails, the rows are still there, rather than
# an empty store sitting next to a cache that would silently refill it.
responses = await api.clear_cache()
repeaters = rb.truncate()
print(f"Removed {repeaters} repeaters and {responses} cached responses")
asyncio.run(start_over())
truncate() empties the table but keeps the file and its schema marker, so the
next open sees a current, empty database rather than one to discard. Both calls
are safe to repeat and safe on a working directory nothing was ever written to;
they simply report 0.
The equivalent from a shell is rm repeaterbook.db .repeaterbook_cache/api_cache_*.
The MCP server exposes the same operation as its
clear_local_data tool.
My database is suddenly empty after upgrading¶
That is deliberate. The database is a cache of re-downloadable data, so rather
than migrate it across a schema change, the library discards it and starts
clean — you will see a Discarding cached database warning explaining why.
Call populate() again to refill it.
Each file stores a fingerprint of the schema that wrote it, derived from the models themselves. If that no longer matches the running version, the file cannot be read back correctly (an old text column read as a boolean, say, is worse than no data at all), so it goes.
API Questions¶
Why am I getting 401 or 403 from the API?¶
| Error | Cause | Fix |
|---|---|---|
401 auth_missing |
No token was sent | Pass app_token=os.environ["REPEATERBOOK"] |
401 auth_invalid |
Token wrong, revoked, or expired | Regenerate it on API Applications |
403 ua_mismatch |
User-Agent doesn't match the application the token was issued for |
Remove your app_name / app_version / app_contact overrides |
ua_mismatch is the common one. A token generated against RepeaterBook Python Client (App #114) is only valid alongside that application's registered User-Agent, which this library sends by default. Overriding any part of it — even just app_contact, to your own address — breaks the match. See the Authentication guide.
Do I need to register my own application with RepeaterBook?¶
No. This library ships registered as RepeaterBook Python Client (App #114); generate a token against it from API Applications and use the library's default User-Agent.
Register your own only if you're building a separate product with its own identity. Then override app_name, app_version, and app_contact to match your registration exactly, and use a token issued for it.
What's the difference between export.php and exportROW.php?¶
- export.php: North America (USA, Canada, Mexico)
- exportROW.php: Rest of World (all other countries)
The library automatically selects the correct endpoint based on your query.
How often should I refresh data?¶
Repeater data doesn't change frequently. Recommended refresh intervals:
- Active development: 1 hour (default cache TTL)
- Production apps: 24 hours or longer
- Static analysis: Download once, use indefinitely
from datetime import timedelta
# Set longer cache for production
api = RepeaterBookAPI(max_cache_age=timedelta(hours=24))
Can I download all repeaters worldwide?¶
Yes, but it's a lot of data and takes time. Consider:
import pycountry
# All countries (slow, large)
all_countries = set(pycountry.countries)
# Download in batches...
Better approach: Download by region as needed.
Rate limiting?¶
RepeaterBook doesn't publicly document rate limits, but be respectful:
- ✅ Use caching (enabled by default)
- ✅ Download once, query many times
- ✅ Download specific regions, not everything
- ❌ Don't make rapid-fire requests
- ❌ Don't abuse the API
Data Questions¶
Why are some repeaters missing expected fields?¶
Not all repeaters have complete information. Always check for None:
if rep.dmr_id:
print(f"DMR ID: {rep.dmr_id}")
else:
print("DMR ID not available")
# Or use getattr with default
dmr_id = getattr(rep, 'dmr_id', 'Unknown')
How do I handle unknown/missing coordinates?¶
Some repeaters have imprecise or missing coordinates:
# Filter for precise coordinates
results = rb.query(Repeater.precise == True)
# Check before using
if rep.latitude and rep.longitude:
# Use coordinates
pass
What does "UNKNOWN" status mean?¶
Status.UNKNOWN means the operational status hasn't been verified or reported. It doesn't necessarily mean the repeater is off-air.
For critical applications, prefer:
Why is DMR color code sometimes None?¶
Not all DMR repeaters report their color code. Note that the dmr_color_code field is a string, not an integer. Common defaults:
- Color Code 1: Most common default
- Color Code 2: Also common
When programming radios, try CC1 first if unknown.
How are analog and digital flags set?¶
These are capability flags:
analog_capable=True: Supports FM analogdmr_capable=True: Supports DMRapco_p_25_capable=True: Supports P25- etc.
A repeater can have multiple flags (e.g., dual-mode).
Integration Questions¶
Can I use this with Flask/Django/FastAPI?¶
Yes! See the Examples page for a Flask integration example.
Key considerations:
- Initialize once: Create
RepeaterBookinstance at startup - Async support: FastAPI works great with async/await
- Database per app: Don't share database files across applications
Can I export to CSV/JSON?¶
Yes:
import pandas as pd
import json
results = rb.query(...)
# CSV with pandas
df = pd.DataFrame([r.model_dump() for r in results])
df.to_csv('repeaters.csv', index=False)
# JSON
data = [r.model_dump() for r in results]
with open('repeaters.json', 'w') as f:
json.dump(data, f, indent=2, default=str)
Can I use this in a mobile app?¶
The library is designed for Python. For mobile apps:
- Python backend: Create a REST API using Flask/FastAPI
- Direct integration: Use frameworks like Kivy or BeeWare
- Alternative: Use RepeaterBook API directly in your mobile code
How do I integrate with radio programming software?¶
Most radio programming software accepts CSV imports. See the codeplug example for details.
Development Questions¶
How do I contribute?¶
See CONTRIBUTING.md for detailed guidelines.
Quick start:
- Fork the repository
- Clone your fork
- Create a feature branch
- Make changes
- Run tests:
pytest --cov - Submit a pull request
How do I run tests?¶
# Install dev dependencies. Dev tooling lives in dependency *groups*; the
# `mcp` extra is separate, so ask for both.
uv sync --all-extras --all-groups
# Run tests
pytest
# With coverage
pytest --cov --cov-report=html
# Run specific test
pytest tests/test_repeaterbook.py
How do I build documentation?¶
# Run from the repository root -- `mkdocs.yml` lives there, not in `docs/`.
mkdocs serve # Live preview at http://127.0.0.1:8000
# Or using Nox
nox -s docs_serve
Where do I report bugs?¶
Please report bugs on GitHub Issues.
Include:
- Python version
- Operating system
- Error message and stack trace
- Minimal code to reproduce
Error Handling¶
What exceptions does the RepeaterBook Python Client raise?¶
The RepeaterBook Python Client uses a hierarchy of custom exceptions:
| Exception | When Raised |
|---|---|
RepeaterBookError |
Base exception for all library errors |
RepeaterBookAPIError |
Any HTTP 4xx/5xx other than 401/403/429, or a 200 response whose body reports an error |
RepeaterBookUnauthorizedError |
HTTP 401 — missing or invalid app token |
RepeaterBookForbiddenError |
HTTP 403 — User-Agent or authorization denied |
RepeaterBookRateLimitError |
HTTP 429 — rate limited; carries retry_after |
RepeaterBookValidationError |
Invalid data or response format |
RepeaterBookRowError |
A single export row could not be modelled |
RepeaterBookCacheError |
The response could not be cached — a full disk or an unwritable working directory. A cache entry that is merely missing or corrupt is not an error: it is treated as a miss and refetched |
How do I handle errors properly?¶
from repeaterbook import (
RepeaterBookError,
RepeaterBookAPIError,
RepeaterBookValidationError,
)
try:
repeaters = await api.download(query=query)
except RepeaterBookAPIError as e:
print(f"API error: {e}")
except RepeaterBookValidationError as e:
print(f"Invalid data: {e}")
except RepeaterBookError as e:
print(f"Library error: {e}")
Why did I get a validation error?¶
The Repeater model validates data automatically:
- Latitude must be between -90 and 90
- Longitude must be between -180 and 180
- Frequency must be positive
A single row that fails these checks does not fail a download. The data is
community-maintained and bad rows do occur, so download() logs and skips them
and returns everything else. You'll see a warning like:
Skipping unmodellable repeater 48:24371 (W5AW): Frequency must be positive, got 0.00000
Skipped 1 unmodellable of 1669 repeaters: 48:24371 (W5AW)
How do I find out which rows were skipped?¶
Pass a list for skipped and inspect it afterwards:
from repeaterbook.exceptions import RepeaterBookRowError
skipped: list[RepeaterBookRowError] = []
repeaters = await api.download(query, skipped=skipped)
print(f"{len(repeaters)} usable, {len(skipped)} dropped")
for error in skipped:
print(error.label, "->", error)
Each entry keeps the offending payload on error.row, which is what you'd
attach when reporting the record to RepeaterBook.
Can I make malformed rows an error instead?¶
Yes — pass strict=True and the first unmodellable row raises
RepeaterBookRowError instead of being skipped:
Troubleshooting¶
Enable debug logging¶
from loguru import logger
import sys
logger.add(sys.stdout, level="DEBUG")
# Now see detailed logs
repeaters = await api.download(query=ExportQuery(countries={brazil}))
Check database contents¶
sqlite3 repeaterbook.db
# List tables
.tables
# Show schema
.schema repeater
# Query data
SELECT COUNT(*) FROM repeater;
SELECT * FROM repeater LIMIT 5;
Verify API response¶
The API rejects unauthenticated requests, so a raw check has to send the same
identity the library does — both the approved User-Agent and the token.
Reuse api.headers rather than hand-rolling them, so the User-Agent keeps
matching the application your token was issued for:
import aiohttp
import asyncio
import os
from repeaterbook.services import RepeaterBookAPI
async def test_api():
api = RepeaterBookAPI(app_token=os.environ["REPEATERBOOK"])
url = "https://repeaterbook.com/api/export.php?country=Brazil"
async with aiohttp.ClientSession(headers=dict(api.headers)) as session:
async with session.get(url) as response:
print(f"Status: {response.status}")
data = await response.json()
# An error payload carries `status`/`message` instead of `results`.
if "results" not in data:
print(f"API error: {data}")
return
print(f"Repeaters: {len(data['results'])}")
asyncio.run(test_api())
Still Having Issues?¶
- Check the Examples page for working code
- Review the API Reference for detailed documentation
- Search GitHub Issues
- Ask for help on Discord