This directory contains example scripts demonstrating how to use the ManicTime Python client for various common tasks.
All examples require the basic ManicTime client to be installed:
pip install -e .Some examples have additional requirements that are noted in their documentation.
Demonstrates how to connect to the ManicTime API and retrieve basic timeline data.
# From the manictime_client directory
python examples/basic_usage.py
# Or as a module
python -m examples.basic_usageShows how to retrieve and analyze activity data organized by day.
# From the manictime_client directory
python examples/daily_activities.py
# Or as a module
python -m examples.daily_activitiesCreates charts and visualizations from ManicTime data.
Requirements:
- pandas
- matplotlib
- seaborn (optional, for better styling)
# Install dependencies
pip install pandas matplotlib seaborn
# From the manictime_client directory
# Run with default settings (30 days)
python examples/data_visualization.py
# Run with custom days
python examples/data_visualization.py 14 # analyze last 14 days
# Or as a module
python -m examples.data_visualization
python -m examples.data_visualization 14Output will be saved to a manictime_visualizations directory.
Exports ManicTime data to CSV or JSON files for further analysis in other tools.
# From the manictime_client directory
# Export last 30 days to CSV
python examples/export_to_csv.py
# Export with custom options
python examples/export_to_csv.py --days 14 --output my_data --format both
# Or as a module
python -m examples.export_to_csv
python -m examples.export_to_csv --days 14 --output my_data --format bothCommand line options:
--days: Number of days to export (default: 30)--output: Output directory (default: manictime_export)--format: Export format: csv, json, or both (default: csv)
All examples load configuration from environment variables. Before running, you must create a .env file in the manictime_client directory with your ManicTime server settings.
- Copy the template file:
cp .env.template .env- Edit the
.envfile with your actual credentials:
MANICTIME_SERVER_URL=http://your-manictime-server
MANICTIME_AUTH_TYPE=bearer # or ntlm
MANICTIME_TOKEN=your-access-token # for bearer auth
# Alternatively for username/password auth:
# MANICTIME_USERNAME=your-username
# MANICTIME_PASSWORD=your-password
# MANICTIME_DOMAIN=your-domain # for NTLM auth
Choose one of these authentication methods:
Bearer Token Authentication:
MANICTIME_AUTH_TYPE=bearer
MANICTIME_TOKEN=your-access-token
Username/Password Authentication:
MANICTIME_AUTH_TYPE=bearer
MANICTIME_USERNAME=your-username
MANICTIME_PASSWORD=your-password
NTLM Authentication (Windows Authentication):
MANICTIME_AUTH_TYPE=ntlm
MANICTIME_USERNAME=your-username
MANICTIME_PASSWORD=your-password
MANICTIME_DOMAIN=your-domain # if applicable
To test if your authentication is working correctly:
# From the manictime_client directory
python -c "from manictime import ManicTimeClient, Config; client = ManicTimeClient(Config.from_env()); print(client.get_timelines())"If this returns a list of timelines, your authentication is working properly.
If you need to get a bearer token:
- Use the C# client's login command:
mtapi auth login --server-url <server URL> --username <username> --password <password>
- Or follow the documentation for your ManicTime server's authentication endpoints