wedetech-sdk
Official Python client for the wede API.
wede keeps critical operations running whatever the state of the network. Operations captured without connectivity are synchronised when it returns, and each one is stored exactly once.
Full documentation: docs.wede.pt
Requirements
Python 3.8 or later. No dependencies.
Installation
pip install wedetech-sdk
Credentials
On a server, use the tenant API key (wede_live_... or wede_test_...) and keep it as a secret.
import os
from wede import WedeClient
wede = WedeClient(api_key=os.environ["WEDE_API_KEY"])
On a device, sign the user in and use the session token. What the token can do depends on the user's role in your tenant.
session = WedeClient.login(email, password)
wede = WedeClient(access_token=session["token"])
The token expires after 8 hours. Sign in again and call wede.set_access_token(new_token). Five failed sign-in attempts lock the account for 15 minutes.
| Argument | Default | Description |
|---|---|---|
api_key |
Tenant API key, server side only | |
access_token |
User session token | |
base_url |
https://api.wede.pt |
API base URL |
timeout |
10.0 |
Request timeout in seconds |
retries |
3 |
Attempts on network failure |
Send an event
res = wede.send_event(
type="cardiac_arrest",
vertical="healthcare",
priority="high",
payload={"patient_ref": "P-1042"},
metadata={"zone_id": "LIS-01"},
)
res["event_id"]
type is an event type of your catalog for this vertical, or an event category (see below). priority is low, normal, high or critical. The same idempotency_key twice returns 409 duplicate_event, so retries are always safe.
Event types and categories
Event types are yours. You create them in your catalog, per vertical, and link each one to a category:
wede.create_catalog_action("healthcare", "cardiac_arrest", "Cardiac arrest", category="EMERGENCY")
Categories are a shared list kept by wede (list_event_categories()), for example EMERGENCY, PAYMENT, BOOKING, STATUS_UPDATE, IDENTITY_CONFIRM, DISPATCH and OTHER. The list stays open and grows over time. Using them is optional: an event can use a category code directly as its type.
An event's type is accepted when it is an active type of your catalog for the event's vertical, or an active category. Anything else returns 422 unknown_event_type.
Operations captured without connectivity
from wede import capture_event
captured = capture_event("delivery_confirmed", "logistics", "normal", {"parcel": "PX-2231"})
# store `captured` locally, unchanged
result = wede.sync_batch(queued_events)
result["summary"] # {"total", "accepted", "duplicates", "rejected"}
result["results"] # one entry per event
- Up to 500 events per call.
capture_eventadds the capture time and an integrity checksum. An event whose content changes after capture is rejected.duplicatesis your proof against double counting: an operation that already reached wede is stored only once.- Payloads can contain
dict,list,str,int,float,boolandNone. The SDK serialises them exactly as wede checks them.
Errors
| Class | When |
|---|---|
WedeAuthError |
Missing or invalid credentials (401) |
WedeError |
The API answered with an error. status, code and details carry the reason |
WedeNetworkError |
No response after all retries |
Common codes: duplicate_event (409), unknown_event_type (422), unknown_vertical (422), invalid_payload (422), forbidden (403).
Method reference
| Area | Methods |
|---|---|
| Sign in | WedeClient.login, set_access_token |
| Events | send_event, list_events, get_event |
| Event types | list_event_categories, list_catalog_actions, create_catalog_action, update_catalog_action, delete_catalog_action |
| Offline sync | capture_event, sync_batch, get_sync_status, register_device, sync_device_queue |
| Connectivity | get_connectivity_status, report_connectivity, list_zones, get_zone |
| Tenant | get_tenant_info, get_usage, get_billing, update_dispatch_settings |
| Teams and dispatch | list_teams, get_team, update_member_location, score_teams, dispatch, dispatch_action |
| Missions | list_missions, list_my_missions, get_mission, update_mission_status |
| Parsers | list_parsers, get_parser, get_active_parser |
| Webhooks | list_webhooks, create_webhook, delete_webhook |
What each credential can call depends on its role in your tenant. A call outside it returns 403.
License
MIT
Release files for wedetech-sdk 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 | |
|---|---|---|---|
| wedetech_sdk-2.0.0.tar.gz | 12.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wedetech_sdk-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.9 kB
Release files / wedetech_sdk-2.0.0.tar.gz
| Download URL | wedetech_sdk-2.0.0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22990d3331cec3589ced0aadc0293ba7044c713462d523b947c69da66ba9b7dc
|
|
BLAKE2b-256 checksum How to use checksums |
9998fcd5408185294c5481d822e507f630a6006008dedf664954ae3d8a636f0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / wedetech_sdk-2.0.0-py3-none-any.whl
| Download URL | wedetech_sdk-2.0.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7aa4eb13fd517e2a0cb589541aa2821eb9d5458e4be2667bb079d62a6ac32b3f
|
|
BLAKE2b-256 checksum How to use checksums |
327fc6ee3a5dc24a1b6f27a46adeb8a47ab6b6ccfd35abc3803c57854f3d2c6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|