API Documentation

Complete guide to accessing Red Sox statistics and data through our API

Introduction

Welcome to the FenwayStats API! This API provides comprehensive access to Red Sox data, including player statistics, game results, and team news. The API is read-only and all data is managed by the FenwayStats team.

Base URL

http://fenwaystats.com

Authentication

All API requests require an API key, which must be included in the request headers:

Authorization: ApiKey YOUR_API_KEY

API Key Expiration & Renewal

  • Your API key is **valid for 365 days** from activation.
  • Adding funds **does not extend expiration**β€”it only increases your request count.
  • Once expired, you must **purchase a new API key**.
  • Need more requests? Click here to Add Funds β†’

Rate Limits

To ensure fair usage, rate limits apply to all API keys:

  • Max **10 requests per minute**.
  • Max **100 requests per day**.
  • Requests exceeding limits return a 429 Too Many Requests response.

How to Increase Limits?

  • Default rate limits apply to all users.
  • Need higher limits? Contact admin support.
  • More requests available through the Add Funds β†’ feature.

Players API

Endpoint

GET /api/players/

Response Example

                                    {
                                    "id": 1,
                                    "first_name": "Rafael",
                                    "last_name": "Devers",
                                    "team": "Red Sox",
                                    "position": "3B",
                                    "batting_average": 0.345
                                    }

Games API

The Games API provides information about past and upcoming games, including scores, opponents, and game numbers.

Endpoint

GET /api/games/

Response Example

                        {
                            "id": 1,
                            "number": 3,
                            "date": "2025-04-17",
                            "opponent": "Baltimore Orioles",
                            "red_sox_score": 5,
                            "opponent_score": 3,
                            "slug": "baltimore-orioles-2025-04-17"
                        }

Fetching Game Details

To retrieve details for a specific game, use its slug:

GET /api/games/<slug>/

Game Stats API

Endpoint

GET /api/gamestats/

Response Example

                                        {
                                        "player": {
                                            "id": 1,
                                            "first_name": "Rafael",
                                            "last_name": "Devers"
                                        },
                                        "game": {
                                            "id": 1,
                                            "date": "2025-04-17",
                                            "opponent": "Baltimore Orioles"
                                        },
                                        "stats": {
                                            "at_bats": 5,
                                            "hits": 2,
                                            "runs": 1
                                        }
                                        }

News API

Endpoint

GET /api/news/

Response Example

                                    {
                                    "id": 1,
                                    "title": "Fenway Park Opens for New Season",
                                    "content": "Fenway Park is ready to welcome fans...",
                                    "created_at": "2025-01-25T14:00:00Z",
                                    "updated_at": "2025-01-25T14:00:00Z",
                                    "tags": ["Season Opening", "Fenway Park"],
                                    "featured_image": "http://fenwaystats.com/media/news_images/fenway_park.jpg"
                                    }