├── assets └── logo-sporte-score.png ├── controllers ├── isJson.controller.js └── request.controller.js ├── package.json ├── LICENSE ├── test.js ├── .gitignore ├── README.md └── index.js /assets/logo-sporte-score.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorratts13/sport-score/HEAD/assets/logo-sporte-score.png -------------------------------------------------------------------------------- /controllers/isJson.controller.js: -------------------------------------------------------------------------------- 1 | function isJson(str) { 2 | try { 3 | JSON.parse(str); 4 | } catch (e) { 5 | return false; 6 | } 7 | 8 | return true; 9 | } 10 | 11 | export default isJson; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sport-score", 3 | "version": "1.0.8", 4 | "description": "score de jogos para bet365", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node test.js" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/victorratts13/sport-score.git" 12 | }, 13 | "keywords": [ 14 | "bet365", 15 | "score", 16 | "sofa-score", 17 | "scorebing", 18 | "betfair", 19 | "1xbet", 20 | "bettando", 21 | "apostas", 22 | "sports", 23 | "e-sports", 24 | "api-sports", 25 | "bet365-api" 26 | ], 27 | "author": "ratts13", 28 | "license": "MIT", 29 | "bugs": { 30 | "url": "https://github.com/victorratts13/sport-score/issues" 31 | }, 32 | "homepage": "https://github.com/victorratts13/sport-score#readme", 33 | "dependencies": { 34 | "axios": "^1.1.3", 35 | "axios-cookiejar-support": "^4.0.3", 36 | "axios-fetch-request": "^1.0.1", 37 | "dateformat": "^5.0.3", 38 | "fetch": "^1.1.0", 39 | "tough-cookie": "^4.1.2" 40 | }, 41 | "type": "module" 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Victor Ratts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | // const score = require('./index'); 2 | import Score from "./index.js"; 3 | const api = new Score({ 4 | version: 'v1', 5 | sport: 'football' 6 | }); 7 | 8 | 9 | // api.statistics(9223864).then(rest => { 10 | // for(var arr of rest.statistics){ 11 | // if(arr.period == 'ALL'){ 12 | // console.log(arr) 13 | // } 14 | // } 15 | // }) 16 | 17 | // api.votes('9223864').then(rest => { 18 | // console.log(rest) 19 | // }) 20 | 21 | // api.getlang(true).then(rest => { 22 | // console.log(rest) 23 | // }) 24 | 25 | // api.eventCount().then(rest => { 26 | // console.log(rest) 27 | // }) 28 | 29 | api.scheduledEvents().then(rest => { 30 | console.log(rest) 31 | }) 32 | 33 | // api.oddsProviders('BR').then(rest => { 34 | // console.log(rest) 35 | // }) 36 | 37 | // api.config.uniqueTournamentsWeb('BR').then(rest => { 38 | // console.log(rest) 39 | // }) 40 | 41 | // api.config.uniqueTournamentsFootball('BR').then(rest => { 42 | // console.log(rest) 43 | // }) 44 | 45 | // api.sport.futebol.trendingTopPlayers().then(rest => { 46 | // console.log(rest) 47 | // }) 48 | 49 | // api.oddsFeaturedEvents().then(rest => { 50 | // console.log(rest) 51 | // }) -------------------------------------------------------------------------------- /controllers/request.controller.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | const fetchData = require('fetch').fetchUrl; 3 | const { isJson } = require('./isJson.controller') 4 | const axiosCookieSuport = require("axios-cookiejar-support").default; 5 | const tough = require("tough-cookie"); 6 | var headers = { 7 | 'accept': '*/*', 8 | 'if-none-match': 'W/"ce9ef8a4f6"', 9 | 'accept-encoding': 'gzip, deflate, br', 10 | 'accept-language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7', 11 | 'cache-control': 'max-age=0', 12 | 'origin': 'https://www.sofascore.com', 13 | 'referer': 'https://www.sofascore.com/', 14 | 'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"', 15 | 'sec-ch-ua-mobile': '?0', 16 | 'sec-fetch-dest': 'empty', 17 | 'sec-fetch-mode': 'cors', 18 | 'sec-fetch-site': 'same-site', 19 | 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36' 20 | }; 21 | axiosCookieSuport(axios); 22 | const cookieJar = new tough.CookieJar(); 23 | let apiCookie = { withCredentials: true, jar: cookieJar }; 24 | const axiosConfig = { 25 | baseURL: 'https://api.sofascore.com/', 26 | proxy: false, 27 | headers: headers, 28 | withCredentials: true, 29 | jar: cookieJar 30 | }; 31 | 32 | var api = axios.create(axiosConfig); 33 | 34 | const fetch = (url, option) => { 35 | return new Promise((resolve, reject) => { 36 | fetchData(url, option, (error, meta, rest) => { 37 | if (error) { 38 | return reject(error) 39 | } else { 40 | if(isJson(rest.toString())){ 41 | return resolve(JSON.parse(rest.toString())) 42 | }else{ 43 | return resolve(rest.toString()) 44 | } 45 | } 46 | }) 47 | }) 48 | } 49 | 50 | module.exports = { 51 | api, apiCookie, axiosConfig, fetch 52 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 | ![version](https://img.shields.io/badge/version-1.0.8-brightgreen) ![env](https://img.shields.io/badge/lang-javascript-yellow) ![version](https://img.shields.io/badge/env-npm-red) 6 |

