All Projects → S1M0N38 → Soccerapi

S1M0N38 / Soccerapi

Licence: mit
soccerapi ⚽️ , an unambitious soccer odds scraper

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Soccerapi

fotmob
⚽ A wrapper around the unofficial FotMob API
Stars: ✭ 22 (-57.69%)
Mutual labels:  soccer, football
Footballdata
A hodgepodge of JSON and CSV Football/Soccer data
Stars: ✭ 526 (+911.54%)
Mutual labels:  football, soccer
angular-footballdata-api-factory
AngularJS Factory for the football-data.org JSON REST API
Stars: ✭ 48 (-7.69%)
Mutual labels:  soccer, football
sports.py
A simple Python package to gather live sports scores
Stars: ✭ 51 (-1.92%)
Mutual labels:  soccer, football
Datofutbol
Dato Fútbol repository
Stars: ✭ 23 (-55.77%)
Mutual labels:  football, soccer
understatr
fetch understat data
Stars: ✭ 72 (+38.46%)
Mutual labels:  soccer, football
regista
An R package for soccer modelling
Stars: ✭ 71 (+36.54%)
Mutual labels:  soccer, football
transfermarkt-datasets
⚽️ Extract, prepare and publish Transfermarkt datasets.
Stars: ✭ 60 (+15.38%)
Mutual labels:  soccer, football
Epl Fantasy Geek
English Premier League 2017-18 Fantasy Stats for Geeks
Stars: ✭ 50 (-3.85%)
Mutual labels:  football, soccer
Open Data
Free football data from StatsBomb
Stars: ✭ 891 (+1613.46%)
Mutual labels:  football, soccer
football-peek
[JavaScript - NodeJS] Application to access football scores
Stars: ✭ 14 (-73.08%)
Mutual labels:  soccer, football
Football Cli
⚽ Command line interface for Hackers who love football
Stars: ✭ 984 (+1792.31%)
Mutual labels:  football, soccer
kickoff
Open Kick-Off is a fun rewriting attempt of the cult football game Kick Off 2 designed by Dino Dini and released in 1990 by Anco for the Atari ST and the Commodore Amiga. It is written in Java with the help of libGDX.
Stars: ✭ 32 (-38.46%)
Mutual labels:  soccer, football
soccer-bookmaker-odds
Historical data of bookmaker odds for some of the major soccer European leagues.
Stars: ✭ 16 (-69.23%)
Mutual labels:  soccer, football
ARGoal
Get more goals. | Virtual Goals & Goal Distance | App Doctor Hu
Stars: ✭ 14 (-73.08%)
Mutual labels:  soccer, football
football analytics
⚽📊 A collection of football analytics projects, data, and analysis by Edd Webster (@eddwebster), including a curated list of publicly available resources published by the football analytics community.
Stars: ✭ 405 (+678.85%)
Mutual labels:  soccer, football
Espn Fantasy Football Api
Connect to ESPN's fantasy football API via this JS API client for web and NodeJS. Available as an npm package.
Stars: ✭ 188 (+261.54%)
Mutual labels:  api, football
Espnff
ESPN Fantasy Football API
Stars: ✭ 210 (+303.85%)
Mutual labels:  api, football
World Cup 2018 Cli Dashboard
⚽🏆A World Cup 2018 CLI dashboard – Watch matches in your terminal
Stars: ✭ 529 (+917.31%)
Mutual labels:  football, soccer
Golazon
Football data mnmlist way. Built with Next.js and Ruby.
Stars: ✭ 28 (-46.15%)
Mutual labels:  football, soccer

soccerapi

PyPI version Code style: black

Soccerapi (Application Programming Interface) is a simple wrapper build on top of some bookmakers (888sport, bet365 and Unibet) in order to get data about soccer (aka football) odds using python commands.

⚽️ The goal

The goal of the project is to provide an enjoyable way to get odds data for different soccer leagues. If you want to get these types of data you usually have to build a program by yourself (and from scratch) being able to scrape the betting site or to use some kind of paid API. Soccer API try to address this problem.

💡 The philosophy

Keep it simple. Simple API, simple http requests, few dependencies. In the past we tried to build some heavy framework, able to scrape dinamic sites (using selenium, handling complex JavaScript): was an unmaintainable nightmare.

