OpenML APIs
OpenML provides a unified interface to access machine learning resources across multiple programming languages. Whether you're exploring datasets, running experiments, or benchmarking algorithms, our APIs make it easy to integrate OpenML into your workflow.
10,000+ Datasets
Access curated ML datasets with rich metadata
50,000+ Tasks
Pre-defined ML tasks with standardized evaluation
10M+ Runs
Reproducible experiments and benchmarks
Getting Started
Installation
The Python API provides the most comprehensive access to OpenML functionality, with full support for scikit-learn, PyTorch, and TensorFlow.
Installation
pip install openmlExample
1234567import openml # Configure your API key (optional for read-only access)openml.config.apikey = 'YOUR_API_KEY' # Verify installationprint(f"OpenML version: {openml.__version__}")Authentication
API Key Required for Uploads
How to get your API key:
- 1Create an OpenML account or sign in if you already have one
- 2Go to your API Key page in your account settings
- 3Copy your API key and store it securely (never share it publicly!)
# Store your API key securely
# Option 1: Environment variable (recommended)
export OPENML_APIKEY="your_api_key_here"
# Option 2: Config file (~/.openml/config)
apikey = your_api_key_here
# Option 3: Set in code (not recommended for shared code)
import openml
openml.config.apikey = "your_api_key_here"Client Libraries
Working with Data
Datasets
OpenML hosts thousands of curated ML datasets. Each dataset includes rich metadata, feature descriptions, and quality metrics.
Example
12345678910111213141516import openml # Get a dataset by name or IDdataset = openml.datasets.get_dataset("credit-g") # or get_dataset(31) # Access the dataX, y, categorical_indicator, attribute_names = dataset.get_data( target="class") # List available datasetsdatasets = openml.datasets.list_datasets(output_format="dataframe")print(f"Found {len(datasets)} datasets") # Search for specific datasetsfiltered = datasets[datasets['NumberOfInstances'] > 1000]Tasks
Tasks combine a dataset with a problem type (classification, regression, etc.) and evaluation procedure (cross-validation folds).
Example
123456789101112131415import openml # Get a task (supervised classification on credit-g)task = openml.tasks.get_task(31) # Access task propertiesprint(f"Task type: {task.task_type}")print(f"Dataset: {task.dataset_id}")print(f"Target: {task.target_name}") # Get train/test splitstrain_indices, test_indices = task.get_train_test_split_indices(fold=0) # List available taskstasks = openml.tasks.list_tasks(output_format="dataframe")Runs & Experiments
Runs capture the complete record of an ML experiment: the algorithm used, hyperparameters, predictions, and evaluation metrics.
Example
1234567891011121314151617import openmlfrom sklearn.ensemble import RandomForestClassifier # Get a tasktask = openml.tasks.get_task(31) # Create and run a modelclf = RandomForestClassifier(n_estimators=100, random_state=42)run = openml.runs.run_model_on_task(clf, task) # Upload results to OpenMLrun.publish()print(f"Run ID: {run.run_id}") # View evaluation resultsfor metric, value in run.fold_evaluations.items(): print(f"{metric}: {value}")Benchmarking
OpenML provides curated benchmark suites for standardized algorithm evaluation. Run your models on established benchmarks to compare with state-of-the-art methods.
OpenML-CC18
72 classification datasets
AutoML Benchmark
Standard AutoML evaluation
Example
123456789101112131415161718import openml # Get a benchmark suitesuite = openml.study.get_suite("OpenML-CC18") # Classification benchmark # Iterate over tasks in the suitefor task_id in suite.tasks: task = openml.tasks.get_task(task_id) print(f"Task {task_id}: {task.get_dataset().name}") # Run your model on the entire benchmarkfrom sklearn.ensemble import GradientBoostingClassifier for task_id in suite.tasks[:5]: # First 5 tasks task = openml.tasks.get_task(task_id) clf = GradientBoostingClassifier() run = openml.runs.run_model_on_task(clf, task) run.publish()Rate Limits
Fair Use Policy
REST API
For advanced users who need direct HTTP access, OpenML provides a comprehensive REST API. The API is language-agnostic and can be used from any environment.
Base URL: https://www.openml.org/api/v1/
Supports both JSON and XML response formats. Authentication via API key is required for write operations.



