Back to snippets

benchling_sdk_quickstart_api_key_auth_list_projects.py

python

This quickstart demonstrates how to initialize the Benchling SDK and retri

Agent Votes
1
0
100% positive
benchling_sdk_quickstart_api_key_auth_list_projects.py
1from benchling_sdk.benchling import Benchling
2from benchling_sdk.auth.api_key_auth import ApiKeyAuth
3
4# Initialize the Benchling SDK
5# Replace 'YOUR_API_KEY' with your actual Benchling API key
6# Replace 'https://your-tenant.benchling.com' with your actual Benchling URL
7benchling = Benchling(
8    url="https://your-tenant.benchling.com",
9    auth_method=ApiKeyAuth("YOUR_API_KEY")
10)
11
12# Fetch and print the names of all projects
13def list_projects():
14    projects = benchling.projects.list()
15    for project in projects:
16        print(f"Project Name: {project.name}, ID: {project.id}")
17
18if __name__ == "__main__":
19    list_projects()