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:
FigpackViewBase 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:
objectBase class for figpack extensions that provide custom view components
- class figpack.FigpackView[source]
Bases:
objectBase class for all figpack visualization components
- save(output_path: str, *, title: str, description: str = '', script: 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) :param title: Title for the figure :param description: Description text with markdown support :param script: Optional script text used to generate the figure
- show(*, title: str, description: str | None = None, script: 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)
script – Optional script text used to generate the figure
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
- class figpack.Group(zarr_group)[source]
Bases:
object- property attrs: Dict[str, Any]
- figpack.patch_figure(figure_url: str, *, admin_override: bool = False, interactive: bool = True, verbose: bool = True) bool[source]
Patch a figure by updating its rendering code to the latest version
- Parameters:
figure_url – The figpack URL to patch
admin_override – If True, allows admins to patch figures they don’t own
interactive – If True, prompts for user confirmation before proceeding
verbose – If True, prints status messages
- Returns:
True if successful, False otherwise
- Return type:
bool
- figpack.revert_patch_figure(figure_url: str, admin_override: bool = False, interactive: bool = True, verbose: bool = True) bool[source]
Revert a patched figure to its previous rendering code
- Parameters:
figure_url – The figpack URL to revert
admin_override – If True, allows admins to revert figures they don’t own
interactive – If True, prompts for user confirmation before proceeding
verbose – If True, prints status messages
- Returns:
True if successful, False otherwise
- Return type:
bool
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:
FigpackViewBase 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:
objectBase class for figpack extensions that provide custom view components
- class figpack.core.FigpackView[source]
Bases:
objectBase class for all figpack visualization components
- save(output_path: str, *, title: str, description: str = '', script: 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) :param title: Title for the figure :param description: Description text with markdown support :param script: Optional script text used to generate the figure
- show(*, title: str, description: str | None = None, script: 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)
script – Optional script text used to generate the figure
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_and_view_archive(url: str, port: int | None = None) None[source]
Download a tar.gz/tgz archive from a URL and view it
- Parameters:
url – URL to the tar.gz or tgz file
port – Optional port number to serve on
- 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)
- figpack.cli.get_figure_base_url(figure_url: str) str[source]
Get the base URL from any figpack URL
- Parameters:
figure_url – Any figpack URL (may or may not end with /index.html)
- Returns:
The base URL for the figure directory
- Return type:
str
- figpack.cli.patch_figure(figure_url: str, admin_override: bool = False) None[source]
CLI wrapper for patching a figure by updating its rendering code to the latest version
- Parameters:
figure_url – The figpack URL to patch
api_key – API key for authentication
admin_override – If True, allows admins to patch figures they don’t own
Usage Examples
For practical examples of using the API, see the Examples section.