RapidAPI Football API integration for AWS Bedrock AgentCore Gateway. Deploy football data access to any gateway as an MCP-compatible target.
This project deploys RapidAPI Football API as an OpenAPI target to AWS Bedrock AgentCore Gateway, enabling AI agents to query:
- European top 5 league fixtures, results, and standings
- UEFA Champions League and Europa League data
- Player statistics (top scorers, assists)
- Domestic cup competitions
- β¨ Fully Automated Deployment: Custom Resource automatically configures Gateway service role permissions
- Multi-Gateway Support: Deploy to multiple gateways with simple environment configuration
- Built-in League IDs: Common leagues pre-configured in tool descriptions, reducing API calls by 50%
- Shared Credentials: One RapidAPI key can be used across multiple gateway deployments
- CDK Asset Management: OpenAPI schema automatically uploaded to CDK staging bucket
- Secure Credentials: RapidAPI key stored in AWS Secrets Manager
- Idempotent: Safe to deploy multiple times, smart permission merging
- Node.js: >= 18.x
- AWS CLI: Configured with credentials
- AWS CDK: >= 2.100.0
- RapidAPI Account: Active subscription to Football API
- Existing Gateway: Target gateway must exist in your AWS account
If you don't have an existing gateway, you need to create one first. The gateway serves as a unified entry point for agents to access tools and resources through the Model Context Protocol (MCP).
Choose one of the following methods to create a gateway:
| Method | Best For | Command Example |
|---|---|---|
| AWS Console | Visual interface, first-time setup | Web UI with step-by-step wizard |
| AWS CLI | Simple automation, IAM auth | aws bedrock-agentcore-control create-gateway --name my-gateway --authorizer-type AWS_IAM ... |
| AgentCore Toolkit | Automatic OAuth setup | agentcore create_mcp_gateway --region us-west-2 --name my-gateway |
aws bedrock-agentcore-control create-gateway \
--name my-gateway \
--role-arn arn:aws:iam::123456789012:role/MyAgentCoreServiceRole \
--protocol-type MCP \
--authorizer-type AWS_IAM \
--region us-west-2Save these values from the output:
gatewayIdentifierβ Use in.envfile asGATEWAY_IDENTIFIERgatewayUrlβ MCP endpoint URL for connecting clientsroleArnβ Gateway service role ARN
- Semantic Search: Can only be enabled during gateway creation (cannot be changed later)
- IAM Permissions: This CDK stack automatically adds credential provider permissions via Custom Resource
- Service Role: You only need basic gateway permissions; credential provider access is added automatically
π Complete Documentation:
npm installCopy .env.example to a gateway-specific env file:
cp .env.example .env.my-gateway.local
# Edit and set:
# - GATEWAY_IDENTIFIER: Your gateway identifier
# - CREDENTIAL_PROVIDER_NAME: Your credential provider nameStep 1: Create the credential provider
# Create credential provider (only once for shared strategy)
aws bedrock-agentcore-control create-api-key-credential-provider \
--name FootballAPICredentialProvider \
--description "RapidAPI Football API Key (shared)" \
--profile default --region <YOUR_REGION>Step 2: Store your RapidAPI key
Get your RapidAPI key from: https://rapidapi.com/api-sports/api/api-football
Then update the credential provider with your API key:
# IMPORTANT: Use bedrock-agentcore-control to update the API key
# DO NOT use secretsmanager put-secret-value directly
aws bedrock-agentcore-control update-api-key-credential-provider \
--name FootballAPICredentialProvider \
--api-key "YOUR_RAPID_API_KEY" \
--profile default --region <YOUR_REGION>Why use update-api-key-credential-provider?
- The secret is managed by the
bedrock-agentcore-identityservice - Direct Secrets Manager operations may fail due to service ownership
- This command ensures proper formatting (
{"apiKey": "..."}) automatically - Provides better error messages for invalid keys
Common Issues:
- β Wrong:
{"api_key": "..."}or{"api_key_value": "..."} - β
Correct:
{"apiKey": "..."}(handled automatically by the command) - If API calls return "Error/Missing application key", verify the key was updated successfully
cdk bootstrap --profile default./deploy.sh .env.my-gateway.localβββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AWS Bedrock AgentCore Gateway (pre-existing) β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
β β GatewayRoleUpdater (Custom Resource) β β
β β β Automatically adds IAM permissions β β
β β β to Gateway service role β β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
β β FootballAPITarget (OpenAPI Target) β β
β β β β
β β β’ OpenAPI Schema (CDK Asset β S3) β β
β β β’ API Key (Secrets Manager) β β
β β β’ Credential Provider: API_KEY β β
β β β’ Headers: x-rapidapi-key, x-rapidapi-hostβ β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
β β Available Tools: β β
β β β’ getFixtures β β
β β β’ getStandings β β
β β β’ getTopScorers β β
β β β’ getTopAssists β β
β β β’ getLeagues (fallback) β β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β RapidAPI Key from Secrets Manager
βΌ
RapidAPI Football API v3
(https://v3.football.api-sports.io)
cdk deploy
β
1. GatewayRoleUpdater (Custom Resource)
βββ Lambda checks Gateway service role
βββ Adds missing IAM permissions
βββ β
Role updated automatically
β
2. OpenAPI Schema Asset
βββ Upload to S3
β
3. Gateway Target
βββ Reference Gateway
βββ Reference Credential Provider
βββ Link OpenAPI schema from S3
β
β
Target READY (fully automated)
Get match fixtures, results, and schedules.
Parameters:
league(integer): League ID (see common IDs below)season(integer, required): Season year (e.g., 2024 for 2024/2025 season)date(string): Match date (YYYY-MM-DD)last(integer): Get last N matchesnext(integer): Get next N upcoming matchesstatus(string): Match status (FT=Full Time, LIVE=In Progress, NS=Not Started)team(integer): Filter by team ID
Examples:
// Premier League last 10 matches
{ league: 39, season: 2024, last: 10 }
// Champions League next 5 matches
{ league: 2, season: 2024, next: 5 }
// La Liga matches on specific date
{ league: 140, season: 2024, date: "2024-11-10" }
// Live matches across all leagues
{ season: 2024, status: "LIVE" }Get league standings/table.
Parameters:
league(integer, required): League IDseason(integer, required): Season yearteam(integer): Specific team ID
Examples:
// Premier League standings
{ league: 39, season: 2024 }
// Serie A standings
{ league: 135, season: 2024 }Get top goal scorers.
Parameters:
league(integer, required): League IDseason(integer, required): Season year
Examples:
// Bundesliga top scorers
{ league: 78, season: 2024 }Get top assists leaders.
Parameters:
league(integer, required): League IDseason(integer, required): Season year
Search for leagues (use only for uncommon leagues).
Parameters:
id(integer): Specific league IDname(string): Search by namecountry(string): Filter by countryseason(integer): Filter by seasoncurrent(boolean): Active leagues only
- Premier League (England):
39 - La Liga (Spain):
140 - Serie A (Italy):
135 - Bundesliga (Germany):
78 - Ligue 1 (France):
61
- UEFA Champions League:
2 - UEFA Europa League:
3
- FA Cup (England):
45 - Copa del Rey (Spain):
143 - Coppa Italia (Italy):
137 - DFB Pokal (Germany):
81 - Coupe de France (France):
66
The OpenAPI schema includes common league IDs in tool descriptions, enabling:
- Direct Usage: AI agents can use league IDs immediately for common leagues
- Reduced API Calls: No need to query
getLeaguesfor popular competitions - Faster Response: Eliminates one API round-trip (200-500ms saved)
- Quota Savings: Reduces API usage by ~50% for typical queries
Example Flow (Optimized):
User: "Get Premier League standings"
β Agent directly calls: getStandings({ league: 39, season: 2024 })
β API calls: 1
Example Flow (Unoptimized):
User: "Get Premier League standings"
β Agent calls: getLeagues({ name: "Premier League" })
β Agent calls: getStandings({ league: 39, season: 2024 })
β API calls: 2 β
Football API uses year to represent seasons:
2024= 2024/2025 season (August 2024 - May 2025)2023= 2023/2024 season (August 2023 - May 2024)2022= 2022/2023 season (August 2022 - May 2023)
Example: For matches in November 2024, use season: 2024 (current 2024/2025 season).
Tool: getStandings
Parameters: { "league": 39, "season": 2024 }Tool: getFixtures
Parameters: { "league": 2, "season": 2024, "date": "2024-11-10" }# AI agent can call these in parallel:
getTopScorers({ "league": 39, "season": 2024 }) # Premier League
getTopScorers({ "league": 140, "season": 2024 }) # La Liga
getTopScorers({ "league": 135, "season": 2024 }) # Serie A
getTopScorers({ "league": 78, "season": 2024 }) # Bundesliga
getTopScorers({ "league": 61, "season": 2024 }) # Ligue 1{ "errors": { "requests": "The request limit has been reached" } }Solution: Upgrade RapidAPI plan or wait for quota reset.
{ "errors": { "league": "Invalid league id" } }Solution: Use getLeagues to search for correct league ID.
{ "results": 0, "response": [] }Causes: Incorrect season, inactive league, or date out of range.
- Free Plan: 100 requests/day
- Basic Plan: 500 requests/day ($10/month)
- Pro Plan: 5,000 requests/day ($35/month)
Monitor usage in RapidAPI dashboard: https://rapidapi.com/developer/dashboard
agentcore-gateway-targets/
βββ schemas/
β βββ football-api-openapi.yaml # OpenAPI 3.0 schema with embedded league IDs
βββ lib/
β βββ football-gateway-stack.ts # CDK Stack implementation
βββ bin/
β βββ football-gateway-app.ts # CDK App entry point
βββ deploy.sh # Deployment script for CDK stack
βββ package.json # Node.js dependencies
βββ tsconfig.json # TypeScript configuration
βββ cdk.json # CDK configuration
βββ .env.example # Environment template
βββ .env.*.local # Gateway-specific configs (git-ignored)
βββ CLAUDE.md # Project documentation (environment-agnostic)
βββ CLAUDE.local.md # Environment-specific notes (git-ignored)
βββ README.md # This file
npm run buildnpm run watch# List stacks
cdk list
# Show diff
cdk diff
# Synthesize CloudFormation
cdk synth
# Deploy
cdk deploy --profile default
# Destroy (remove target)
cdk destroy --profile defaultAfter deployment, verify the target:
# List all targets on your gateway
aws bedrock-agentcore-control list-gateway-targets \
--gateway-identifier <YOUR_GATEWAY_IDENTIFIER> \
--profile default --region <YOUR_REGION>
# Get specific target details
aws bedrock-agentcore-control get-gateway-target \
--gateway-identifier <YOUR_GATEWAY_IDENTIFIER> \
--target-id <TARGET_ID_FROM_OUTPUT> \
--profile default --region <YOUR_REGION>- Check gateway exists:
aws bedrock-agentcore-control get-gateway --gateway-identifier <YOUR_GATEWAY_ID> - Verify credential provider exists and has correct name
- Check CloudWatch Logs for errors
- Validate OpenAPI schema syntax
- Verify RapidAPI subscription is active
- Check API key in Secrets Manager
- Ensure x-rapidapi-host header matches
- Review rate limit status
- Ensure all operations have
operationId - Avoid oneOf/anyOf/allOf constructs
- Use simple parameter structures
- Validate with OpenAPI validator: https://validator.swagger.io/
- AgentCore Gateway: Pay per tool invocation
- Lambda (GatewayRoleUpdater): ~$0.01 per deployment (free tier eligible)
- CloudWatch Logs: Negligible (7-day retention)
- Secrets Manager: ~$0.40/month per secret
- S3 Storage: Negligible (schema file < 1KB)
- CloudFormation: No charge
- Free: 100 requests/day
- Basic: $10/month (500 requests/day)
- Pro: $35/month (5,000 requests/day)
- AWS Bedrock AgentCore Documentation
- OpenAPI Specification
- RapidAPI Football API
- API-Football Documentation
See LICENSE file in repository root.