API Reference
megane provides APIs for both Python and TypeScript/JavaScript.
Python
The Python API is used for:
- Jupyter widget — Interactive viewer in a notebook cell (
MolecularViewer) - Standalone web app — Served by
megane serveover WebSocket - Python package — Parse structure files and read trajectories programmatically
import megane
# Quick start
viewer = megane.view("protein.pdb")
# With trajectory
viewer = megane.view_traj("protein.pdb", xtc="trajectory.xtc")
See the Python Pipeline API guide for full documentation of the Pipeline class and all node types.
TypeScript / JavaScript
The TypeScript API is used for:
- React component (npm) — Embed the viewer in web applications (
MeganeViewer) MoleculeRenderercore renderer — Framework-agnostic Three.js rendering- Protocol decoding — Parse binary messages from the
megane servebackend
import { MeganeViewer, MoleculeRenderer } from "megane-viewer/lib";
See the TypeScript Pipeline guide for full documentation of the TypeScript pipeline API and React component props.