{"id":6544,"library":"benchling-api-client","title":"Benchling API Client","description":"An autogenerated Python client library providing programmatic access to the Benchling API. It is generated from Benchling's OpenAPI specification, ensuring it stays up-to-date with the latest API changes. As an auto-generated client, its release cadence typically follows updates to the underlying API specification.","status":"active","version":"2.0.427","language":"en","source_language":"en","source_url":"https://github.com/benchling/benchling-api-client-python","tags":["api-client","benchling","bioinformatics","life-sciences","autogenerated"],"install":[{"cmd":"pip install benchling-api-client","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"BenchlingClient","correct":"from benchling_api_client import BenchlingClient"},{"symbol":"Configuration","correct":"from benchling_api_client import Configuration"},{"note":"Accesses generated data models like models.User or models.AaSequence.","symbol":"models","correct":"from benchling_api_client import models"}],"quickstart":{"code":"import os\nfrom benchling_api_client import BenchlingClient, Configuration\n\n# Benchling API keys are typically associated with a specific tenant.\n# Set these environment variables: BENCHLING_TENANT_NAME, BENCHLING_API_KEY\n# Example host: https://my-org.benchling.com/api/v2\n\nbenchling_tenant = os.environ.get('BENCHLING_TENANT_NAME', 'YOUR_TENANT_NAME')\nbenchling_api_key = os.environ.get('BENCHLING_API_KEY', 'YOUR_API_KEY')\n\nif benchling_tenant == 'YOUR_TENANT_NAME' or benchling_api_key == 'YOUR_API_KEY':\n    print(\"Please set BENCHLING_TENANT_NAME and BENCHLING_API_KEY environment variables.\")\nelse:\n    try:\n        configuration = Configuration(\n            host=f\"https://{benchling_tenant}.benchling.com/api/v2\",\n            api_key={'api_key': benchling_api_key}\n        )\n\n        with BenchlingClient(configuration=configuration) as client:\n            # The client provides direct access to various API namespaces (e.g., users, aa_sequences)\n            users_api = client.users\n            # List users, retrieving only the first page for demonstration\n            response = users_api.list_users(page_size=1)\n            \n            if response.users:\n                print(f\"Found user: {response.users[0].handle} (ID: {response.users[0].id})\")\n            else:\n                print(\"No users found or accessible with this API key.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the Benchling API client using environment variables for credentials and make a simple call to list users. It highlights the required host format and accessing specific API endpoints via the client instance. The code includes a check for unset environment variables."},"warnings":[{"fix":"Refer to the official Benchling API documentation and the client's GitHub release notes for specific migration guides when upgrading across major versions.","message":"Major version updates (e.g., from 1.x to 2.x) in auto-generated clients frequently introduce breaking changes due to underlying API specification evolution. This can include altered method signatures, renamed parameters, or changes in data model structures.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Implement a loop that continuously calls the list method, passing the `next_token` from the previous response until no `next_token` is returned.","message":"Many list endpoints in the Benchling API (e.g., `list_users`, `list_aa_sequences`) are paginated. To retrieve all results, you must iterate through pages using the `next_token` parameter from the response.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your `host` string exactly matches the expected format for your Benchling tenant.","message":"The `host` configuration must be precise, including the `https://` prefix, your tenant name, and the `/api/v2` suffix (e.g., `https://my-org.benchling.com/api/v2`). Omitting parts of this URL is a common configuration error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify that your Benchling API key has the required read/write permissions for the specific resources and operations. Consult your Benchling tenant administrator or the Benchling API documentation on permissions.","message":"API keys have specific scopes and permissions. If you encounter `403 Forbidden` errors, it likely indicates that your API key lacks the necessary permissions for the operation you are attempting. The client itself cannot bypass these API-level restrictions.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}