Skip to content

A simple PHP-based API that fetches live cricket scores from Cricbuzz URLs. 🎯

Notifications You must be signed in to change notification settings

akshdeepsingh7/cricket-score-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Cricket Score API 🏏

PHP Version Status

A simple PHP-based API that fetches live cricket scores from Cricbuzz URLs. 🎯

✨ Features

  • 🌐 Web interface for easy score retrieval
  • πŸ”Œ JSON API endpoint
  • βœ… URL validation
  • ⚠️ Error handling
  • πŸ”„ Live score extraction from Cricbuzz pages

πŸ“‹ Requirements

  • πŸ”§ PHP 7.0 or higher
  • πŸ“¦ DOM and libxml PHP extensions

πŸš€ Usage

πŸ’» Web Interface

  1. Access the root URL without parameters to view the web interface
  2. Enter a valid Cricbuzz URL in the input field
  3. Click "Get Score" to fetch the live score

πŸ”— API Endpoint

Make a GET request with the url parameter:

GET /?url=https://www.cricbuzz.com/live-cricket-scores/[match-id]

πŸ“ Response Format

Success Response:

{
    "status": "success",
    "message": "Current Score",
    "data": "Team A 100/2 (15.2 Ov)"
}

Error Response:

{
    "status": "error",
    "message": "Error description"
}

⚠️ Error Messages

  • "Invalid URL format" - The provided URL is not properly formatted
  • "Failed to retrieve data from the source" - Unable to fetch data from Cricbuzz
  • "Score card not found" - Unable to locate score information on the page

πŸ”’ Security Features

  • πŸ›‘οΈ URL validation using filter_var()
  • πŸ“¨ JSON content-type headers
  • 🧹 Input sanitization

⚑ Limitations

  • πŸ”„ Depends on Cricbuzz's HTML structure
  • ⚠️ May break if Cricbuzz changes their page layout
  • πŸ’Ύ No caching mechanism implemented

πŸ“ž Support

Issues

About

A simple PHP-based API that fetches live cricket scores from Cricbuzz URLs. 🎯

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages