cfb.js

August 27, 2024 ยท View on GitHub

cfb - JavaScript client for cfb.js This is an API for accessing all sorts of college football data. Please note that API keys should be supplied with "Bearer " prepended (e.g. "Bearer your_key"). API keys can be acquired from the CollegeFootballData.com website. This SDK is automatically generated by the Swagger Codegen project:

  • API version: 4.6.0
  • Package version: 4.6.0
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install cfb.js --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var cfb = require('cfb.js');

var defaultClient = cfb.ApiClient.instance;

// Configure API key authorization: ApiKeyAuth
var ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = "Bearer YOUR_API_KEY";

var api = new cfb.BettingApi()

var opts = { 
  'gameId': 56, // {Number} Game id filter
  'year': 56, // {Number} Year/season filter for games
  'week': 56, // {Number} Week filter
  'seasonType': "regular", // {String} Season type filter (regular or postseason)
  'team': "team_example", // {String} Team
  'home': "home_example", // {String} Home team filter
  'away': "away_example", // {String} Away team filter
  'conference': "conference_example" // {String} Conference abbreviation filter
};
api.getLines(opts).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});


Documentation for API Endpoints

All URIs are relative to https://api.collegefootballdata.com

ClassMethodHTTP requestDescription
cfb.BettingApigetLinesGET /linesBetting lines
cfb.CoachesApigetCoachesGET /coachesCoaching records and history
cfb.ConferencesApigetConferencesGET /conferencesConferences
cfb.DraftApigetDraftPicksGET /draft/picksList of NFL Draft picks
cfb.DraftApigetNFLPositionsGET /draft/positionsList of NFL positions
cfb.DraftApigetNFLTeamsGET /draft/teamsList of NFL teams
cfb.DrivesApigetDrivesGET /drivesDrive data and results
cfb.GamesApigetAdvancedBoxScoreGET /game/box/advancedAdvanced box scores
cfb.GamesApigetCalendarGET /calendarSeason calendar
cfb.GamesApigetGameMediaGET /games/mediaGame media information and schedules
cfb.GamesApigetGameWeatherGET /games/weatherGame weather information (Patreon only)
cfb.GamesApigetGamesGET /gamesGames and results
cfb.GamesApigetPlayerGameStatsGET /games/playersPlayer game stats
cfb.GamesApigetScoreboardGET /scoreboardLive game results (Patreon only)
cfb.GamesApigetTeamGameStatsGET /games/teamsTeam game stats
cfb.GamesApigetTeamRecordsGET /recordsTeam records
cfb.MetricsApigetFGEPGET /metrics/fg/epField Goal Expected Points
cfb.MetricsApigetGamePPAGET /ppa/gamesTeam Predicated Points Added (PPA/EPA) by game
cfb.MetricsApigetPlayerGamePPAGET /ppa/players/gamesPlayer Predicated Points Added (PPA/EPA) broken down by game
cfb.MetricsApigetPlayerSeasonPPAGET /ppa/players/seasonPlayer Predicated Points Added (PPA/EPA) broken down by season
cfb.MetricsApigetPredictedPointsGET /ppa/predictedPredicted Points (i.e. Expected Points or EP)
cfb.MetricsApigetPregameWinProbabilitiesGET /metrics/wp/pregamePregame win probability data
cfb.MetricsApigetTeamPPAGET /ppa/teamsPredicted Points Added (PPA/EPA) data by team
cfb.MetricsApigetWinProbabilityDataGET /metrics/wpWin probability chart data
cfb.PlayersApigetPlayerSeasonStatsGET /stats/player/seasonPlayer stats by season
cfb.PlayersApigetPlayerUsageGET /player/usagePlayer usage metrics broken down by season
cfb.PlayersApigetReturningProductionGET /player/returningTeam returning production metrics
cfb.PlayersApigetTransferPortalGET /player/portalTransfer portal by season
cfb.PlayersApiplayerSearchGET /player/searchSearch for player information
cfb.PlaysApigetLivePlaysGET /live/playsLive metrics and PBP (Patreon only)
cfb.PlaysApigetPlayStatTypesGET /play/stat/typesTypes of player play stats
cfb.PlaysApigetPlayStatsGET /play/statsPlay stats by play
cfb.PlaysApigetPlayTypesGET /play/typesPlay types
cfb.PlaysApigetPlaysGET /playsPlay by play data
cfb.RankingsApigetRankingsGET /rankingsHistorical polls and rankings
cfb.RatingsApigetConferenceSPRatingsGET /ratings/sp/conferencesHistorical SP+ ratings by conference
cfb.RatingsApigetEloRatingsGET /ratings/eloHistorical Elo ratings
cfb.RatingsApigetFPIRatingsGET /ratings/fpiHistorical FPI ratings
cfb.RatingsApigetSPRatingsGET /ratings/spHistorical SP+ ratings
cfb.RatingsApigetSRSRatingsGET /ratings/srsHistorical SRS ratings
cfb.RecruitingApigetRecruitingGroupsGET /recruiting/groupsRecruit position group ratings
cfb.RecruitingApigetRecruitingPlayersGET /recruiting/playersPlayer recruiting ratings and rankings
cfb.RecruitingApigetRecruitingTeamsGET /recruiting/teamsTeam recruiting rankings and ratings
cfb.StatsApigetAdvancedTeamGameStatsGET /stats/game/advancedAdvanced team metrics by game
cfb.StatsApigetAdvancedTeamSeasonStatsGET /stats/season/advancedAdvanced team metrics by season
cfb.StatsApigetStatCategoriesGET /stats/categoriesTeam stat categories
cfb.StatsApigetTeamSeasonStatsGET /stats/seasonTeam statistics by season
cfb.TeamsApigetFbsTeamsGET /teams/fbsFBS team list
cfb.TeamsApigetRosterGET /rosterTeam rosters
cfb.TeamsApigetTalentGET /talentTeam talent composite rankings
cfb.TeamsApigetTeamMatchupGET /teams/matchupTeam matchup history
cfb.TeamsApigetTeamsGET /teamsTeam information
cfb.VenuesApigetVenuesGET /venuesArena and venue information

Documentation for Models

Documentation for Authorization

ApiKeyAuth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header