npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sportmonks

v3.0.0-alpha.0

Published

Sportmonks Node.js V3 API

Downloads

35

Readme

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