Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sportmonks

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sportmonks

Sportmonks Node.js V3 API

  • 3.0.0-alpha.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by850%
Maintainers
1
Weekly downloads
 
Created
Source

SportMonks Node.js V3 API

Installation

npm install sportmonks

Import

import { SportMonks } from 'sportmonks';
const sportmonks = new SportMonks({ apiKey: "__YOUR_API_TOKEN__"});

Usage

You can retrieve SportMonks data of the following type:

  • core
  • odds
  • football
const sportmonks = new SportMonks({ apiKey: "__YOUR_API_TOKEN__"});

// 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();

The lib comes with types so you will see all the methods available for each type while your are typing.

Response

All the methods resolve a response width the following type:

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;
}

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.

const resp = await sportmonks.football.getLeagues();
if (resp.ok) console.log(resp.data);

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:

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

FAQs

Package last updated on 20 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc