[ PROMPT_NODE_26242 ]
sdk_reference
[ SKILL_DOCUMENTATION ]
# Benchling Python SDK 参考
## 安装与设置
### 安装
bash
# 稳定版本
pip install benchling-sdk
# 使用 Poetry
poetry add benchling-sdk
# 预发布/预览版本(不建议用于生产环境)
pip install benchling-sdk --pre
poetry add benchling-sdk --allow-prereleases
### 要求
- Python 3.7 或更高版本
- 在您的 Benchling 租户上启用了 API 访问权限
### 基本初始化
python
from benchling_sdk.benchling import Benchling
from benchling_sdk.auth.api_key_auth import ApiKeyAuth
benchling = Benchling(
url="https://your-tenant.benchling.com",
auth_method=ApiKeyAuth("your_api_key")
)
## SDK 架构
### 主要类
**Benchling 客户端:**
`benchling_sdk.benchling.Benchling` 类是所有 SDK 交互的根节点。它提供了对所有资源端点的访问:
python
benchling.dna_sequences # DNA 序列操作
benchling.rna_sequences # RNA 序列操作
benchling.aa_sequences # 氨基酸序列操作
benchling.custom_entities # 自定义实体操作
benchling.mixtures # 混合物操作
benchling.containers # 容器操作
benchling.boxes # 盒子操作
benchling.locations # 位置操作
benchling.plates # 板操作
benchling.entries # 实验记录本条目操作
benchling.workflow_tasks # 工作流任务操作
benchling.requests # 请求操作
benchling.folders # 文件夹操作
benchling.projects # 项目操作
benchling.users # 用户操作
benchling.teams # 团队操作
### 资源模式
所有资源均遵循一致的 CRUD 模式:
python
# 创建
resource.create(CreateModel(...))
# 读取 (单个)
resource.get(id="resource_id")
# 读取 (列表)
resource.list(optional_filters...)
# 更新
resource.update(id="resource_id", UpdateModel(...))
# 归档/删除
resource.archive(id="resource_id")
## 实体管理
### DNA 序列
**创建:**
python
from benchling_sdk.models import DnaSequenceCreate
sequence = benchling.dna_sequences.create(
DnaSequenceCreate(
name="pET28a-GFP",
bases="ATCGATCGATCG",
is_circular=True,
folder_id="fld_abc123",
schema_id="ts_abc123",
fields=benchling.models.fields({
"gene_name": "GFP",
"resistance": "Kanamycin",
"copy_number"