📘 The documentation

The following section contain all the useful information to use this API at its best. Read it carefully.

Installation

Use your favorite python package manager (like pip, pipenv, poetry). For example if you use pip type in your terminal:

pip install --upgrade soccerapi

It's important to keep soccerapi updated to the last version because bookmakers sometimes change their website so soccerapi could break. We the last version on the master branch we try to keep up.


Alternatively, if you want a kind of testing/developing setup, you can install soccerapi directly from source code by first cloning the repository from GitHub and then install dev dependencies (poetry is required)

git clone https://github.com/S1M0N38/soccerapi.git
cd soccerapi
poetry install

Finally activate the environment

poetry shell

In order to obtain data from Bet365 you need to run a docker which posts on a local server a needed header to make requests to the Bet365 api. The docker run separeately from the api since it is written in JavaScript and it runs a chromedirver to run JavaScript and acquire the header.

Checkout soccerapi-server to install the docker and run it.

Usage

Import the soccerapi bookmaker, define the api variable and request odds.

from soccerapi.api import Api888Sport
# from soccerapi.api import ApiUnibet
# from soccerapi.api import ApiBet365

api = Api888Sport()
url = 'https://www.888sport.com/#/filter/football/italy/serie_a'
odds = api.odds(url)

print(odds)
[
  {
    'time': '2020-01-12T19:45:00Z'
    'home_team': 'Roma',
    'away_team': 'Juventus',
    'both_teams_to_score': {'no': 2380, 'yes': 1560},
    'double_chance': {'12': 1320, '1X': 1710, '2X': 1360},
    'full_time_resut': {'1': 3200, '2': 2160, 'X': 3450},
  },

  ...

  {
    'time': '2020-01-13T19:45:00Z'
    'home_team': 'Parma',
    'away_team': 'Lecce',
    'both_teams_to_score': {'no': 2280, 'yes': 1600},
    'double_chance': {'12': 1270, '1X': 1270, '2X': 1960},
    'full_time_resut': {'1': 1850, '2': 3850, 'X': 3800},
  }
]

The odds() method return a list of next events of the request competition (in the example: the url points to italy-serie_a)

To get a dict of valid urls that you can pass to odds() use the method competitions().

odds = api.competitions()

print(odds)
{

'Algeria': {
    'Ligue 1': 'https://www.888sport.com/#/filter/football/algeria/ligue_1',
    'Ligue 1 U21': 'https://www.888sport.com/#/filter/football/algeria/ligue_1_u21'
},

'Argentina': {
    'Primera D Metropolitana': 'https://www.888sport.com/#/filter/football/argentina/primera_d_metropolitana'
},

'Australia': {
    'A-League': 'https://www.888sport.com/#/filter/football/australia/a-league',
    'W-League (W)': 'https://www.888sport.com/#/filter/football/australia/w-league__w_'
},

...

}

This python dict is dynamically generated every time the competitions() method is run. This method crawls the bookmaker site looking for the available competitions and extract the url for every competitions offered by the bookmaker.

For some bookmakers (Bet365) many http requests are perform by competitions(), so there is the risk of receiving an IP ban. Use this method wisely (e.g. store the competitions in a json file and update them only when necessary).

The main reasons we introduced the competitions() method is due to the fact that some bookmakers (Bet365) change the url for a competitions over time in order to contrast bot scraping, so do not trust on a static list of urls for every bookmaker.

Country restriction

The regulation of online gambling varies from country to country. There are different versions of the bookmaker site depending on the provenience of your http request. Moreover, most bookmakers implement some kind of VPN detection which block VPN-http requests. Due to this constrains it's difficult to test soccerapi for worldwide usability. In the following are reported some results of the availability of bookmaker in different countries.

bet365 888sport / unibet
accessible 🇮🇹 🇧🇷 🇺🇸 🇨🇦 🇦🇺 🇧🇷 🇨🇭 🇮🇹 🇩🇪 🇩🇰 🇪🇸 🇫🇮 🇯🇵 🇳🇱 🇳🇴 🇸🇪 🇮🇪 🇮🇳 🇸🇬 🇭🇰 🇳🇿 🇲🇽 🇷🇴
inaccessible 🇫🇷 🇬🇧

Contributing

If you like to contribute to the project read CONTRIBUTING.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].