{"id":7042,"library":"benchling-sdk","title":"Benchling SDK for Python","description":"The Benchling SDK for Python provides a robust interface for interacting with the Benchling Platform, enabling programmatic access to its various functionalities including entities, assays, results, and workflows. It simplifies API interactions, handles authentication, and supports common data structures. The current version is 1.24.1, with frequent releases to keep pace with platform updates.","status":"active","version":"1.24.1","language":"en","source_language":"en","source_url":"https://github.com/Benchling/benchling-sdk-python","tags":["benchling","sdk","api","bioinformatics","lab-automation","genomics"],"install":[{"cmd":"pip install benchling-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"BenchlingClient","correct":"from benchling_sdk.benchling import BenchlingClient"}],"quickstart":{"code":"import os\nfrom benchling_sdk.benchling import BenchlingClient\n\n# Ensure BENCHLING_API_KEY and BENCHLING_API_URL are set as environment variables\napi_key = os.environ.get(\"BENCHLING_API_KEY\", \"\")\napi_url = os.environ.get(\"BENCHLING_API_URL\", \"\")\n\nif not api_key or not api_url:\n    print(\"Please set BENCHLING_API_KEY and BENCHLING_API_URL environment variables.\")\n    # In a real application, you might raise an exception or configure differently.\n    exit(1)\n\ntry:\n    # Initialize the client. It automatically picks up BENCHLING_API_KEY and BENCHLING_API_URL.\n    benchling_client = BenchlingClient()\n\n    # Example: List up to 3 entries (requires appropriate permissions)\n    entries = benchling_client.entries.list(page_size=3).items\n\n    print(f\"Successfully connected to Benchling. Found {len(entries)} entries.\")\n    for entry in entries:\n        print(f\"  - Entry ID: {entry.id}, Name: {entry.name}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"Initializes the BenchlingClient using environment variables for authentication and fetches a list of entries as a basic connectivity test. Ensure `BENCHLING_API_KEY` and `BENCHLING_API_URL` are set."},"warnings":[{"fix":"Replace string literals (e.g., `'DNA_OLIGO'`) with actual enum members (e.g., `PartType.DNA_OLIGO`). Refer to the specific enum class for valid members.","message":"As of `benchling-sdk` v1.23.0, API class methods and client initialization no longer accept string arguments for enum types. You must pass actual enum members.","severity":"breaking","affected_versions":">=1.23.0"},{"fix":"Prefer `response.items` for the current page's results or use `response.to_iterator()` for efficient iteration over all pages. Always check the official documentation for the recommended pagination pattern.","message":"The SDK's pagination mechanism has evolved. Direct access to `response.results` might be deprecated or behave differently in newer versions compared to `response.items` or explicit iterators.","severity":"gotcha","affected_versions":"Pre-1.11.0 to current"},{"fix":"Implement retry logic with exponential backoff. Monitor `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` headers in the response for current rate limit status.","message":"Benchling API has rate limits. Frequent or large requests without proper handling can lead to `429 Too Many Requests` errors.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed in your active environment: `pip install benchling-sdk`","cause":"The `benchling-sdk` package is not installed or the Python environment is incorrect.","error":"ModuleNotFoundError: No module named 'benchling_sdk'"},{"fix":"Set `BENCHLING_API_KEY` and `BENCHLING_API_URL` environment variables correctly. Double-check your API key and URL for typos or expiration.","cause":"Invalid or missing `BENCHLING_API_KEY` or `BENCHLING_API_URL` environment variables.","error":"benchling_sdk.lib.api_client_error.BenchlingApiClientError: 401 Unauthorized"},{"fix":"Review the specific error details in the API response message. Ensure all required fields are present and their types/formats match the API documentation for the endpoint. If using enums (for v1.23.0+), pass the actual enum member (e.g., `PartType.DNA_OLIGO`) rather than a string.","cause":"The data sent in the request body (e.g., when creating an entity) does not conform to the expected API schema, or an enum value was passed as a string instead of an enum member.","error":"benchling_sdk.lib.api_client_error.BenchlingApiClientError: 400 Bad Request (Validation Error)"}]}