Giter Site home page Giter Site logo

himanshuc3 / cricket-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sanwebinfo/cricket-api

0.0 0.0 0.0 275 KB

Free Live Cricket Score JSON API - Cricket API

Home Page: https://sanwebinfo.github.io/cricket-api/

License: MIT License

Python 100.00%

cricket-api's Introduction

Free Cricket API ๐Ÿ”

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

PHP, Node.js and deno Cricket API was not working due to the Cricbuzz Mobile site being Fully Redesigned - The full Site Structure was Changed it's a bit complex to get data - Please Consider using this Python Cricket API Version - Breaking Changes: JSON API Structure was changed update your app or website according to the changes in JSON data

unofficial API Data Fetched from Cricbuzz.com

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

Recently we shutdown our Free API Server due to bulk API Calls Personally we Suggest you to Self Host this API on your server - instant Deploy on Vercel or create Docker Container - https://github.com/sanwebinfo/cricket-api?tab=readme-ov-file#free-deploy-

How it Works? ๐Ÿค”

Scrape the data using BeautifulSoup and export a output via JSON using Flask micro web framework.

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

Example: API URL ๐ŸŒ

# Copy the 5 digit code from cricbuzz Current Live Match URL 
http://127.0.0.1:5000/score?id=<Match ID>

Requirements and Features ๐Ÿ“‘

  • Python 3
  • install Required Modules via requirements.txt
  • Virtual Environment for Running Flask server
  • CORS Header
  • Multiple timezone Support for get the Match Starting time
  • Self-hosting support with gunicorn
  • Nginx, Apache2 or Lightspeed for support Proxy
  • HTTPS (For Secure SSL Connections)

Installation ๐Ÿฏ

  • Download or Clone Repo to your Server/localhost
git clone https://github.com/sanwebinfo/cricket-api
cd cricket-api/api

## install python env
sudo apt install python3-venv

## Create Virtual Env
python3 -m venv venv

## Activate Virtual Env
source venv/bin/activate

## install Modules
python3 -m pip install -r requirements.txt

## verify
python3 -m flask --version

## start the dev server 
flask --app index.py --debug run --host=0.0.0.0 --port=5000

## Exit from Virtual Env
deactivate
  • Test the API
## API Home page
http://127.0.0.1:5000/

## GET Match data
http://127.0.0.1:5000/score?id=<Match ID>

Example Response ๐ŸŒ

Cricket API

{
    "title": "Australia vs Pakistan, 2nd Test - Live Cricket Score",
    "update": "Day 1: 3rd Session",
    "livescore": "AUS 168/3 (60)",
    "runrate": "CRR: 2.8",
    "batterone": "Travis Head",
    "batsmanonerun": "5",
    "batsmanoneball": "(5)",
    "batsmanonesr": "100",
    "battertwo": "Marnus Labuschagne",
    "batsmantworun": "36",
    "batsmantwoball": "(98)",
    "batsmantwosr": "36.73",
    "bowlerone": "Shaheen Afridi",
    "bowleroneover": "19",
    "bowleronerun": "61",
    "bowleronewickers": "0",
    "bowleroneeconomy": "3.21",
    "bowlertwo": "Aamer Jamal",
    "bowlertwoover": "12",
    "bowlertworun": "37",
    "bowlertwowickers": "1",
    "bowlertwoeconomy": "3.08"
}

Code Examples โ˜•

  • WordPress
function display_api_response() {
  $base_url = 'http://127.0.0.1:5000/score?id=';
  $match_id = '123456';
  $url = $base_url.$match_id;
  $response = wp_remote_get($url);
  global $body;
  $body = json_decode( $response['body'], true );
}
add_action( 'init', 'display_api_response' );

Replace http://127.0.0.1:5000 with your API URL

  • Fetch API (Javascript)
var match_id = '123456';

async function fetchscore() {
    try {
        const response = await fetch('http://127.0.0.1:5000/score?id=' + match_id);
        const data = await response.json();
        console.log(data);
    } catch (exception) {
        console.log('Connection issue');
    }
}
fetchscore();

Free Deploy ๐Ÿ˜

  • Deploy on Vercel

Deploy with Vercel

Development

  • Update Submodule
git submodule update --remote --merge

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/

LICENSE ๐Ÿ“•

MIT

cricket-api's People

Contributors

mskian avatar santhoshkumar 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.