Important
This is still a work in progress — while mostly functional, it may produce unexpected results.
A WeeWX extension that provides a lightweight API interface using the FastAPI framework.
- Python 3.11 or later
- WeeWX v4 or later
- FastAPI 0.116.0 or later
- requests 2.32.0 or later
-
Install FastAPI and requests packages
$ pip install "fastapi[standard]" requests -
Install the extension with
weectl extensionWeeWX 5.0+
$ weectl extension install https://github.com/HumphreysCarter/weewx-fastapi/releases/latest/download/weewx-fastapi.zip
WeeWX v4.0
$ weectl extension --install https://github.com/HumphreysCarter/weewx-fastapi/releases/latest/download/weewx-fastapi.zip
-
Restart WeeWX
The API server will run automatically whenever WeeWX is running via Uvicorn. FastAPI will automatically produce interactive API documentation, which by default, it is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
The API server is configured via the DataAPI section of the weewx.conf file.
[DataAPI]
enabled = True
server_host = localhost
server_port = 8000
prism_normals = False- Use the
enabledoption to either enable or disable the API server. - The server host and port number can be set with the
server_hostandserver_portsettings. To enable all network interfaces, setserver_hostto0.0.0.0. - 30-year normals for precipitation and temperature can also be retrieved for your location from the PRISM Group at Oregon State University by setting
prism_normalstoTrue. This is only available for areas within the continental United States.