7 | 8 | 9 | ## introduction 10 | 11 | api for sports statistics and real-time bet365 games. With it you can choose sports data like: 12 | 13 | - Basketball 14 | - Tennis 15 | - Table Tennis 16 | - Hockey 17 | - Esports 18 | - Handball 19 | - Volleyball 20 | - Baseball 21 | - American Football 22 | - Motorsport 23 | - Rugby 24 | - More 25 | - Darts 26 | - Cricket 27 | - Snooker 28 | - Futsal 29 | - Badminton 30 | - Aussie Rules 31 | - Beach Volleyball 32 | - Waterpolo 33 | - Floorball 34 | - Bandy 35 | 36 | Where all live data can be set from your current time in UTC format. 37 | 38 | ## install and implementation 39 | 40 | you can apply this library to your project through the NPM or Yarn repository 41 | 42 | ```bash 43 | npm install sport-score --save 44 | 45 | ``` 46 | and now import the library into your javascript project 47 | 48 | ```js 49 | import Score from "sport-score"; 50 | 51 | const api = new Score({ 52 | version: 'v1',//version from API 53 | sport: 'football'//sport model 54 | }); 55 | ``` 56 | 57 | ## get language 58 | 59 | use this method for get automatic language and region. 60 | >- define true or false for get local language 61 | 62 | ```js 63 | api.getlang(true).then(rest => { 64 | console.log(rest) // callback 65 | }) 66 | ``` 67 | 68 | ## get event number 69 | 70 | use this method for get the number of live events 71 | 72 | ```js 73 | api.eventCount().then(rest => { 74 | console.log(rest) // callback 75 | }) 76 | ``` 77 | 78 | ## get scheduled Events 79 | 80 | to get scheduled Events, you can use this: 81 | 82 | ```js 83 | api.scheduledEvents('2021-05-06').then(rest => { 84 | console.log(rest) 85 | }) 86 | ``` 87 | 88 | ## get event odds 89 | use this method for get the odds information. 90 | 91 | >- you can define language for callback. 92 | 93 | ```js 94 | api.oddsProviders('PT').then(rest => { 95 | console.log(rest) 96 | }) 97 | ``` 98 | 99 | ## get web configurations 100 | use this method for get web configuration. 101 | 102 | >- you can define language for callback. 103 | 104 | ```js 105 | api.config.uniqueTournamentsWeb('BR').then(rest => { 106 | console.log(rest) // callback 107 | }) 108 | ``` 109 | 110 | ## get Football configurations 111 | use this method for get Football configuration. 112 | 113 | >- you can define language for callback. 114 | 115 | ```js 116 | api.config.uniqueTournamentsFootball('BR').then(rest => { 117 | console.log(rest) // callback 118 | }) 119 | ``` 120 | 121 | ## get Football configurations 122 | use this method for get Football configuration. 123 | 124 | >- you can define language for callback. 125 | 126 | ```js 127 | api.config.uniqueTournamentsFootball('BR').then(rest => { 128 | console.log(rest) // callback 129 | }) 130 | ``` 131 | 132 | ## get sport detail 133 | 134 | this method get all sport information with details from games. 135 | 136 | ```js 137 | // for get Top games from today 138 | api.trendingTopPlayers().then(rest => { 139 | console.log(rest) 140 | }) 141 | // get all data from spect day (if null is from today for default). Define number of rows if you like. 142 | api.toDay('2021-05-06', '1000').then(rest => { 143 | console.log(rest) 144 | }) 145 | //get categories from all games. 146 | api.categories().then(rest => { 147 | console.log(rest) 148 | }) 149 | ``` 150 | 151 | ## get in live events 152 | 153 | this method return all live events. 154 | 155 | ```js 156 | api.live().then(rest => { 157 | console.log(rest) 158 | }) 159 | ``` 160 | 161 | ## get Odds Information 162 | 163 | to get odds information, you can use 2 methods: 164 | 165 | ```js 166 | //this method returns all odd informations in live 167 | api.oddsFeaturedEvents('2021-05-06', '1', '-10800').then(rest => { 168 | console.log(rest) 169 | }) 170 | //this method return a spect odds for any event in live 171 | api.fracionalOdds('9223864').then(rest => { 172 | console.log(rest) 173 | }) 174 | ``` 175 | 176 | ## get statistic data 177 | 178 | for get statistics and metrics for a any event, you can use this method: 179 | 180 | ```js 181 | api.statistics('9223864').then(rest => { 182 | console.log(rest) 183 | }) 184 | ``` 185 | 186 | ## probability win based in popular votes 187 | 188 | to get a probability win statistic, you can use this method: 189 | 190 | ```js 191 | api.votes('9223864').then(rest => { 192 | console.log(rest) 193 | }) 194 | 195 | ``` 196 | 197 | >- Note: this method return a popular vote for a event in live. This have a significant error margin. 198 | 199 | ## For more details. 200 | 201 | Contact-me on telegram: ``@vratts`` 202 | email: ``victor@vratts.com`` 203 | 204 | 205 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // index.js 2 | import dateFormat from "dateformat"; 3 | import fetch from "axios-fetch-request"; 4 | const api = new fetch(); 5 | var base = 'https://api.sofascore.com'; 6 | 7 | class Score { 8 | constructor(config = { 9 | version: 'v1', 10 | timerUTC: new Date(), 11 | sport: 'football' 12 | }) { 13 | this.version = config.version; 14 | this.now = config.timeUTC; 15 | this.sport = config.sport; 16 | 17 | } 18 | 19 | getlang(lang = false) { 20 | return new Promise((resolve, reject) => { 21 | //https://api.sofascore.com/api/v1/country/alpha2 22 | api.get(`${base}/api/${this.version || 'v1'}/country/alpha2`).then(rest => { 23 | return resolve(rest) 24 | }).catch(e => { 25 | return reject(e) 26 | }) 27 | }) 28 | } 29 | 30 | eventCount(count = '-10800') { 31 | return new Promise((resolve, reject) => { 32 | //https://api.sofascore.com/api/v1/sport/-10800/event-count 33 | api.get(`${base}/api/${this.version || 'v1'}/sport/${count}/event-count`).then(rest => { 34 | return resolve(rest) 35 | }).catch(e => { 36 | return reject(e) 37 | }) 38 | }) 39 | } 40 | 41 | scheduledEvents(dateEvent = dateFormat(this.now, 'yyyy-mm-dd')) { 42 | return new Promise((resolve, reject) => { 43 | //https://api.sofascore.com/api/v1/sport/${this.sport}/scheduled-events/2021-07-12 44 | api.get(`${base}/api/${this.version || 'v1'}/sport/${this.sport}/scheduled-events/${dateEvent}`).then(rest => { 45 | return resolve(rest) 46 | }).catch(e => { 47 | return reject(e) 48 | }) 49 | }) 50 | } 51 | 52 | oddsProviders(lang = 'PT') { 53 | return new Promise((resolve, reject) => { 54 | //https://api.sofascore.com/api/v1/odds/providers/BR/web 55 | api.get(`${base}/api/${this.version || 'v1'}/odds/providers/${lang}/web`).then(rest => { 56 | return resolve(rest) 57 | }).catch(e => { 58 | return reject(e) 59 | }) 60 | }) 61 | } 62 | 63 | config = { 64 | uniqueTournamentsWeb(lang = 'PT') { 65 | return new Promise((resolve, reject) => { 66 | //https://api.sofascore.com/api/v1/config/unique-tournaments/BR 67 | api.get(`${base}/api/${this.version || 'v1'}/config/unique-tournaments/${lang}`).then(rest => { 68 | return resolve(rest) 69 | }).catch(e => { 70 | return reject(e) 71 | }) 72 | }) 73 | }, 74 | uniqueTournamentsFootball(lang = 'PT') { 75 | return new Promise((resolve, reject) => { 76 | //https://api.sofascore.com/api/v1/config/unique-tournaments/BR/football 77 | api.get(`${base}/api/${this.version || 'v1'}/config/unique-tournaments/${lang}/football`).then(rest => { 78 | return resolve(rest) 79 | }).catch(e => { 80 | return reject(e) 81 | }) 82 | }) 83 | } 84 | } 85 | 86 | 87 | categories() { 88 | return new Promise((resolve, reject) => { 89 | //https://api.sofascore.com/api/v1/sport/${this.sport}/categories 90 | api.get(`${base}/api/${this.version || 'v1'}/sport/${this.sport}/categories`).then(rest => { 91 | return resolve(rest) 92 | }).catch(e => { 93 | return reject(e) 94 | }) 95 | }) 96 | } 97 | 98 | toDay(dateEvent = dateFormat(this.now, 'yyyy-mm-dd'), count = '-10800') { 99 | return new Promise((resolve, reject) => { 100 | //https://api.sofascore.com/api/v1/sport/${this.sport}/2021-07-12/-10800/categories 101 | api.get(`${base}/api/${this.version || 'v1'}/sport/${this.sport}/${dateEvent}/${count}/categories`).then(rest => { 102 | return resolve(rest) 103 | }).catch(e => { 104 | return reject(e) 105 | }) 106 | }) 107 | } 108 | 109 | trendingTopPlayers() { 110 | return new Promise((resolve, reject) => { 111 | //https://api.sofascore.com/api/v1/sport/${this.sport}/trending-top-players 112 | api.get(`${base}/api/${this.version || 'v1'}/sport/${this.sport}/trending-top-players`).then(rest => { 113 | return resolve(rest) 114 | }).catch(e => { 115 | return reject(e) 116 | }) 117 | }) 118 | } 119 | 120 | oddsFeaturedEvents(dateEvent = dateFormat(this.now, 'yyyy-mm-dd'), page = 1, rand = '-10800') { 121 | return new Promise((resolve, reject) => { 122 | //https://api.sofascore.com/api/v1/odds/1/featured-events/${this.sport}/2021-07-12/-10800 123 | api.get(`${base}/api/${this.version || 'v1'}/odds/${page}/featured-events/${this.sport}/${dateEvent}/${rand}`).then(rest => { 124 | return resolve(rest) 125 | }).catch(e => { 126 | return reject(e) 127 | }) 128 | }) 129 | } 130 | 131 | fracionalOdds(event = '', page = 1) { 132 | return new Promise((resolve, reject) => { 133 | //https://api.sofascore.com/api/v1/event/9223865/odds/1/featured 134 | api.get(`${base}/api/${this.version || 'v1'}/event/${event}/odds/${page}/featured`).then(rest => { 135 | return resolve(rest) 136 | }).catch(e => { 137 | return reject(e) 138 | }) 139 | }) 140 | } 141 | 142 | FootballFeaturedEvents(page) { 143 | return new Promise((resolve, reject) => { 144 | //https://api.sofascore.com/api/v1/odds/1/featured-events/football 145 | api.get(`${base}/api/${this.version || 'v1'}/odds/${page}/featured-events/football`).then(rest => { 146 | return resolve(rest) 147 | }).catch(e => { 148 | return reject(e) 149 | }) 150 | }) 151 | } 152 | 153 | heatMap(event = '', player = '') { 154 | return new Promise((resolve, reject) => { 155 | //https://api.sofascore.com/api/v1/event/9506640/player/309464/heatmap 156 | api.get(`${base}/api/${this.version || 'v1'}/event/${event}/player/${player}/heatmap`).then(rest => { 157 | return resolve(rest) 158 | }).catch(e => { 159 | return reject(e) 160 | }) 161 | }) 162 | } 163 | 164 | featuredOdds(event = '', page = 1) { 165 | return new Promise((resolve, reject) => { 166 | //https://api.sofascore.com/api/v1/event/9286604/odds/1/featured 167 | api.get(`${base}/api/${this.version || 'v1'}/event/${event}/odds/${page}/featured`).then(rest => { 168 | return resolve(rest) 169 | }).catch(e => { 170 | return reject(e) 171 | }) 172 | }) 173 | } 174 | 175 | allData(event = '', page = 1) { 176 | return new Promise((resolve, reject) => { 177 | //https://api.sofascore.com/api/v1/event/9476094/odds/1/all 178 | api.get(`${base}/api/${this.version || 'v1'}/event/${event}/odds/${page}/all`).then(rest => { 179 | return resolve(rest) 180 | }).catch(e => { 181 | return reject(e) 182 | }) 183 | }) 184 | } 185 | 186 | votes(event = '') { 187 | return new Promise((resolve, reject) => { 188 | //https://api.sofascore.com/api/v1/event/9223864/votes 189 | api.get(`${base}/api/${this.version || 'v1'}/event/${event}/votes`).then(rest => { 190 | return resolve(rest) 191 | }).catch(e => { 192 | return reject(e) 193 | }) 194 | }) 195 | } 196 | 197 | statistics(event = '') { 198 | return new Promise((resolve, reject) => { 199 | //https://api.sofascore.com/api/v1/event/9223864/statistics 200 | api.get(`${base}/api/${this.version || 'v1'}/event/${event}/statistics`).then(rest => { 201 | return resolve(rest) 202 | }).catch(e => { 203 | return reject(e) 204 | }) 205 | }) 206 | } 207 | 208 | liveEvents() { 209 | return new Promise((resolve, reject) => { 210 | //https://api.sofascore.com/api/v1/sport/football/events/live 211 | api.get(`${base}/api/v1/sport/${this.sport}/events/live`).then(rest => { 212 | return resolve(rest) 213 | }).catch(e => { 214 | return reject(e) 215 | }) 216 | }) 217 | } 218 | 219 | openUrl(url) { 220 | return new Promise((resolve, reject) => { 221 | api.get(url).then(rest => { 222 | return resolve(rest) 223 | }).catch(e => { 224 | return reject(e) 225 | }) 226 | }) 227 | } 228 | } 229 | 230 | export default Score; --------------------------------------------------------------------------------