Skip to main content

A tool for working with local copies of the RepeaterBook database. Visit https://www.repeaterbook.com/wiki/doku.php?id=api for terms of use. In particular: "Use of the (RepeaterBook) data is for personal use only. The data cannot be fed to a commercial product for sale or otherwise."

Project description

hamkit.repeaterbook

PyPI - Version PyPI - Python Version


[!NOTE]
hamkit.repeaterbook is a small standalone component of hamkit. You can use it by itself (see below) if queries against the RepeaterBook database is all that you need. Alternatively, install the entire collection of HamKit modules with pip install hamkit.

[!TIP]
Even if you do not use RepeaterBook instances directly (e.g, if you want to run your own database queries), RepeaterBook.download() is useful for downloading and parsing the data into sqlite for local queries.

A simple library to work with a local copy of the RepeaterBook US & Canada database

pip install hamkit-repeaterbook

Download the RepeaterBook data, and load it into a sqlite database

import os
import logging
from hamkit.repeaterbook import RepeaterBook

logging.basicConfig(level=logging.DEBUG)

sources = [
    "https://www.repeaterbook.com/api/export.php?state=Washington",
    "https://www.repeaterbook.com/api/export.php?state=Washington&stype=gmrs",
]

# Download the database, if not already present
db_file = "repeaterbook.db"
if not os.path.isfile(db_file):
    RepeaterBook.download("repeaterbook.db", sources),

# Query information about a callsign
rb = RepeaterBook(db_file)
for r in rb.find_nearest(lat=47.658009, lon=-122.103288):
    print(f"{r}\n")

which will output the following:

Repeater(callsign='KC7IYE', downlink_freq=145.31, downlink_tone='', uplink_freq=144.71, uplink_tone='103.5', nearest_city='Redmond', landmark='', county='King', state='Washington', state_id='53', country='United States', latitude=47.67399979, longitude=-122.12200165, precise=0, use='OPEN', operational_status='On-air', fm_analog=1, ares=0, races=0, skywarn=0, canwarn=0, allstar_node='0', echoLink_node='', irlp_node='0', wires_node='', dmr=0, dmr_color_code='', dmr_id='', dstar=0, nxdn=0, apco_p25=0, p25_nac='', m17=0, m17_can='', tetra=0, tetra_mcc='', tetra_mnc='', system_fusion=0, ysf_dg_id_uplink='', ysf_dg_is_downlink='', ysf_dsc='', notes='', last_update='2021-07-06', distance=2.2639443534336845)

Repeater(callsign='KC7IYE', downlink_freq=53.07, downlink_tone='179.9', uplink_freq=51.37, uplink_tone='100.0', nearest_city='Redmond', landmark='', county='King', state='Washington', state_id='53', country='United States', latitude=47.6925, longitude=-122.1114, precise=0, use='OPEN', operational_status='On-air', fm_analog=1, ares=0, races=0, skywarn=0, canwarn=0, allstar_node='0', echoLink_node='0', irlp_node='0', wires_node='', dmr=0, dmr_color_code='', dmr_id='', dstar=0, nxdn=0, apco_p25=0, p25_nac='', m17=0, m17_can='', tetra=0, tetra_mcc='', tetra_mnc='', system_fusion=0, ysf_dg_id_uplink='', ysf_dg_is_downlink='', ysf_dsc='', notes='', last_update='2023-03-17', distance=3.8830227407299263)

Repeater(callsign='N7QT', downlink_freq=442.325, downlink_tone='103.5', uplink_freq=447.325, uplink_tone='103.5', nearest_city='Redmond', landmark='', county='King', state='Washington', state_id='53', country='United States', latitude=47.67459, longitude=-122.05393, precise=0, use='OPEN', operational_status='Unknown', fm_analog=1, ares=0, races=0, skywarn=0, canwarn=0, allstar_node='0', echoLink_node='0', irlp_node='0', wires_node='', dmr=1, dmr_color_code='2', dmr_id='311757', dstar=0, nxdn=0, apco_p25=0, p25_nac='', m17=0, m17_can='', tetra=0, tetra_mcc='', tetra_mnc='', system_fusion=0, ysf_dg_id_uplink='', ysf_dg_is_downlink='', ysf_dsc='', notes='', last_update='2023-12-15', distance=4.130456951733273)

...

In general, the operation is straightforward enough, but RepeaterBook.download() has numerous options, as per the following docstring:

"""
Download the RepeaterBook data and load it into a local sqlite database for querying.

Parameters:
    db_filename:  The location of the sqlite database to create.
    sources:      A list of URIs to download, or local file paths. Each URI or file
                  must resolve to a json file that uses the RepeaterBook format.
                  E.g.,
                    ["https://www.repeaterbook.com/api/export.php?state=Washington"]
                  Or
                    ["./cache/Washington.json"]

		  Repeated calls to repeaterbook.com are internally rate-limited to
		  one per minute.

                  CAUTION: each call to RepeaterBook will return a limited number
                           of records (at this time 3500). It is best to gather only
                           what you need, such as one state.
                           DO NOT MAKE FREQUENT CALLS, or you will be rate-limited or
                           blocked.

                  For details see: https://www.repeaterbook.com/wiki/doku.php?id=api

    overwrite:    If true, overwrite any existing file (Default: False)
"""

License

hamkit-repeaterbook is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hamkit_repeaterbook-0.0.1a1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

hamkit_repeaterbook-0.0.1a1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file hamkit_repeaterbook-0.0.1a1.tar.gz.

File metadata

File hashes

Hashes for hamkit_repeaterbook-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 a97ae40c2f030eebe20dd09222dbcf6e28afc685f8ea667156294c22638e893e
MD5 be016bca3cf6dc30c03e2e99b6d45f8b
BLAKE2b-256 3744d19bf16e1e7526c014cd3515eef6b82e8e8f2f328798d6bb4e036b93353f

See more details on using hashes here.

File details

Details for the file hamkit_repeaterbook-0.0.1a1-py3-none-any.whl.

File metadata

File hashes

Hashes for hamkit_repeaterbook-0.0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 66d2fc68ce94a46bcf1825b18b1213f4a051b5052e741fbc1eccc532e8028347
MD5 25872f77cb7173eb1f3fa378dd453630
BLAKE2b-256 65c1aea5d58b0f6f62fd7baa8e9c427f1bc99e661559b98c29adffff56c5a074

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page