Python SDK for the MolBuilder REST API
Project description
molbuilder-client
Python SDK for the MolBuilder REST API.
Install
pip install molbuilder-client
Requires Python 3.11+. The only runtime dependency is httpx.
Quickstart
from molbuilder_client import MolBuilder
client = MolBuilder(api_key="mb_...")
# Parse a SMILES string
mol = client.from_smiles("CCO", name="ethanol")
print(mol.id, mol.num_atoms) # mol_xxxx 9
# Get molecular properties
props = client.get_properties(mol.id)
print(props.formula, props.molecular_weight) # C2H6O 46.07
# Get 3D coordinates
structure = client.get_3d(mol.id)
for atom in structure.atoms:
print(atom.symbol, atom.position)
# Look up an element
fe = client.get_element("Fe")
print(fe.name, fe.atomic_weight) # Iron 55.845
# Retrosynthesis
plan = client.retrosynthesis("c1ccccc1O") # phenol
print(plan.routes_found, plan.best_route.total_steps)
# Process evaluation
proc = client.process_evaluate("CCO", scale_kg=100.0)
print(proc.cost.total_usd, proc.cost.per_kg_usd)
Async usage
import asyncio
from molbuilder_client import AsyncMolBuilder
async def main():
async with AsyncMolBuilder(api_key="mb_...") as client:
mol = await client.from_smiles("CCO")
props = await client.get_properties(mol.id)
print(props.formula)
asyncio.run(main())
Error handling
All API errors raise typed exceptions that inherit from MolBuilderError:
from molbuilder_client import MolBuilder, ValidationError, RateLimitError
client = MolBuilder(api_key="mb_...")
try:
client.from_smiles("not_valid")
except ValidationError as e:
print(f"Bad SMILES: {e.message}")
except RateLimitError as e:
print(f"Slow down! Retry after {e.retry_after}s")
| HTTP Status | Exception |
|---|---|
| 401 | AuthenticationError |
| 403 | ForbiddenError |
| 404 | NotFoundError |
| 422 | ValidationError |
| 429 | RateLimitError |
| 500 | ServerError |
| 501/503 | ServiceUnavailableError |
API reference
Auth
| Method | Returns | Description |
|---|---|---|
register(email) |
APIKeyInfo |
Register a new free-tier API key |
get_token() |
Token |
Exchange API key for a JWT |
Molecule
| Method | Returns | Description |
|---|---|---|
from_smiles(smiles, name="") |
MoleculeInfo |
Parse SMILES into a molecule |
get_properties(mol_id) |
MoleculeProperties |
Computed molecular properties |
get_3d(mol_id) |
Molecule3D |
3D coordinates and bonds |
Elements
| Method | Returns | Description |
|---|---|---|
get_element(symbol) |
Element |
Look up element by symbol |
Retrosynthesis
| Method | Returns | Description |
|---|---|---|
retrosynthesis(smiles, max_depth=5, beam_width=5) |
RetrosynthesisPlan |
Plan retrosynthetic routes |
Process
| Method | Returns | Description |
|---|---|---|
process_evaluate(smiles, scale_kg=1.0, max_depth=5, beam_width=5) |
ProcessEvaluation |
Full process engineering report |
Billing
| Method | Returns | Description |
|---|---|---|
create_checkout(plan) |
CheckoutSession |
Create Stripe checkout session |
billing_status() |
BillingStatus |
Current subscription status |
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file molbuilder_client-0.2.0.tar.gz.
File metadata
- Download URL: molbuilder_client-0.2.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21b6f20d666026a14906a49dbe69aeaf28cb56d4052cb6820a145fd5ca01b211
|
|
| MD5 |
37096a620eddbe05cce85319ba81e9d0
|
|
| BLAKE2b-256 |
bac8a8c91d8ad929840157b10a908924200760c5e2852bdfe8fd899d179d067f
|
Provenance
The following attestation bundles were made for molbuilder_client-0.2.0.tar.gz:
Publisher:
release-sdk.yml on Taylor-C-Powell/Molecule_Builder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molbuilder_client-0.2.0.tar.gz -
Subject digest:
21b6f20d666026a14906a49dbe69aeaf28cb56d4052cb6820a145fd5ca01b211 - Sigstore transparency entry: 1001673446
- Sigstore integration time:
-
Permalink:
Taylor-C-Powell/Molecule_Builder@31d18993375035b3b665bb201506cb884ecfe69d -
Branch / Tag:
refs/tags/sdk-v0.2.0 - Owner: https://github.com/Taylor-C-Powell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk.yml@31d18993375035b3b665bb201506cb884ecfe69d -
Trigger Event:
push
-
Statement type:
File details
Details for the file molbuilder_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: molbuilder_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b59e4c20edd153e78e08dba1ab10c1338a34be33b9d97a0d1b849df969e3127b
|
|
| MD5 |
8382b7f504951ab334a80198d1a70f44
|
|
| BLAKE2b-256 |
641ce00228da1e25d6b2a1b3344b6d46895a7d4371c92b816ab9a9549ed1b2cb
|
Provenance
The following attestation bundles were made for molbuilder_client-0.2.0-py3-none-any.whl:
Publisher:
release-sdk.yml on Taylor-C-Powell/Molecule_Builder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molbuilder_client-0.2.0-py3-none-any.whl -
Subject digest:
b59e4c20edd153e78e08dba1ab10c1338a34be33b9d97a0d1b849df969e3127b - Sigstore transparency entry: 1001673447
- Sigstore integration time:
-
Permalink:
Taylor-C-Powell/Molecule_Builder@31d18993375035b3b665bb201506cb884ecfe69d -
Branch / Tag:
refs/tags/sdk-v0.2.0 - Owner: https://github.com/Taylor-C-Powell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk.yml@31d18993375035b3b665bb201506cb884ecfe69d -
Trigger Event:
push
-
Statement type: