GithubHelp home page GithubHelp logo

amitbkumar14 / cricket-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mskian/cricket-api

0.0 0.0 0.0 172 KB

Free Cricket API - Live Cricket Score JSON API ๐Ÿ

License: MIT License

PHP 100.00%

cricket-api's Introduction

Free Cricket API ๐Ÿ”

Live Cricket Score API ๐Ÿ

unofficial API Data Fetched from Cricbuzz.com

This is an unofficial API and not Linked or Partnered with Any Brands/Company.

How it Works? ๐Ÿค”

We are just fetching the data from Cricbuzz using PHP cURL preg_match and preg_math_all. It's kind of scraping but we are not storing any data or link in our end.

Everything is scraped live and shown to end users in realtime.

API URL ๐ŸŒ

https://cricket-api.vercel.app/cri.php?url=<Live Match URL>

Requirements ๐Ÿ“‘

  • Server with PHP Support
  • PHP 7.2 or 7.3 or 7.4
  • PHP cURL
  • Nginx, Apache2 or Lightspeed
  • HTTPS (For Secure SSL Connections)

Installation ๐Ÿฏ

  • Download or Clone Repo to your Server
git clone https://github.com/mskian/cricket-api.git
cd cricket-api
cd cri
  • Test the API
php -S localhost:6001

Usage ๐ŸŸ

  • Get the Live Match Score URL from - https://www.cricbuzz.com/cricket-match/live-scores
  • Enter them Directly or replace www with m

Example ๐Ÿ“‹

http://localhost:6001/cri.php?url=https://www.cricbuzz.com/live-cricket-scores/30524/53rd-match-indian-premier-league-2020

(OR)

http://localhost:6001/cri.php?url=https://m.cricbuzz.com/live-cricket-scores/30524/53rd-match-indian-premier-league-2020

Example Response ๐ŸŒ

Cricket API

{
    "success": true,
    "livescore": {
        "title": "Sunrisers Hyderabad vs Mumbai Indians, 56th Match",
        "current": "SRH - 145\/0 (16.2)",
        "batsman": "Wriddhiman Saha*",
        "batsmanrun": "57",
        "ballsfaced": "(43)",
        "fours": "7",
        "sixes": "1",
        "bowler": "Nathan Coulter-Nile*",
        "bowlerover": "3.2",
        "bowlerruns": "25",
        "bowlerwickets": "0",
        "partnership": "145(98)",
        "recentballs": "Data Not Found",
        "lastwicket": "... 0 0 4 1 | 0 4 1 1 0 1 | 1 0",
        "runrate": "CRR: 8.88",
        "commentary": [
            "16.2 Coulter-Nile to W Saha, no run, 139.1kph, ",
            "16.1 Coulter-Nile to Warner, 1 run, 124.4kph, length, nipping in off the pitch onto middle. Warner makes room and slaps it to deep point ",
            "15.5 Pattinson to Warner, no run, 139.7kph, backs away, cuts, but ends up miscuing it back down the pitch ",
            "15.4 Pattinson to W Saha, 1 run, swivels, one-legged, pulling it to the man in the deep behind square ",
            "15.3 Pattinson to Warner, 1 run, 118.2kph, back of a length, taking pace off, keeping it outside off for Warner to have to reach out. And he does connect this time, to guide it to third man ",
            "15.1 Pattinson to Warner, no run, 134.5kph, full, outside off, quick, just inside the tramline. Warner stretches, but can't quite connect ",
            "14.6 Coulter-Nile to Warner, 1 run, 130.6kph, length, nips back in, and Warner jumps away at the last moment with an opened bat face to steer it through point ",
            "14.4 Coulter-Nile to Warner, no run, skids through as it seams back in sharply to go under Warner's crouched swat, thudding off his thighs towards backward point ",
            "14.3 Coulter-Nile to Warner, no run, 136.4kph, serious bouncer, climbing back in. Nope, it's the circumstances that determines its ferocity, and with an 18 runs | 33 balls equation, this is gently left alone ",
            "14.2 Coulter-Nile to W Saha, 1 run, 136.9kph, full, on middle with the angle-in. Saha goes wristy, through mid-wicket ",
            "14.1 Coulter-Nile to W Saha, no run, 117kph, in-cutter into the tummy. Saha gets cramped in what looked like an initial attempt to cut, and so drops his wrists, opens his bat face and runs out to short third man ",
            "13.6 D Kulkarni to Warner, 2 runs, 105.4kph, and very comfortable. Around the fourth-stump, which Warner lines up to and punches through point ",
            "13.5 D Kulkarni to W Saha, 1 run, 127.6kph, full, on off, quiet flick, long-on "
        ],
        "teamone": "Data Not Found",
        "teamtwo": "Data Not Found",
        "update": "Sunrisers Hyderabad need 5 runs in 22 balls"
    }
}

Code Examples โ˜•

  • WordPress
## API Auth and Get data
function display_api_response() {
  $base_url = 'https://YOUR-API-Domain.com/cri.php?url=';
  $score_path = 'https://www.cricbuzz.com/live-cricket-scores/30524/53rd-match-indian-premier-league-2020';
  $url = $base_url.$score_path;
  $response = wp_remote_get($url);
  global $body;
  $body = json_decode( $response['body'], true );
}
add_action( 'init', 'display_api_response' );

Replace YOUR-API-Domain with your actual API Domain

  • Fetch API (Javascript)
var url = 'https://www.cricbuzz.com/live-cricket-scores/30524/53rd-match-indian-premier-league-2020';

async function fetchscore() {
    try {
        const response = await fetch('https://api.example.com/cri.php?url=' + url);
        const data = await response.json();
        console.log(data);
    } catch (exception) {
        console.log('Connection issue');
    }
}
fetchscore();

Free Deploy ๐Ÿ˜

  • Deploy on Heroku

Deploy

  • Deploy on Vercel

Deploy with Vercel

How Deploy Works? - https://github.com/mskian/cri-deploy

Development ๐Ÿฉ

git clone https://github.com/mskian/cricket-api.git
cd cricket-api
cd cri
php -S localhost:3001

Contributing ๐Ÿ™Œ

Your PR's are Welcome

Disclaimer ๐Ÿ—ƒ

  • This is not an Offical API from Cricbuzz - it's an Unofficial API
  • This is for Education Purpose only - use at your own risk on Production Site

All Credits Goes to https://www.cricbuzz.com/

My other Projects ๐Ÿค“

# Project Name Description
01 Live Cricket Score Static Site A Simple Scrape Method - Fetch the Live Cricket Score from espncricinfo.com using Nodejs and Cheerio.js
02 IPL Special Cricket API for Get the Live IPL Cricket Score
03 Live IPL Score Update on Telegram Get Live IPL cricket Score on Telegram
04 Live Cricket Score Wordpress Plugin (JS Version) Get Live Cricket Score on Wordpress site call API using Javascript Fetch API
05 Live Cricket Score Wordpress Plugin (Wp Remote URL) Get Live Cricket Score on Wordpress site call API using Wordpress HTTP Remote URL
06 PWA Web App Real-time Live Cricket Score Web app + PWA Built using Nuxt.js

LICENSE ๐Ÿ“•

MIT

cricket-api's People

Contributors

mcnaveen avatar mskian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.