SportMonks Soccer API
installation
npm install sportmonks
import
ES6
import { SportmonksApi } from 'sportmonks';
const sportmonks = new SportmonksApi(__YOUR_API_TOKEN__);
CommonJS
var SportmonksApi = require('sportmonks').SportmonksApi;
var sportmonks = new SportmonksApi(__YOUR_API_TOKEN__);
usage
var sportmonks = new SportmonksApi(__YOUR_API_TOKEN__);
sportmonks.get(endpoint,params).then( function(resp){
console.log(resp);
});
endpoint
you can get the endpoint from the official sportmonks documentation
omitting the base url and the parameters (that are set with the params field)
sportmonks.get('v2.0/countries').then( function(resp){
console.log(resp)
});
params
if you need to specify parameters you can set the params field as follow
sportmonks.get('v2.0/countries/{id}', { id: 13, competitions: true }).then( function(resp){
});
page number can be added using the page param
sportmonks.get('v2.0/fixtures/between/{from}/{to}', { from: '1998-01-01', to: '2017-12-01', page: 2, lineup: true}).then( function(resp) {
console.log(resp.meta.pagination)
});