### Install build and twine tools Source: https://github.com/nuralogix/dfx-apiv2-client-py/blob/master/PUBLISHING.md Install the necessary tools for building and uploading Python packages. ```shell pip install --upgrade build twine ``` -------------------------------- ### Install DeepAffex APIv2 Client Source: https://github.com/nuralogix/dfx-apiv2-client-py/blob/master/README.md Use pip to install or upgrade the library in your Python environment. ```shell pip install --upgrade dfx-apiv2-client ``` -------------------------------- ### Create and verify distributions Source: https://github.com/nuralogix/dfx-apiv2-client-py/blob/master/PUBLISHING.md Clean the distribution directory, build the package, and validate the generated files. ```shell rm dist/* # Clean dist folder, on Window use `del /s /q dist\*` python -m build # Create wheel and source distribution using `build` tool twine check --strict dist/* # Check the created distributions and fix any issues if needed ``` -------------------------------- ### Manage Devices with DFX API v2 Python Client Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Demonstrates various device management operations including listing types, creating, retrieving, updating, and retrieving license IDs. Requires aiohttp and dfx_apiv2_client. Ensure dfxapi.Settings.device_token is set. ```python import aiohttp import dfx_apiv2_client as dfxapi async def manage_devices(): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: # List device types status, types = await dfxapi.Devices.types(session) print(f"Device types: {types}") # List devices status, devices = await dfxapi.Devices.list( session, status_id="ACTIVE", device_type_id="", device_name="", device_version="", license_id="", date="", end_date="", sort_order="DESC", limit=25, offset=0 ) print(f"Devices: {devices}") # Create a new device status, new_device = await dfxapi.Devices.create( session, device_name="Health Kiosk #1", device_type_id="LINUX", device_id="kiosk-001", version="1.0.0" ) device_id = new_device.get("ID") print(f"Created device: {device_id}") # Retrieve device details status, device = await dfxapi.Devices.retrieve(session, device_id) print(f"Device: {device}") # Update device status, updated = await dfxapi.Devices.update( session, id=device_id, device_name="Health Kiosk #1 Updated", status="ACTIVE", version="1.1.0" ) print(f"Updated device: {updated}") # Get license ID for device status, license_info = await dfxapi.Devices.retrieve_license_id(session) print(f"License: {license_info}") return devices ``` -------------------------------- ### Manage Licenses with DFX API v2 Python Client Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Demonstrates listing organization licenses and retrieving details for a specific license. Requires aiohttp and dfx_apiv2_client. Ensure dfxapi.Settings.device_token is set. ```python import aiohttp import dfx_apiv2_client as dfxapi async def manage_licenses(): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: # List organization licenses status, licenses = await dfxapi.Licenses.list( session, date="", # Filter by start date end_date="", # Filter by end date status_id="ACTIVE", # Filter by status license_type_id="", # Filter by license type ID license_type="", # Filter by license type limit=25, offset=0 ) print(f"Licenses: {licenses}") # Get specific license details if licenses: license_id = licenses[0]["ID"] status, license_detail = await dfxapi.Licenses.get(session, license_id) print(f"License details: {license_detail}") return licenses ``` -------------------------------- ### Perform Organization Operations in Python Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Demonstrates retrieving organization details, managing users, listing measurements, and performing organization-specific logins using the dfx_apiv2_client library. ```python import aiohttp import dfx_apiv2_client as dfxapi async def organization_operations(): headers = {"Authorization": f"Bearer {dfxapi.Settings.user_token}"} async with aiohttp.ClientSession(headers=headers) as session: # Retrieve organization details status, org = await dfxapi.Organizations.retrieve(session) print(f"Organization: {org}") # List organization users status, users = await dfxapi.Organizations.list_users( session, start_date="", end_date="", email="", role_id="", gender="", region="", limit=25, offset=0 ) print(f"Users: {users}") # Create organization user status, new_user = await dfxapi.Organizations.create_user( session, first_name="Jane", last_name="Smith", email="jane.smith@example.com", gender="female", date_of_birth="1985-06-20", role_id="LEAD" ) print(f"Created user: {new_user}") # List organization measurements status, measurements = await dfxapi.Organizations.list_measurements( session, date="2024-01-01", end_date="2024-12-31", user_profile_id="", study_id="", status_id="COMPLETE", email="", partner_id="", mode="", region="", limit=50, offset=0 ) print(f"Measurements: {measurements}") # List organization profiles status, profiles = await dfxapi.Organizations.list_profiles( session, date="", end_date="", owner_email="", user_profile_name="", status_id="ACTIVE", limit=25, offset=0 ) print(f"Profiles: {profiles}") # Organization login (with organization identifier) status, login_result = await dfxapi.Organizations.login( session, email="admin@example.com", password="password123", org_id="org-identifier", mfa_token="", token_expires_in_sec=86400, refresh_token_expires_in_sec=2592000 ) print(f"Login result: {login_result}") return org ``` -------------------------------- ### Configure DFX APIv2 Client Settings Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Configure global settings for API endpoints and authentication tokens. Ensure authentication tokens are populated after registration or login. ```python import dfx_apiv2_client as dfxapi # Configure API endpoints (defaults shown) dfxapi.Settings.rest_url = "https://api.deepaffex.ai" dfxapi.Settings.ws_url = "wss://api.deepaffex.ai" # Authentication tokens (populated after registration/login) dfxapi.Settings.device_id = "" dfxapi.Settings.device_token = "" dfxapi.Settings.device_refresh_token = "" dfxapi.Settings.role_id = "" dfxapi.Settings.user_id = "" dfxapi.Settings.user_token = "" dfxapi.Settings.user_refresh_token = "" ``` -------------------------------- ### Create New User Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Creates a new user account with provided personal details. Requires a device token for authentication. Ensure all required fields like first name, last name, email, password, and date of birth are correctly formatted. ```python import aiohttp import dfx_apiv2_client as dfxapi async def create_user(): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, body = await dfxapi.Users.create( session, first_name="John", last_name="Doe", email="john.doe@example.com", password="SecurePassword123!", phone_number="+1234567890", gender="male", # male, female, other date_of_birth="1990-01-15", # YYYY-MM-DD format height_cm=175, weight_kg=70 ) return status, body ``` -------------------------------- ### User Login with Email and Password Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Logs in a user using their email and password. Requires a device token for authentication and supports an optional MFA token. Token expiration times can be configured. ```python import aiohttp import dfx_apiv2_client as dfxapi async def user_login(email: str, password: str): # Requires device token for authentication headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, body = await dfxapi.Users.login( session, email=email, password=password, mfa_token="", # Optional MFA token token_expires_in_sec=86400, # Token TTL (default: 24 hours) refresh_token_expires_in_sec=2592000 # Refresh token TTL (default: 30 days) ) if status < 400: # Settings are automatically populated print(f"User Token: {dfxapi.Settings.user_token}") print("Login successful") else: print(f"Login failed: {body}") return status, body ``` -------------------------------- ### Execute complete measurement workflow in Python Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt This asynchronous function demonstrates the full lifecycle of a measurement, including API status checks, device registration, and payload processing. Ensure the payloads folder contains binary files named with the 'payload*.bin' pattern. ```python import aiohttp import asyncio import json import dfx_apiv2_client as dfxapi async def complete_measurement_workflow(license_key: str, payloads_folder: str): # Step 1: Check API status async with aiohttp.ClientSession() as session: status, api_status = await dfxapi.General.api_status(session) if api_status["StatusID"] != "ACTIVE": print(f"API not active: {api_status}") return # Step 2: Register device async with aiohttp.ClientSession(raise_for_status=True) as session: await dfxapi.Organizations.register_license( session, license_key, "LINUX", "My App", "MYAPP", "1.0.0" ) print(f"Registered device: {dfxapi.Settings.device_id}") headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers, raise_for_status=True) as session: # Step 3: List and select a study status, studies = await dfxapi.Studies.list(session) if not studies: print("No studies available") return study_id = studies[0]["ID"] print(f"Using study: {study_id}") # Step 4: Create a profile for the participant status, profile = await dfxapi.Profiles.create( session, "Test Participant", "test@example.com" ) profile_id = profile.get("ID", "") # Step 5: Create measurement status, measurement = await dfxapi.Measurements.create( session, study_id, user_profile_id=profile_id ) measurement_id = measurement["ID"] print(f"Created measurement: {measurement_id}") # Step 6: Load and send payloads import glob import os payload_files = sorted(glob.glob(os.path.join(payloads_folder, "payload*.bin"))) for i, payload_file in enumerate(payload_files): with open(payload_file, 'rb') as f: payload = f.read() # Determine action based on position if i == 0 and len(payload_files) > 1: action = "FIRST::PROCESS" elif i == len(payload_files) - 1: action = "LAST::PROCESS" else: action = "CHUNK::PROCESS" status, result = await dfxapi.Measurements.add_data( session, measurement_id, action, payload ) print(f"Added chunk {i+1}/{len(payload_files)}: {result['ID']}") await asyncio.sleep(5) # Rate limiting # Step 7: Retrieve results await asyncio.sleep(10) # Wait for processing status, results = await dfxapi.Measurements.retrieve( session, measurement_id, expand=True ) print(f"Results: {json.dumps(results, indent=2)}") return results # Run the workflow # asyncio.run(complete_measurement_workflow("your-license-key", "./payloads")) ``` -------------------------------- ### Register Device with License Key Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Register a device with a license key to enable authenticated API calls. Settings are automatically populated upon successful registration. Ensure to specify appropriate device type, application details, and token expiration times. ```python import aiohttp import dfx_apiv2_client as dfxapi async def register_device(license_key: str): async with aiohttp.ClientSession(raise_for_status=True) as session: status, body = await dfxapi.Organizations.register_license( session, license_key=license_key, device_type_id="LINUX", # Device type: LINUX, WINDOWS, MACOS, IOS, ANDROID app_name="My Health App", # Your application name app_id="com.example.healthapp", # Your application identifier app_version="1.0.0", # Your application version token_expires_in_seconds=86400, # Token TTL (default: 24 hours) refresh_token_expires_in_sec=2592000 # Refresh token TTL (default: 30 days) ) # Settings are automatically populated on success print(f"Device ID: {dfxapi.Settings.device_id}") print(f"Device Token: {dfxapi.Settings.device_token}") print(f"Role ID: {dfxapi.Settings.role_id}") return body ``` -------------------------------- ### Publish release to private PyPI Source: https://github.com/nuralogix/dfx-apiv2-client-py/blob/master/PUBLISHING.md Tag the release on the main branch and upload the signed distribution files. ```shell git checkout master # Releases should always be from main branch git tag vX.Y.Z # Tag the release on the main branch rm dist/* # Clean dist folder, on Window use `del /s /q dist/*` python -m build # Create wheel and source distribution twine upload --sign dist/* # Sign and upload to PyPI ``` -------------------------------- ### Create Real-time Measurement via WebSocket Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Use this function to stream real-time measurement data. It first creates a measurement using the REST API, then connects to the WebSocket for data streaming and result retrieval. Ensure you have the necessary authentication token set in `dfxapi.Settings.device_token`. ```python import aiohttp import asyncio import json import random import string import dfx_apiv2_client as dfxapi def generate_request_id(): return "".join(random.choices(string.ascii_letters, k=10)) def determine_action(chunk_number: int, total_chunks: int) -> str: if chunk_number == 0 and total_chunks > 1: return "FIRST::PROCESS" elif chunk_number == total_chunks - 1: return "LAST::PROCESS" return "CHUNK::PROCESS" async def make_measurement_websocket(study_id: str, payloads: list[bytes]): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers, raise_for_status=True) as session: # Step 1: Create measurement via REST status, create_result = await dfxapi.Measurements.create(session, study_id) measurement_id = create_result["ID"] print(f"Created measurement: {measurement_id}") # Step 2: Connect to WebSocket async with dfxapi.Measurements.ws_connect(session) as ws: # Optional: Authenticate via WebSocket if headers not available # await dfxapi.Organizations.ws_auth_with_token(ws, generate_request_id()) # await ws.receive() # Step 3: Subscribe to results results_request_id = generate_request_id() await dfxapi.Measurements.ws_subscribe_to_results( ws, request_id=generate_request_id(), measurement_id=measurement_id, results_request_id=results_request_id ) total_chunks = len(payloads) results_received = 0 async def send_chunks(): for i, payload in enumerate(payloads): action = determine_action(i, total_chunks) request_id = generate_request_id() await dfxapi.Measurements.ws_add_data( ws, request_id=request_id, measurement_id=measurement_id, action=action, payload=payload, chunk_order=i, # Optional duration_s="5" # Optional chunk duration ) print(f"Sent chunk {i+1}/{total_chunks} - {action}") await asyncio.sleep(5) # Simulate real-time capture async def receive_results(): nonlocal results_received async for msg in ws: status, request_id, payload = dfxapi.Measurements.ws_decode(msg) if request_id == results_request_id: result = json.loads(payload) print(f"Received result: {result}") results_received += 1 if results_received >= total_chunks: await ws.close() break # Run send and receive concurrently await asyncio.gather(send_chunks(), receive_results()) print(f"Measurement {measurement_id} complete") return measurement_id ``` -------------------------------- ### Check API Status and Verify Token Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Check the API status, list available system resources like regions, user roles, statuses, and MIME types. Token verification requires authentication headers. ```python import aiohttp import dfx_apiv2_client as dfxapi async def check_api_and_verify(): async with aiohttp.ClientSession() as session: # Check API status status, api_status = await dfxapi.General.api_status(session) print(f"API Status: {api_status['StatusID']}") # Expected: "ACTIVE" # List available regions status, regions = await dfxapi.General.list_available_regions(session) print(f"Available regions: {regions}") # List available user roles status, roles = await dfxapi.General.list_available_user_roles(session) print(f"User roles: {roles}") # List available statuses status, statuses = await dfxapi.General.list_available_statuses(session) print(f"Statuses: {statuses}") # List accepted MIME types status, mimes = await dfxapi.General.list_accepted_mime_types(session) print(f"Accepted MIME types: {mimes}") # Verify token (requires authentication headers) headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, body = await dfxapi.General.verify_token(session) if status < 400: print("Token is valid") else: print(f"Token verification failed: {body}") ``` -------------------------------- ### Create and Process Measurements via REST API Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Demonstrates the full lifecycle of a measurement, including creation, data chunk submission, intermediate status retrieval, and final result fetching. ```python async def make_measurement_rest(study_id: str, payload_data: bytes, profile_id: str = ""): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers, raise_for_status=True) as session: # Step 1: Create a new measurement status, create_result = await dfxapi.Measurements.create( session, study_id=study_id, resolution=0, # Video resolution (0 for default) user_profile_id=profile_id, # Associate with a profile partner_id="" # Optional partner identifier ) measurement_id = create_result["ID"] print(f"Created measurement: {measurement_id}") # Step 2: Add data chunks (simulating video frames) # For single chunk measurement status, add_result = await dfxapi.Measurements.add_data( session, measurement_id=measurement_id, action="FIRST::PROCESS", # FIRST::PROCESS, CHUNK::PROCESS, or LAST::PROCESS payload=payload_data # Binary payload from DFX SDK ) print(f"Added chunk: {add_result['ID']}") # Wait for processing await asyncio.sleep(5) # Step 3: Retrieve intermediate results status, intermediate = await dfxapi.Measurements.retrieve_intermediate( session, measurement_id=measurement_id, chunk_order=0 # 0-indexed chunk number ) print(f"Intermediate results: {intermediate}") # Step 4: Retrieve final measurement results status, results = await dfxapi.Measurements.retrieve( session, measurement_id=measurement_id, expand=True # Include detailed results ) print(f"Final results: {results}") return measurement_id, results ``` -------------------------------- ### Manage Measurement Studies with DFX API Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt List, retrieve, and create studies using the Studies module. Requires an active device token in the settings. ```python import aiohttp import dfx_apiv2_client as dfxapi async def manage_studies(): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: # List available study types status, types = await dfxapi.Studies.types(session, status="ACTIVE") print(f"Study types: {types}") # List study templates status, templates = await dfxapi.Studies.list_templates( session, status="ACTIVE", type_="", # Optional type filter sort_order="DESC", sort_key="Created", limit=25, offset=0 ) print(f"Available templates: {templates}") # List existing studies status, studies = await dfxapi.Studies.list( session, date="", # Optional: filter by start date end_date="", # Optional: filter by end date study_name="", # Optional: filter by name status="ACTIVE", limit=25, offset=0 ) print(f"Studies: {studies}") # Retrieve a specific study if studies: study_id = studies[0]["ID"] status, study = await dfxapi.Studies.retrieve(session, study_id) print(f"Study details: {study}") # Get SDK configuration for the study status, sdk_config = await dfxapi.Studies.retrieve_sdk_config_data( session, study_id=study_id, sdk_id="your-sdk-id", current_hash="" # MD5 hash for caching ) print(f"SDK Config: {sdk_config}") # Create a new study status, new_study = await dfxapi.Studies.create( session, study_name="Health Monitoring Study", description="Daily vital signs monitoring", study_template_id="template-id-here", config={} # Study-specific configuration ) print(f"Created study: {new_study}") return studies ``` -------------------------------- ### Manage User Profiles with DFX API Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Perform CRUD operations on user profiles using the Profiles module. Requires an active user token in the settings. ```python import aiohttp import dfx_apiv2_client as dfxapi async def manage_profiles(): headers = {"Authorization": f"Bearer {dfxapi.Settings.user_token}"} async with aiohttp.ClientSession(headers=headers) as session: # Create a new profile status, result = await dfxapi.Profiles.create( session, profile_name="John Doe", email="john.doe@example.com" ) profile_id = result.get("ID") print(f"Created profile: {profile_id}") # List all profiles status, profiles = await dfxapi.Profiles.list( session, profile_name="", # Optional filter status="", # Optional status filter limit=25, offset=0 ) print(f"Found {len(profiles)} profiles") # Retrieve a specific profile status, profile = await dfxapi.Profiles.retrieve(session, profile_id) print(f"Profile details: {profile}") # Update profile status, updated = await dfxapi.Profiles.update( session, profile_id=profile_id, profile_name="John D.", profile_email="john.d@example.com", status="ACTIVE" ) print(f"Updated profile: {updated}") # Delete profile status, deleted = await dfxapi.Profiles.delete(session, profile_id) print("Profile deleted") return profile_id ``` -------------------------------- ### Organization License Registration Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Handles device registration with a license key, required before making authenticated API calls. ```APIDOC ## Organizations API Endpoints ### Description Manages device registration using a license key, which is a prerequisite for authenticated API interactions. It also provides functionality to unregister a device. ### Method POST (for register_license) DELETE (for unregister_license) ### Endpoint `/api/v2/organizations/register_license` `/api/v2/organizations/unregister_license` ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body (for register_license) - **license_key** (str) - Required - The license key for the organization. - **device_type_id** (str) - Required - The type of device (e.g., "LINUX", "WINDOWS", "IOS"). - **app_name** (str) - Required - The name of the application. - **app_id** (str) - Required - The unique identifier of the application. - **app_version** (str) - Required - The version of the application. - **token_expires_in_seconds** (int) - Optional - Token expiration time in seconds (default: 86400). - **refresh_token_expires_in_sec** (int) - Optional - Refresh token expiration time in seconds (default: 2592000). ### Request Example (register_license) ```python import aiohttp import dfx_apiv2_client as dfxapi async def register_device(license_key: str): async with aiohttp.ClientSession(raise_for_status=True) as session: status, body = await dfxapi.Organizations.register_license( session, license_key=license_key, device_type_id="LINUX", app_name="My Health App", app_id="com.example.healthapp", app_version="1.0.0", token_expires_in_seconds=86400, refresh_token_expires_in_sec=2592000 ) # Settings are automatically populated on success print(f"Device ID: {dfxapi.Settings.device_id}") print(f"Device Token: {dfxapi.Settings.device_token}") print(f"Role ID: {dfxapi.Settings.role_id}") return body ``` ### Request Example (unregister_device) ```python import aiohttp import dfx_apiv2_client as dfxapi async def unregister_device(): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, body = await dfxapi.Organizations.unregister_license(session) if status < 400: print("Device unregistered successfully") return status, body ``` ### Response #### Success Response (200) for register_license - **device_id** (str) - The registered device ID. - **device_token** (str) - The authentication token for the device. - **role_id** (str) - The role ID assigned to the device. #### Success Response (200) for unregister_license - **message** (str) - Confirmation message of unregistration. #### Response Example (register_license) ```json { "device_id": "some_device_id", "device_token": "some_device_token", "role_id": "some_role_id" } ``` #### Response Example (unregister_license) ```json { "message": "Device unregistered successfully." } ``` #### Error Response (4xx/5xx) - **error**: Dictionary containing error details. ``` -------------------------------- ### General API Status and Token Verification Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Endpoints for checking API status, verifying tokens, and retrieving system resources. ```APIDOC ## General API Endpoints ### Description Provides endpoints for checking API status, verifying tokens, and retrieving available system resources. ### Method GET ### Endpoint `/api/v2/status` (for api_status) `/api/v2/regions` (for list_available_regions) `/api/v2/user_roles` (for list_available_user_roles) `/api/v2/statuses` (for list_available_statuses) `/api/v2/mimes` (for list_accepted_mime_types) `/api/v2/verify_token` (for verify_token) ### Parameters #### Query Parameters None for these endpoints. #### Request Body None for these endpoints. ### Request Example ```python import aiohttp import dfx_apiv2_client as dfxapi async def check_api_and_verify(): async with aiohttp.ClientSession() as session: # Check API status status, api_status = await dfxapi.General.api_status(session) print(f"API Status: {api_status['StatusID']}") # List available regions status, regions = await dfxapi.General.list_available_regions(session) print(f"Available regions: {regions}") # List available user roles status, roles = await dfxapi.General.list_available_user_roles(session) print(f"User roles: {roles}") # List available statuses status, statuses = await dfxapi.General.list_available_statuses(session) print(f"Statuses: {statuses}") # List accepted MIME types status, mimes = await dfxapi.General.list_accepted_mime_types(session) print(f"Accepted MIME types: {mimes}") # Verify token (requires authentication headers) headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, body = await dfxapi.General.verify_token(session) if status < 400: print("Token is valid") else: print(f"Token verification failed: {body}") ``` ### Response #### Success Response (200) - **api_status**: Dictionary containing API status information. - **regions**: List of available regions. - **roles**: List of available user roles. - **statuses**: List of available statuses. - **mimes**: List of accepted MIME types. - **verify_token**: Body indicating token validity. #### Response Example ```json { "StatusID": "ACTIVE", "Message": "API is operational." } ``` #### Error Response (4xx/5xx) - **error**: Dictionary containing error details. ``` -------------------------------- ### List Measurements with Filters Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Retrieves a list of measurements based on specific criteria such as date ranges, status, and profile IDs. ```python async def list_measurements(): headers = {"Authorization": f"Bearer {dfxapi.Settings.user_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, measurements = await dfxapi.Measurements.list( session, date="2024-01-01", # Filter by start date end_date="2024-12-31", # Filter by end date user_profile_id="", # Filter by profile study_id="", # Filter by study status_id="COMPLETE", # PENDING, PROCESSING, COMPLETE, ERROR partner_id="", mode="", # Optional mode filter limit=50, offset=0 ) print(f"Found {len(measurements)} measurements") return measurements ``` -------------------------------- ### Unregister Device Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Unregister a previously registered device from the system. This action requires the device token for authentication. ```python import aiohttp import dfx_apiv2_client as dfxapi async def unregister_device(): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, body = await dfxapi.Organizations.unregister_license(session) if status < 400: print("Device unregistered successfully") return status, body ``` -------------------------------- ### Request Password Reset Email Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Initiates the password reset process by sending an email to the specified address. Requires the user's email and organization ID. ```python import aiohttp import dfx_apiv2_client as dfxapi async def request_password_reset(email: str, org_id: str): async with aiohttp.ClientSession() as session: status, body = await dfxapi.Auths.request_password_reset_email( session, email=email, org_id=org_id ) return status, body ``` -------------------------------- ### User Logout Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Logs out the currently authenticated user. Requires the user token for authentication. ```python import aiohttp import dfx_apiv2_client as dfxapi async def user_logout(): headers = {"Authorization": f"Bearer {dfxapi.Settings.user_token}"} async with aiohttp.ClientSession(headers=headers, raise_for_status=True) as session: status, body = await dfxapi.Users.logout(session) print("Logout successful") return status, body ``` -------------------------------- ### Renew User Token Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Renews the current user token to extend the session. Optionally, a new refresh token TTL can be specified. The client automatically updates settings with new tokens upon successful renewal. ```python import aiohttp import dfx_apiv2_client as dfxapi async def renew_tokens(): headers = {"Authorization": f"Bearer {dfxapi.Settings.user_token}"} async with aiohttp.ClientSession(headers=headers) as session: # Renew user token status, body = await dfxapi.Auths.renew_user_token( session, refresh_token_expires_sec=2592000 # Optional: new refresh token TTL ) if status < 400: # Settings are automatically updated with new tokens print(f"New User Token: {dfxapi.Settings.user_token}") print(f"New Refresh Token: {dfxapi.Settings.user_refresh_token}") else: print(f"Token renewal failed: {body}") return status, body ``` -------------------------------- ### Renew Device Token Source: https://context7.com/nuralogix/dfx-apiv2-client-py/llms.txt Renews the device token, which is required for certain authenticated operations. The client automatically updates the device token in settings upon successful renewal. ```python import aiohttp import dfx_apiv2_client as dfxapi async def renew_device_token(): headers = {"Authorization": f"Bearer {dfxapi.Settings.device_token}"} async with aiohttp.ClientSession(headers=headers) as session: status, body = await dfxapi.Auths.renew_device_token(session) if status < 400: print(f"New Device Token: {dfxapi.Settings.device_token}") return status, body ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.