SDK docs menu

class

Client

Your HardLabs account, and the boards you can open with it.

from hardlabs_sdk import Client
Client(token=None, api=None, *, timeout=60.0)

Client() signs in with the token npx hardlabs login saved on this computer, or HARDLABS_TOKEN when it is set.

Usage

from hardlabs_sdk import Client

client = Client()
board = client.start("hardlabs/demo-board")

Arguments

tokenstr | Nonedefault None
An API token. Defaults to HARDLABS_TOKEN, then the token hardlabs login saved.
apistr | Nonedefault None
The API's address. Defaults to HARDLABS_API_URL, then https://api.hardlabs.io.
timeoutfloatdefault 60.0
Real seconds a single request may take.

Raises

  • LookupError — No token was given and none is saved.

Client.memethod

Returns the account the token belongs to.

client.me() -> dict

Returns

dict — The account, as the API reports it.

Client.simsmethod

Lists the simulations you can open.

client.sims() -> list[dict]

python -m hardlabs_sdk sims prints the same list.

Returns

list[dict] — Each with its address (owner/project@version) and id.

Client.boardmethod

Returns a board by name, without booting it. Call Board.start to boot it.

client.board(name) -> Board

Arguments

namestr
owner/project@version, owner/project (its latest published version), a project's name, or an id.

Returns

Board — The board.

Raises

  • HardLabsError — No simulation has that name, or more than one does. The message lists what you can open.

Client.startmethod

Returns a board by name, booted. The same as board(name).start(firmware).

client.start(name, firmware=None) -> Board

Usage

board = Client().start("company_name/board_name", "build/app.elf")

Arguments

namestr
The simulation's name, as board takes it.
firmwarestr | Path | Image | list | Nonedefault None
The firmware to boot, as Board.start takes it. The board's own when left out.

Returns

Board — The running board.