Skip to content

seunafara/api-sports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published