python-alpaca-server
This is an easy to use Python server for ASCOM Alpaca. It can be run on any system that running Python 3.12 or higher, including a Raspberry Pi. This allows you to easily create new ASCOM Alpaca devices.
Nothing complicated here, just create a new class that implements your logic and inherits from one of the base device classes.
Then start up a new AlpacaServer. The server automatically enables discovery
as well.
Example
pip install python-alpaca-server
Edit app.py
from typing import List
from python_alpaca_server.app import AlpacaServer, Description
from python_alpaca_server.devices.safetymonitor import SafetyMonitor
from python_alpaca_server.errors import NotImplementedError
from python_alpaca_server.request import ActionRequest, CommandRequest, CommonRequest, PutConnectedRequest
# Inherit from the base SafetyMonitor class, and implement the methods.
class MySafetyMonitor(SafetyMonitor):
def __init__(self, unique_id: str):
super().__init__(unique_id)
self._connected = False
def put_action(self, req: ActionRequest) -> str:
raise NotImplementedError(req)
def put_command_blind(self, req: CommandRequest) -> None:
raise NotImplementedError(req)
def put_command_bool(self, req: CommandRequest) -> bool:
raise NotImplementedError(req)
def put_command_string(self, req: CommandRequest) -> str:
raise NotImplementedError(req)
def get_connected(self, req: CommonRequest) -> bool:
return self._connected
def put_connected(self, req: PutConnectedRequest) -> None:
self._connected = req.Connected
def get_description(self, req: CommonRequest) -> str:
return "My Description"
def get_driverinfo(self, req: CommonRequest) -> str:
return "My Driver Info"
def get_driverversion(self, req: CommonRequest) -> str:
return "0.1.0"
def get_interfaceversion(self, req: CommonRequest) -> int:
return 1
def get_name(self, req: CommonRequest) -> str:
return "MySafetyMonitor"
def get_supportedactions(self, req: CommonRequest) -> List[str]:
return []
def get_issafe(self, req: CommonRequest) -> bool:
if not self._connected:
return False
# TODO: Check something to see if we are safe to observe. Return True if safe.
return False
def get_server_description() -> Description:
return Description(
ServerName="MyServer",
Manufacturer="MyManufacturer",
ManufacturerVersion="0.1.0",
Location="MyLocation",
)
if __name__ == "__main__":
import uvicorn
port = 8000
# Choose a unique ID to pass into MySafetyMonitor. This ID should stay the same
# across server restarts.
svr = AlpacaServer(get_server_description, [MySafetyMonitor("other")])
# Create a FastAPI application we can attach to uvicorn or any other WSGI server.
app = svr.create_app(port)
try:
uvicorn.run(app, host="0.0.0.0", port=port)
except KeyboardInterrupt:
pass
Run
python app.py
ASCOM Alpaca Reference
- ASCOM Master Interface Documentation - Official API specifications for all device types
- Local OpenAPI specs in
docs/:AlpacaDeviceAPI_v1.yaml- Device API (camera, telescope, focuser, etc.)AlpacaManagementAPI_v1.yaml- Management API (discovery, configuration)
Metadata
Release files for python-alpaca-server 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_alpaca_server-2.0.0.tar.gz | 36.1 kB | Without provenance | Details for python_alpaca_server-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_alpaca_server-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for python_alpaca_server-2.0.0-py3-none-any.whl |
Total release size: 85.0 kB
Release files / python_alpaca_server-2.0.0.tar.gz
| Download URL | python_alpaca_server-2.0.0.tar.gz |
|---|---|
| Size | 36.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
edfce3a69703f049a2fea845a8f2d7b81a827b80907a469399600cda5fcff62c
|
|
BLAKE2b-256 checksum How to use checksums |
92ce7102ef9164b3d0c467e44fe4d2bdddb3da5d460293f9653be41ee96813da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.11.1 Darwin/24.6.0
|
Release files / python_alpaca_server-2.0.0-py3-none-any.whl
| Download URL | python_alpaca_server-2.0.0-py3-none-any.whl |
|---|---|
| Size | 48.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0855f47a8e7f5c15da2d69145046a4ee1222c55d9bde6ddc66c2a5a6c467a53b
|
|
BLAKE2b-256 checksum How to use checksums |
b1b9b96819076bd5ccf513f186e6a23227ec572fc6ac5e359bd8c60f40fd4e9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.11.1 Darwin/24.6.0
|
Security for python-alpaca-server 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.