Skip to main content

Wandelbots Python Client: Interact with robots in an easy and intuitive way.

Project description

wandelbots-api-client

Interact with robots in an easy and intuitive way.

  • Compatible API version: 1.4.0 (can be found at the home screen of your instance -> API)
  • Package version: 26.4.0.dev18

Requirements.

Python >=3.11, Python < 4.0

Installation

pip install wandelbots-api-client

OR with uv:

uv init
uv add wandelbots-api-client

Authentication

The SDK supports OAuth2 device code flow authentication for both Entra ID (formerly Azure AD) and Auth0. This authentication method is ideal for CLI applications, scripts, and headless environments.

Entra ID (Azure AD) Authentication

import asyncio
from wandelbots_api_client import ApiClient, Configuration
from wandelbots_api_client.authorization import EntraIDConfig

async def main():
    # Initialize Entra ID config
    auth = EntraIDConfig(
        client_id="GIVEN_CLIENT_ID",
        tenant_id="GIVEN_TENANT_ID", 
        scope="openid profile email offline_access GIVEN_CLIENT_ID\.default"
    )
    
    # Request device code
    device_response = await auth.request_device_code()
    
    # Display user instructions
    print(f"\nPlease authenticate:")
    print(f"1. Go to: {device_response['verification_uri']}")
    print(f"2. Enter code: {device_response['user_code']}")
    print(f"Waiting for authentication...\n")
    
    # Poll for token (will wait until user completes authentication)
    token_response = await auth.poll_token_endpoint(
        device_code=device_response["device_code"],
        interval=device_response.get("interval", 5),
        expires_in=device_response.get("expires_in", 900)
    )
    
    print("Authentication successful!")
    
    # Configure API client with access token
    config = Configuration(
        host="https://your-instance.wandelbots.io",
        access_token=token_response["access_token"]
    )
    
    async with ApiClient(configuration=config) as api_client:
        # Use the API client for authenticated requests
        # Example: api = YourApi(api_client)
        # result = await api.your_method()
        pass
    
    # Optionally refresh the token later
    if "refresh_token" in token_response:
        new_token = await auth.refresh_token(token_response["refresh_token"])
        config.access_token = new_token["access_token"]

asyncio.run(main())

Auth0 Authentication

import asyncio
from wandelbots_api_client import ApiClient, Configuration
from wandelbots_api_client.authorization import Auth0Config

async def main():
    # Initialize Auth0 config
    auth = Auth0Config(
        client_id="GIVEN_CLIENT_ID",
        domain="auth.portal.wandelbots.io",
        audience="GIVEN_AUDIENCE", 
        scope="openid profile email offline_access"
    )
    
    # Or use default config from template variables
    # auth = Auth0Config.default()
    
    # Request device code
    device_response = await auth.request_device_code()
    
    # Display user instructions
    print(f"\nPlease authenticate:")
    print(f"1. Go to: {device_response['verification_uri']}")
    print(f"2. Enter code: {device_response['user_code']}")
    print(f"Waiting for authentication...\n")
    
    # Poll for token (will wait until user completes authentication)
    token_response = await auth.poll_token_endpoint(
        device_code=device_response["device_code"],
        interval=device_response.get("interval", 5),
        expires_in=device_response.get("expires_in", 900)
    )
    
    print("Authentication successful!")
    
    # Configure API client with access token
    config = Configuration(
        host="https://XYZ.instances.wandelbots.io",
        access_token=token_response["access_token"]
    )
    
    async with ApiClient(configuration=config) as api_client:
        # Use the API client for authenticated requests
        # Example: api = YourApi(api_client)
        # result = await api.your_method()
        pass

asyncio.run(main())

Token Refresh

To maintain long-lived sessions, use refresh tokens to obtain new access tokens:

# When your access token expires
if "refresh_token" in token_response:
    refreshed = await auth.refresh_token(token_response["refresh_token"])
    config.access_token = refreshed["access_token"]
    
    # Update refresh token if a new one is provided
    if "refresh_token" in refreshed:
        token_response["refresh_token"] = refreshed["refresh_token"]

Complete Example with Error Handling

import asyncio
from wandelbots_api_client import ApiClient, Configuration
from wandelbots_api_client.authorization import EntraIDConfig

async def authenticate_and_call_api():
    """Complete example with error handling."""
    try:
        # Initialize authentication
        auth = EntraIDConfig(
            client_id="GIVEN_CLIENT_ID",
            tenant_id="GIVEN_TENANT_ID",
            scopen="openid profile email offline_access GIVEN_CLIENT_ID\.default"
        )
        
        # Verify configuration
        if not auth.is_complete():
            raise ValueError("Authentication configuration is incomplete")
        
        # Request device code
        device_response = await auth.request_device_code()
        
        # Display instructions
        print(f"\n{'='*60}")
        print(f"AUTHENTICATION REQUIRED")
        print(f"{'='*60}")
        print(f"Visit: {device_response['verification_uri']}")
        print(f"Enter code: {device_response['user_code']}")
        print(f"{'='*60}\n")
        
        # Wait for user to authenticate
        token_response = await auth.poll_token_endpoint(
            device_code=device_response["device_code"],
            interval=device_response.get("interval", 5),
            expires_in=device_response.get("expires_in", 900)
        )
        
        print("✓ Authentication successful!\n")
        
        # Create API client
        config = Configuration(
            host="https://XYZ.instance.wandelbots.io",
            access_token=token_response["access_token"]
        )
        
        async with ApiClient(configuration=config) as api_client:
            # Make authenticated API calls here
            # Example:
            # from wandelbots_api_client.api import YourApi
            # api = YourApi(api_client)
            # result = await api.your_method()
            print("API client ready for requests")
            
    except TimeoutError:
        print("Authentication timed out. Please try again.")
    except ValueError as e:
        print(f"Configuration error: {e}")
    except Exception as e:
        print(f"Authentication failed: {e}")

asyncio.run(authenticate_and_call_api())

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wandelbots_api_client-26.4.0.dev18.tar.gz (609.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wandelbots_api_client-26.4.0.dev18-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file wandelbots_api_client-26.4.0.dev18.tar.gz.

File metadata

  • Download URL: wandelbots_api_client-26.4.0.dev18.tar.gz
  • Upload date:
  • Size: 609.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.22.1","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wandelbots_api_client-26.4.0.dev18.tar.gz
Algorithm Hash digest
SHA256 a55e8290bfe523936c3d3a3aed78f6f99b7e13bc8c7a6d8b6bf3897e23e6dfc1
MD5 bde87e77ff66becf27fa003612a18778
BLAKE2b-256 09b5da6b9bcd1d5cd0b12192a13a2279d420de226ab56a153d2d003f75ae9b41

See more details on using hashes here.

File details

Details for the file wandelbots_api_client-26.4.0.dev18-py3-none-any.whl.

File metadata

  • Download URL: wandelbots_api_client-26.4.0.dev18-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.22.1","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wandelbots_api_client-26.4.0.dev18-py3-none-any.whl
Algorithm Hash digest
SHA256 526c5f7f7caa3b472f78a0f1aa4f8cbc78e374d7a6f1f1f2e22ac620c5580914
MD5 c89c5bd7adf8bb69706a07e9064da15f
BLAKE2b-256 a3b2fcd01166cf53c0c4d5336f2b906f0a5828ee52831067fc79fecebb04ca61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page