@winible/oddsjam-js-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

oddsjam-js-wrapper: A lightweight OddsJam API wrapper for Javascript/Typescript

What is oddsjam-js-wrapper?

oddsjam-js-wrapper is a fast, lightweight wrapper for the OddsJam API. It strives to be as intuitive to use as possible, providing strongly typed requests and responses to ensure predictability and consistency.

How do I use it?

Start by installing the oddsjam-js-wrapper package

    npm -i oddsjam-js-wrapper

Create an instance of the OddsJamClient - depending on your environment (CommonJS example):

    const OddsJamClient = require('oddsjam-js-wrapper');
    const clientInstance = OddsJamClient(YOUR_API_KEY);

Then simply call whichever async function you'd like to, for example:

const futures = async () => {
  try {
    const data = await clientInstance.getFutures();
    console.log(data);
  } catch (e) {
    console.log(e);
  }
};

futures();

This will yield you a strongly typed return value of the "futures" type based on the OddsJam API spec.

NOTE: I am purposely, as least as the package stands now, not handling errors within the package and the capture of these need to be handled by the user of the package. In doing so, we get really nice type hinting on the return values of the API as opposed to returning either the Promise result or the error itself and losing this ability.

Parameters are not required for any function call, but can be provided as desired:

The parameters that can receive multiple instances of themself, i.e. sport in this example, can be passed in as either a singular value or an array of values and they will be parsed into the GET request.

    const data = await oddsJamAPI.getGames({page: 2, sport: ['baseball', 'basketball']});

    OR

    const data = await oddsJamAPI.getGames({page: 2, sport: 'baseball'});

Note: Sport and SportsBook parameters are case insensitive

Readme

Keywords

Package Sidebar

Install

npm i @winible/oddsjam-js-wrapper

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

20.5 kB

Total Files

14

Last publish

Collaborators

  • arcmena-winible
  • rodney.winible
  • brandongarciawinible
  • teddymoney
  • gabriel.winible