1.0.7 • Published 10 months ago

api-sports v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

api-sports

An easy-to-use Node.js wrapper for the API Sports service.

Installation

You can install api-sports using npm:

npm install api-sports

Usage

First, import the Sports class from the api-sports package:

const Sports = require('api-sports');

If you're using ES6 imports:

import Sports from 'api-sports';

Then, create a new Sports instance with your API key:

const sports = new Sports('your-api-key');

You can then use any of the available methods to make requests to the API. For example, if we to make a request to the football endpoint, the football method takes two parameters: the endpoint URL (as a string), and an object of query parameters:

sports.football('leagues', { id: 39 }) // can also be /leagues
  .then(data => console.log(data))
  .catch(error => console.error(error));

// should return
{
  // ...
  response: [
    {
      league: {
        id: 39,
        // ...
      }
    }
  ]
}

Methods

americanFootball(url, params)

Makes a GET request to the american football API endpoints. API Docs

  • url: The endpoint URL (as a string).
  • params: An object of query parameters.

Returns a Promise that resolves with the response data.

basketball(url, params)

Makes a GET request to the basketball API endpoints. API Docs

baseball(url, params)

Makes a GET request to the baseball API endpoints. API Docs

football(url, params)

Makes a GET request to the football API endpoints. API Docs

formula1(url, params)

Makes a GET request to the formula 1 API endpoints. API Docs

handball(url, params)

Makes a GET request to the handball API endpoints. API Docs

hockey(url, params)

Makes a GET request to the hockey API endpoints. API Docs

nba(url, params)

Makes a GET request to the nba API endpoints. API Docs

rugby(url, params)

Makes a GET request to the rugby API endpoints. API Docs

volleyball(url, params)

Makes a GET request to the volleyball API endpoints. API Docs

Contributing

Contributions are welcome! Please submit a pull request or create an issue to get started.

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago