Async REST
async_rest
Asynchronous X-Plane Web API access through REST.
Classes:
-
AsyncXPRestAPI–Opt-in asynchronous REST client for X-Plane Web API.
AsyncXPRestAPI
AsyncXPRestAPI(
host: str = "127.0.0.1",
port: int = 8086,
api: str = "/api",
api_version: str = "v1",
use_cache: bool = False,
retry_attempts: int = 1,
retry_backoff: float = 0.0,
retry_backoff_max: float = 5.0,
read_only: bool = False,
)
Opt-in asynchronous REST client for X-Plane Web API.
Methods:
-
aclose–Close the underlying async HTTP session.
-
capabilities–Fetch and cache API capabilities.
-
changed–If rounding applies, determine if value has changed.
-
command–Create a Command bound to this async API.
-
dataref–Create a Dataref bound to this async API.
-
dataref_value–Get dataref value through REST API.
-
execute_command–Execute command through REST API.
-
get_command_meta_by_id–Get cached command metadata by command identifier.
-
get_command_meta_by_name–Get cached command metadata by command path.
-
get_dataref_meta_by_id–Get cached dataref metadata by dataref identifier.
-
get_dataref_meta_by_name–Get cached dataref metadata by dataref name.
-
get_rest_meta–Get metadata from X-Plane through REST API for an object.
-
invalidate_caches–Remove cached metadata.
-
rest_api_reachable–Whether the REST API is reachable.
-
set_network–Set network and API parameters for connection.
-
set_roundings–Add rounding to simulator variable value change detection.
-
write_dataref–Write single dataref value through REST API.
Attributes:
-
connected(bool) –Whether the last async REST probe succeeded.
-
rest_url(str) –URL for the REST API.
-
status(CONNECTION_STATUS) –Connection status.
-
status_str(str) –Connection status as a string.
-
use_cache(bool) –Use cache for object metadata.
-
xp_version(str | None) –Returns reported X-Plane version from simulator.
connected
property
connected: bool
Whether the last async REST probe succeeded.
rest_url
property
rest_url: str
URL for the REST API.
status_str
property
status_str: str
Connection status as a string.
use_cache
property
writable
use_cache: bool
Use cache for object metadata.
xp_version
property
xp_version: str | None
Returns reported X-Plane version from simulator.
aclose
async
aclose() -> None
Close the underlying async HTTP session.
capabilities
async
capabilities() -> dict
Fetch and cache API capabilities.
changed
changed(dataref: str, value: Any) -> bool
If rounding applies, determine if value has changed.
dataref
dataref(path: str, auto_save: bool = False) -> Dataref
Create a Dataref bound to this async API.
dataref_value
async
dataref_value(
dataref: Dataref, raw: bool = False, no_decode: bool = False
) -> DatarefReadResult
Get dataref value through REST API.
execute_command
async
execute_command(command: Command, duration: float = 0.0) -> bool
Execute command through REST API.
get_command_meta_by_id
get_command_meta_by_id(ident: int) -> CommandMeta | None
Get cached command metadata by command identifier.
get_command_meta_by_name
get_command_meta_by_name(path: str) -> CommandMeta | None
Get cached command metadata by command path.
get_dataref_meta_by_id
get_dataref_meta_by_id(ident: int) -> DatarefMeta | None
Get cached dataref metadata by dataref identifier.
get_dataref_meta_by_name
get_dataref_meta_by_name(path: str) -> DatarefMeta | None
Get cached dataref metadata by dataref name.
get_rest_meta
async
get_rest_meta(
obj: Dataref | Command, force: bool = False
) -> DatarefMeta | CommandMeta | None
Get metadata from X-Plane through REST API for an object.
invalidate_caches
invalidate_caches() -> None
Remove cached metadata.
rest_api_reachable
async
rest_api_reachable() -> bool
Whether the REST API is reachable.
set_network
set_network(host: str, port: int, api: str, api_version: str) -> bool
Set network and API parameters for connection.
set_roundings
set_roundings(roundings: dict[str, int]) -> None
Add rounding to simulator variable value change detection.
write_dataref
async
write_dataref(dataref: Dataref) -> bool
Write single dataref value through REST API.