Back to all questions

Is there a Python SDK for the API?

API Usage
api
python
sdk

Yes, the MatCraft Python SDK provides a high-level interface to the API:

bash
pip install matcraft
python
from matcraft import MatCraftClient

client = MatCraftClient()  # guest access
# or
client = MatCraftClient(token="YOUR_TOKEN")  # authenticated

# Search
results = client.search(elements=["Si", "O"], band_gap_min=1.0)

# Get detail
material = client.get_material("mp-149")

# Export structure
material.export("poscar", path="output.vasp")

# Band structure
bs = client.get_band_structure("mp-149")
bs.plot()  # matplotlib

# Builder tools (requires auth)
supercell = client.build_supercell("mp-149", nx=2, ny=2, nz=2)

The SDK handles pagination, error handling, and rate limit retries automatically. Full documentation is at matcraft.ai/docs/sdk.

Related Questions