API Reference
This section provides detailed API documentation for figpack.
Core Modules
figpack - A Python package for creating shareable, interactive visualizations in the browser
- class figpack.ExtensionView(*, extension: FigpackExtension, view_type: str)[source]
Bases:
FigpackView
Base class for views that are rendered by figpack extensions
- class figpack.FigpackExtension(*, name: str, javascript_code: str, additional_files: Dict[str, str] | None = None, version: str = '1.0.0')[source]
Bases:
object
Base class for figpack extensions that provide custom view components
- class figpack.FigpackView[source]
Bases:
object
Base class for all figpack visualization components
- save(output_path: str, *, title: str) None [source]
Save as figure either to a folder or to a .tar.gz file :param output_path: Output path (destination folder or .tar.gz file path)
- show(*, title: str, description: str | None = None, port: int | None = None, open_in_browser: bool | None = None, upload: bool | None = None, inline: bool | None = None, inline_height: int = 600, ephemeral: bool | None = None, allow_origin: str | None = None, wait_for_input: bool | None = None, _dev: bool | None = None)[source]
Display a figpack view component with intelligent environment detection and flexible display options. See https://flatironinstitute.github.io/figpack/show_function.html for complete documentation.
Automatically adapts behavior based on context (Jupyter, Colab, JupyterHub, standalone). Display modes include local browser, inline notebook, and remote upload with ephemeral options. Environment variables (FIGPACK_UPLOAD, FIGPACK_INLINE, FIGPACK_OPEN_IN_BROWSER) can control default behaviors.
- Parameters:
title – Title for browser tab and figure (required)
description – Description text with markdown support (optional)
port – Local server port, random if None
open_in_browser – Auto-open in browser, auto-detects by environment
upload – Upload figure to figpack servers, auto-detects by environment
ephemeral – Use temporary figure for cloud notebooks, auto-detects
inline – Display inline in notebook, auto-detects by environment
inline_height – Height in pixels for inline display (default: 600)
allow_origin – CORS allow-origin header for local server
wait_for_input – Wait for Enter before continuing, auto-detects
_dev – Developer mode for figpack development
Views
Core Views
Core Functionality
The core functionality includes the essential show()
function used to display and share visualizations. For detailed documentation of this crucial function and all its configuration options, see the show() function reference.
- class figpack.core.ExtensionView(*, extension: FigpackExtension, view_type: str)[source]
Bases:
FigpackView
Base class for views that are rendered by figpack extensions
- class figpack.core.FigpackExtension(*, name: str, javascript_code: str, additional_files: Dict[str, str] | None = None, version: str = '1.0.0')[source]
Bases:
object
Base class for figpack extensions that provide custom view components
- class figpack.core.FigpackView[source]
Bases:
object
Base class for all figpack visualization components
- save(output_path: str, *, title: str) None [source]
Save as figure either to a folder or to a .tar.gz file :param output_path: Output path (destination folder or .tar.gz file path)
- show(*, title: str, description: str | None = None, port: int | None = None, open_in_browser: bool | None = None, upload: bool | None = None, inline: bool | None = None, inline_height: int = 600, ephemeral: bool | None = None, allow_origin: str | None = None, wait_for_input: bool | None = None, _dev: bool | None = None)[source]
Display a figpack view component with intelligent environment detection and flexible display options. See https://flatironinstitute.github.io/figpack/show_function.html for complete documentation.
Automatically adapts behavior based on context (Jupyter, Colab, JupyterHub, standalone). Display modes include local browser, inline notebook, and remote upload with ephemeral options. Environment variables (FIGPACK_UPLOAD, FIGPACK_INLINE, FIGPACK_OPEN_IN_BROWSER) can control default behaviors.
- Parameters:
title – Title for browser tab and figure (required)
description – Description text with markdown support (optional)
port – Local server port, random if None
open_in_browser – Auto-open in browser, auto-detects by environment
upload – Upload figure to figpack servers, auto-detects by environment
ephemeral – Use temporary figure for cloud notebooks, auto-detects
inline – Display inline in notebook, auto-detects by environment
inline_height – Height in pixels for inline display (default: 600)
allow_origin – CORS allow-origin header for local server
wait_for_input – Wait for Enter before continuing, auto-detects
_dev – Developer mode for figpack development
Command Line Interface
Command-line interface for figpack
- figpack.cli.download_figure(figure_url: str, dest_path: str) None [source]
Download a figure from a figpack URL and save as tar.gz
- Parameters:
figure_url – The figpack URL
dest_path – Destination path for the tar.gz file
- figpack.cli.download_file(base_url: str, file_info: Dict, temp_dir: Path) Tuple[str, bool] [source]
Download a single file from the figure
- Parameters:
base_url – The base URL for the figure
file_info – Dictionary with ‘path’ and ‘size’ keys
temp_dir – Temporary directory to download to
- Returns:
Tuple of (file_path, success)
Usage Examples
For practical examples of using the API, see the Examples section.