Welcome to pythonanywhere-core
API wrapper for programmatic management of PythonAnywhere services.
pythonanywhere-core provides a Python interface for managing webapps, files, scheduled tasks,
students, and websites via the PythonAnywhere API. It serves as the core library behind the
PythonAnywhere CLI tool and PythonAnywhere MCP server.
Quick Start
Install the library:
pip install pythonanywhere-core
Set up your API token (if running outside PythonAnywhere):
export API_TOKEN="your_token_from_pythonanywhere_account_page"
Note
Creating your API token: Go to the “Account” page on PythonAnywhere, then to the “API Token” tab, and click “Create a new API token”.
If you’re running code on PythonAnywhere itself, the token is automatically available.
You only need to set API_TOKEN when running locally or from external servers.
See Environment Variables for more details on configuration.
Create your first webapp:
from pythonanywhere_core.webapp import Webapp
from pathlib import Path
webapp = Webapp("yourusername.pythonanywhere.com")
webapp.create(
python_version="3.12",
virtualenv_path=Path("/home/yourusername/.virtualenvs/myenv"),
project_path=Path("/home/yourusername/myproject"),
nuke=False
)
webapp.reload()
Documentation
- 📖 Reference Documentation
Complete technical specifications for all modules, classes, and functions.
Environment Variables - Configuration via environment variables
Python Versions - Supported Python versions
Exceptions - Exception types and error handling
API Reference - Complete API reference
Installation
Install via pip:
pip install pythonanywhere-core
For development:
git clone https://github.com/pythonanywhere/pythonanywhere-core.git
cd pythonanywhere-core
poetry install
See Installation for more details.
Features
Webapp Management: Create, configure, reload, and delete WSGI web applications (Django, Flask, etc.)
Website Management: Handle domains and website configuration for ASGI and other apps (FastAPI, Streamlit, etc.)
File Operations: Upload, download, delete, and share files
SSL Configuration: Set up and manage SSL certificates
Scheduled Tasks: Create and manage scheduled tasks
Student Management: Manage student accounts (for teachers)
Links
GitHub Repository: https://github.com/pythonanywhere/pythonanywhere-core
PyPI Package: https://pypi.org/project/pythonanywhere-core/
PythonAnywhere API Docs: https://help.pythonanywhere.com/pages/API/
Issue Tracker: https://github.com/pythonanywhere/pythonanywhere-core/issues