Widget in Jupyter NotebookExporting Projects

Exporting Projects

Export your Cosmograph visualizations to the Cosmograph web application to publish them as interactive web projects. For basic usage, see Get started. All configuration settings are automatically exported with your project (see Configuration).

API Key Setup

Before exporting, you need to set up your API key. Get your API key from your account settings on the Cosmograph web application.

There are two ways to set your API key:

1. Global API key (applies to all widgets):

from cosmograph import set_api_key
 
set_api_key("your-api-key-here")

2. Instance-specific API key (overrides global key for a specific widget):

widget = cosmo(
    points=df,
    point_id_by='id',
    api_key="instance-specific-key"
)

Basic Export

Export a project using the export_project_by_name() method:

import pandas as pd
from cosmograph import cosmo, set_api_key
 
set_api_key("your-api-key")
 
points = pd.DataFrame({
    'id': ['A', 'B', 'C'],
    'label': ['Node A', 'Node B', 'Node C'],
    'category': ['X', 'Y', 'X']
})
 
links = pd.DataFrame({
    'source': ['A', 'B'],
    'target': ['B', 'C']
})
 
widget = cosmo(
    points=points,
    links=links,
    point_id_by='id',
    link_source_by='source',
    link_target_by='target',
    point_color_by='category'
)
 
project_id = widget.export_project_by_name("My Network Visualization")
print(f"Project available at: https://run.cosmograph.app/project/{project_id}")

Method signature:

widget.export_project_by_name(project_name: str, debug: bool = False) -> str
  • project_name: Name for your project
  • debug: Enable detailed logging. Default: False
  • Returns: Project ID (use it to construct the URL)

Debug Mode

Enable debug mode for detailed logging:

project_id = widget.export_project_by_name("My Project", debug=True)

This shows timing information, configuration details, data statistics, and error messages.