Skip to main content

Guides — Roanuz Cricket API

Source: https://www.cricketapi.com/v5/docs/guides/

Resource Keys

Source: https://www.cricketapi.com/v5/docs/guides/resource-keys

A resource key is an identification string that uniquely identifies a resource within its kind.

Key Types

TypeFormatExampleDescription
Country CodeISO-likein, au, engCountry identifier
Association Keystringicc, bcci, ecbCricket board/association
Tournament Keystringipl_2026, wc_2026_odiSpecific tournament edition
Match Keystringipl_2026_t20_01Individual match
Team Keystringcsk, mi, indTeam identifier
Player Keystringc__player__virat_kohli__abc12Individual player (long format)

Player Key Formats

Long: c__player__{first}_{last}__{hash} — e.g., c__player__rahul_yadav__fc84b Short: {initial}_{surname} — e.g., p_salt, s_samson

Data Structure

Source: https://www.cricketapi.com/v5/docs/guides/data-structure

Hierarchy

Country
└── Association (governing body, e.g., ICC, BCCI)
└── Competition (recurring series, e.g., "ICC Cricket World Cup")
└── Tournament (specific edition, e.g., "ICC CWC 2019")
└── Match (individual game, e.g., "IND vs AUS, Match 14")
└── Teams → Players

Key Relationships

  • Country → Associations (one country can have multiple: BCCI under ICC)
  • Association → Competitions → Tournaments → Matches
  • Team → belongs to Association, has squad of Players
  • Player → independent resource, accessible without hierarchy traversal
  • Match → belongs to Tournament, has Teams, Venue, Score, Innings

Forward: Country → Association → Competition → Tournament → Match Backward: Match → Tournament → Competition → Association → Country Cross: Player can be accessed independently of tournament hierarchy

Caching

Source: https://www.cricketapi.com/v5/docs/guides/caching

Recommendations

  • Cache fixture/match lists for 5-10 minutes
  • Cache live match data for 30-60 seconds
  • Cache completed match data for hours/days (it won't change)
  • Cache player/team metadata for 24+ hours
  • Use ETag/Last-Modified headers when available

Hannibal Implementation

See RoanuzDataAdapter.ts CACHE_TTL constants:

  • Fixtures: 300s (5min)
  • Match state (live): 60s
  • Match state (completed): 3600s (1hr)
  • Scorecard (live): 30s
  • Scorecard (completed): 3600s (1hr)
  • Ball-by-ball: 10s
  • Commentary: 30s
  • Venue stats: 86400s (24hr)

Error Handling

Source: https://www.cricketapi.com/v5/docs/guides/error-handling

Error Response Format

{
"status_code": 4xx/5xx,
"error": {
"msg": "Human-readable error message",
"code": "ERROR_CODE"
}
}

Error Codes

CodeHTTPMessageAction
A-400-0400Invalid input to processVerify inputs (match keys, etc.)
A-400-2400Invalid Project Key providedCheck project key in console
A-400-3400Invalid Page Key providedUse page_key from current response
A-400-4400Invalid API Key providedCheck API key in request body
A-401-0401Invalid access token to processToken expired — refresh and retry
A-402-0402Project is inactiveRenew Roanuz subscription
A-403-0403Access limited to specific user groupsUpgrade plan or check permissions
A-404-0404Resource not foundResource doesn't exist or was deleted
C-400-1400Invalid country code providedCheck country code format
P-400-1400Subscription not configuredConfigure delivery method
P-400-2400Invalid push delivery methodUse valid delivery method
P-400-3400Delivery method unsupportedMethod not available for this resource
P-400-4400Resource already subscribedAlready subscribed to this delivery method
P-403-1403Subscription disabled on projectEnable push services on account
P-403-2403Subscription not authorizedPush unavailable for this resource
UN-500-0500Unknown errorRetry after a few seconds

Hannibal Handling

In RoanuzDataAdapter.makeRequest():

if (response.data.error) {
throw new Error(response.data.error.msg || 'Roanuz API error');
}