Prerequisites
Ensure you have the Premier League library installed:Basic Server Setup
The simplest way to start the API server:Import and run the server
Create a Python file or use an interactive Python session:The server will start on
http://0.0.0.0:3000 by default.Custom Configuration
Using Function Parameters
Customize the server usingrun_server parameters:
http://127.0.0.1:8000.
Using ServerConfig Object
For more control, use theServerConfig class:
Using YAML Configuration
Using Environment Variables
Testing Endpoints
Once your server is running, test the various endpoints:Get Top Goalscorers
Get League Standings
Get Transfer Information
Export Data to Files
Using the API in Python
You can also call the API from Python using therequests library:
Production Deployment
For production environments, use the production mode with multiple workers:production_config.yaml):
Available Query Parameters
Most endpoints support these common parameters:| Parameter | Type | Description | Example |
|---|---|---|---|
season | string | Filter by season | 2023-2024 |
league | string | Filter by league | Premier League |
limit | integer | Limit number of results | 10 |
team | string | Filter by team name | Arsenal |
filename | string | Export filename (without extension) | my_data |
header | string | Include metadata in response | true |
transfer_type | string | Transfer direction: in, out, or both | in |
Common Error Responses
The API returns structured error messages: Missing Required Parameter:Advanced Usage
Custom Flask App Integration
If you need to integrate the API into an existing Flask application:app.py:33-73 for the create_app function.
Programmatic Server Control
For testing or embedding the server in another application:Function Reference
run_server()
Starts the Premier League API server (defined atapp.py:76-119).
Parameters:
host(str, optional): Host to bind to. Default:"0.0.0.0"port(int, optional): Port to bind to. Default:3000debug(bool, optional): Enable debug mode. Default:Falseconfig_path(str, optional): Path to YAML config file. Default:Noneconfig_dict(dict, optional): Dictionary of configuration options. Default:Nonemode(str, optional): Run mode -"development"or"production". Default:"development"workers(int, optional): Number of Gunicorn workers (production mode only). Default:1
Next Steps
API Reference
Explore detailed endpoint documentation
Flask API Overview
Learn about architecture and features