Skip to content

Commit c7765d1

Browse files
committed
docs: mention the new WokwiClientSync + update changelog
1 parent 0e314f2 commit c7765d1

File tree

8 files changed

+75
-15
lines changed

8 files changed

+75
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.1.0 - 2025-08-22
4+
5+
- feat: add WokwiClientSync - a synchronous Wokwi client (#9)
6+
37
## 0.0.9 - 2025-08-21
48

59
- feat: add gpio_list method to retrieve all GPIO pins in WokwiClient (#6)

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# Wokwi Python Client 🚀
22

3-
Typed, asyncio-friendly Python SDK for the **Wokwi Simulation API**
3+
Typed Python SDK for the **Wokwi Simulation API** with both async and synchronous interfaces
44

55
[![PyPI version](https://img.shields.io/pypi/v/wokwi-client?logo=pypi)](https://pypi.org/project/wokwi-client/)
66
[![Python versions](https://img.shields.io/pypi/pyversions/wokwi-client)](https://pypi.org/project/wokwi-client/)
77
[![CI](https://github.com/wokwi/wokwi-python-client/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/wokwi/wokwi-python-client/actions/workflows/ci.yaml)
88
[![License: MIT](https://img.shields.io/github/license/wokwi/wokwi-python-client)](LICENSE)
99

10-
> **TL;DR:** Run and control your Wokwi simulations from Python with first-class type hints and zero boilerplate.
10+
> **TL;DR:** Run and control your Wokwi simulations from Python with first-class type hints, zero boilerplate, and both async and synchronous APIs.
1111
1212
---
1313

1414
Wokwi is a platform for creating and running simulations of electronic circuits and embedded systems. It supports a wide range of hardware platforms, including ESP32 family, Arduino, Raspberry Pi, STM32 and more.In addition, it supports a [wide range of peripherals](https://docs.wokwi.com/getting-started/supported-hardware), including sensors, displays, motors, and debugging tools.
1515

16-
Wokwi Python Client is a Python SDK for the Wokwi Simulation API. It allows you to run and control your Wokwi simulations from Python in a typed, asyncio-friendly way. You can use it to automate your embedded testing and development workflows.
16+
Wokwi Python Client is a Python SDK for the Wokwi Simulation API. It provides two client interfaces:
17+
18+
- **`WokwiClient`**: Async client with full asyncio support for modern Python applications
19+
- **`WokwiClientSync`**: Synchronous client that mirrors the async API for traditional blocking code
20+
21+
Both clients allow you to run and control your Wokwi simulations from Python in a typed, easy-to-use way. You can use them to automate your embedded testing and development workflows.
1722

1823
## Installation requirements
1924

@@ -27,20 +32,31 @@ pip install wokwi-client
2732

2833
## Running the examples
2934

30-
The basic example is in the [examples/hello_esp32/main.py](examples/hello_esp32/main.py) file. It shows how to:
35+
### Async Example
36+
37+
The basic async example is in the [examples/hello_esp32/main.py](examples/hello_esp32/main.py) file. It shows how to:
3138

3239
- Connect to the Wokwi Simulator
3340
- Upload a diagram and firmware files
3441
- Start a simulation
3542
- Monitor serial output asynchronously
3643

37-
You can run the example with:
44+
You can run the async example with:
3845

3946
```bash
4047
pip install -e .[dev]
4148
python -m examples.hello_esp32.main
4249
```
4350

51+
### Sync Example
52+
53+
The synchronous example is in the [examples/hello_esp32_sync/main.py](examples/hello_esp32_sync/main.py) file. It demonstrates the same functionality using the blocking `WokwiClientSync`:
54+
55+
```bash
56+
pip install -e .[dev]
57+
python -m examples.hello_esp32_sync.main
58+
```
59+
4460
For more examples, see the [examples](examples) directory.
4561

4662
## Documentation

docs/index.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Wokwi Python Client Library
22

3-
Typed, asyncio-friendly Python SDK for the **Wokwi Simulation API**.
3+
Typed Python SDK for the **Wokwi Simulation API** with both async and synchronous interfaces.
44

55
## Features
66

@@ -9,7 +9,8 @@ Typed, asyncio-friendly Python SDK for the **Wokwi Simulation API**.
99
- Start, pause, resume, and restart simulations
1010
- Monitor serial output asynchronously and write to them
1111
- Control peripherals and read GPIO pins
12-
- Fully type-annotated and easy to use with asyncio
12+
- Fully type-annotated
13+
- Two client interfaces: `WokwiClient` (async) and `WokwiClientSync` (sync)
1314

1415
## Installation
1516

@@ -23,7 +24,9 @@ pip install wokwi-client
2324

2425
Get your API token from [https://wokwi.com/dashboard/ci](https://wokwi.com/dashboard/ci).
2526

26-
## Quickstart Example
27+
## Quickstart Examples
28+
29+
### Async Client (WokwiClient)
2730

2831
```python
2932
import asyncio
@@ -55,7 +58,41 @@ if __name__ == "__main__":
5558
asyncio.run(main())
5659
```
5760

58-
See the [examples/hello_esp32/main.py](https://github.com/wokwi/wokwi-python-client/blob/main/examples/hello_esp32/main.py) for a full example including serial monitoring, and [examples/micropython_esp32/main.py](https://github.com/wokwi/wokwi-python-client/blob/main/examples/micropython_esp32/main.py) for an example of running MicroPython on a simulated ESP32 board.
61+
For a complete example, see [examples/hello_esp32/main.py](https://github.com/wokwi/wokwi-python-client/blob/main/examples/hello_esp32/main.py).
62+
63+
### Sync Client (WokwiClientSync)
64+
65+
```python
66+
import os
67+
from wokwi_client import WokwiClientSync, GET_TOKEN_URL
68+
69+
70+
def main():
71+
token = os.getenv("WOKWI_CLI_TOKEN")
72+
if not token:
73+
raise SystemExit(
74+
f"Set WOKWI_CLI_TOKEN in your environment. You can get it from {GET_TOKEN_URL}."
75+
)
76+
77+
client = WokwiClientSync(token)
78+
client.connect()
79+
client.upload_file("diagram.json")
80+
client.upload_file("firmware.bin")
81+
client.start_simulation(firmware="firmware.bin")
82+
client.serial_monitor_cat() # Stream serial output
83+
client.wait_until_simulation_time(10) # Run simulation for 10 seconds
84+
client.disconnect()
85+
86+
87+
if __name__ == "__main__":
88+
main()
89+
```
90+
91+
For a complete example, see [examples/hello_esp32_sync/main.py](https://github.com/wokwi/wokwi-python-client/blob/main/examples/hello_esp32_sync/main.py).
92+
93+
### MicroPython Example
94+
95+
See [examples/micropython_esp32/main.py](https://github.com/wokwi/wokwi-python-client/blob/main/examples/micropython_esp32/main.py) for an example of running MicroPython on a simulated ESP32 board.
5996

6097
## API Reference
6198

docs/reference/wokwi_client.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
::: wokwi_client
1+
::: wokwi_client.WokwiClient
2+
3+
::: wokwi_client.WokwiClientSync

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
site_name: Wokwi Python Client Library
2-
site_description: Typed, asyncio-friendly Python SDK for the Wokwi Simulation API
2+
site_description: Typed Python SDK for the Wokwi Simulation API with both async and synchronous interfaces
33
site_url: https://wokwi.github.io/wokwi-python-client/
44

55
repo_url: https://github.com/wokwi/wokwi-python-client

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
55
[project]
66
name = "wokwi-client"
77
dynamic = ["version"]
8-
description = "Typed, asyncio-friendly Python SDK for the Wokwi Simulation API"
8+
description = "Typed Python SDK for the Wokwi Simulation API with both async and synchronous interfaces"
99
readme = "README.md"
1010
authors = [{ name = "Uri Shaked", email = "uri@wokwi.com" }]
1111
license = "MIT"

src/wokwi_client/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""
22
Wokwi Python Client Library
33
4-
Typed, asyncio-friendly Python SDK for the Wokwi Simulation API.
4+
Typed Python SDK for the Wokwi Simulation API with both async and synchronous interfaces.
55
6-
Provides the WokwiClient class for connecting to, controlling, and monitoring Wokwi simulations from Python.
6+
Provides both WokwiClient (async) and WokwiClientSync (sync) classes for connecting to,
7+
controlling, and monitoring Wokwi simulations from Python.
78
"""
89

910
# SPDX-FileCopyrightText: 2025-present CodeMagic LTD

src/wokwi_client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class WokwiClient:
3131
3232
This class provides methods to connect to the Wokwi simulator, upload files, control simulations,
3333
and monitor serial output. It is designed to be asyncio-friendly and easy to use in Python scripts
34-
and applications.
34+
and applications. For a synchronous interface, see WokwiClientSync.
3535
"""
3636

3737
version: str

0 commit comments

Comments
 (0)