Comparing version 1.2.0 to 3.0.0-alpha.0
{ | ||
"name": "sportmonks", | ||
"version": "1.2.0", | ||
"description": "Sportmonks Soccer API", | ||
"main": "dist/sportmonks.class.js", | ||
"typings": "dist/sportmonks.class.d.ts", | ||
"directories": { | ||
"test": "dist/test" | ||
}, | ||
"version": "3.0.0-alpha.0", | ||
"description": "Sportmonks Node.js V3 API ", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"clean": "rimraf dist coverage .nyc_output", | ||
"clean:all": "npm run clean && rimraf node_modules", | ||
"prebuild": "rimraf dist", | ||
"build": "tsc", | ||
"precommit": "npm run build && npm run cover && npm run check-coverage", | ||
"commit": "git-cz", | ||
"check-coverage": "nyc check-coverage --statements 70 --branches 60 --functions 30 --lines 70", | ||
"report-coverage": "cat ./coverage/lcov.info | coveralls", | ||
"watch:test": "npm t -- -w", | ||
"test": "mocha test/*.test.js", | ||
"cover": "nyc --reporter=lcov --reporter=text npm t", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
"test": "mocha", | ||
"test:watch": "mocha -w", | ||
"test:coverage": "nyc --reporter=html --reporter=text mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/marchitos/sportmonks.git" | ||
"url": "git+https://github.com/marchitos/sportmonks.git" | ||
}, | ||
@@ -36,26 +24,16 @@ "files": [ | ||
"devDependencies": { | ||
"@types/chai": "^4.0.0", | ||
"@types/chai-as-promised": "0.0.31", | ||
"@types/chai-spies": "0.0.0", | ||
"@types/mocha": "^2.2.41", | ||
"@types/node": "^7.0.18", | ||
"chai": "3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"chai-spies": "^0.7.1", | ||
"commitizen": "^2.9.6", | ||
"coveralls": "^2.13.1", | ||
"cz-conventional-changelog": "^2.0.0", | ||
"husky": "^0.13.3", | ||
"mocha": "^3.4.1", | ||
"nyc": "^11.0.2", | ||
"rimraf": "^2.6.1", | ||
"semantic-release": "^6.3.6", | ||
"typescript": "^2.3.2" | ||
"@types/node": "^18.11.18", | ||
"nock": "^13.3.0", | ||
"nyc": "^15.1.0", | ||
"typescript": "^4.7.2" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "node_modules/cz-conventional-changelog" | ||
} | ||
"types": "./dist/index.d.ts", | ||
"bugs": { | ||
"url": "https://github.com/marchitos/sportmonks/issues" | ||
}, | ||
"dependencies": {} | ||
} | ||
"homepage": "https://github.com/marchitos/sportmonks#readme", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"keywords": [] | ||
} |
106
README.md
@@ -1,4 +0,4 @@ | ||
# SportMonks Soccer API | ||
# SportMonks Node.js V3 API | ||
# installation | ||
## Installation | ||
```js | ||
@@ -8,54 +8,84 @@ npm install sportmonks | ||
# import | ||
## ES6 | ||
## Import | ||
```js | ||
import { SportmonksApi } from 'sportmonks'; | ||
const sportmonks = new SportmonksApi(__YOUR_API_TOKEN__); | ||
import { SportMonks } from 'sportmonks'; | ||
const sportmonks = new SportMonks({ apiKey: "__YOUR_API_TOKEN__"}); | ||
``` | ||
## CommonJS | ||
```js | ||
var SportmonksApi = require('sportmonks').SportmonksApi; | ||
var sportmonks = new SportmonksApi(__YOUR_API_TOKEN__); | ||
``` | ||
# usage | ||
## Usage | ||
You can retrieve SportMonks data of the following type: | ||
- core | ||
- odds | ||
- football | ||
```js | ||
var sportmonks = new SportmonksApi(__YOUR_API_TOKEN__); | ||
const sportmonks = new SportMonks({ apiKey: "__YOUR_API_TOKEN__"}); | ||
sportmonks.get(endpoint,params).then( function(resp){ | ||
//resp.data will contain your data | ||
//resp.meta will contain the meta informations | ||
console.log(resp); | ||
}); | ||
// retrieve all countries in your subscription | ||
await sportmonks.core.getCountries(); | ||
// retrieve all markets in your subscription | ||
await sportmonks.odds.getMarkets(); | ||
// retrieve all the leagues in your subscription | ||
await sportmonks.football.getLeagues(); | ||
``` | ||
## endpoint | ||
you can get the endpoint from the [official sportmonks documentation](https://www.sportmonks.com/sports/soccer#documentation) | ||
omitting the base url and the parameters (that are set with the params field) | ||
The lib comes with types so you will see all the methods available for each type while your are typing. | ||
```js | ||
sportmonks.get('v2.0/countries').then( function(resp){ | ||
console.log(resp) | ||
}); | ||
## Response | ||
All the methods resolve a response width the following type: | ||
```ts | ||
export interface IApiResponse<T> { | ||
ok: boolean; | ||
data?: T; | ||
pagination?: { | ||
count: number; | ||
per_page: number; | ||
current_page: number; | ||
next_page: string | null; | ||
has_more: boolean; | ||
}, | ||
subscription?: { | ||
meta: any[]; | ||
plans: any[]; | ||
add_ons: any[]; | ||
widgets: any[]; | ||
}, | ||
rate_limit?: { | ||
resets_in_seconds: number; | ||
remaining: number; | ||
requested_entity: string; | ||
}, | ||
timezone?: string; | ||
error?: any; | ||
} | ||
``` | ||
## params | ||
if you need to specify parameters you can set the params field as follow | ||
You can check for `ok` param to see if the response is successful. | ||
If the response will fail, you can see the failure data in the `error` property. | ||
The response is also enriched with all the metadata provided by SportMonks API. | ||
```js | ||
sportmonks.get('v2.0/countries/{id}', { id: 13, competitions: true }).then( function(resp){ | ||
//id in the params field will replace {id} in the endpoint | ||
//competitions: true, will add include=competitions in query string | ||
}); | ||
const resp = await sportmonks.football.getLeagues(); | ||
if (resp.ok) console.log(resp.data); | ||
``` | ||
## pagination | ||
page number can be added using the page param | ||
## Select, Include and Filter | ||
All the lib methods allow an options param to provide selecting, including and filtering capabilities. | ||
## Include entities | ||
## Select fields | ||
You can limit the size of the response by selecting only the field you need from the resourse you are requesting. | ||
In the following example we will retrieve only the `name` and `leg` from the fixtures: | ||
```js | ||
sportmonks.get('v2.0/fixtures/between/{from}/{to}', { from: '1998-01-01', to: '2017-12-01', page: 2, lineup: true}).then( function(resp) { | ||
//pagination info can be found in | ||
console.log(resp.meta.pagination) | ||
}); | ||
const resp = await sportmonks.football.fixtures({ select: ['name', 'leg'] }); | ||
``` | ||
You can specify the field you want to retrieve as an array for the select property of the options. | ||
## Filters |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
53901
4
23
801
0
91