Git Product home page Git Product logo

the-odds-api-sdk's Introduction

TheOddsApi SDK

TheOddsApi SDK is a Java library that allows developers to interact with The Odds API offered on TheOddsApi. It provides convenient methods to retrieve sports odds data for various events.

Installation

To use TheOddsApi SDK in your Java project, you can add the following dependency to your pom.xml file:

<dependency>
  <groupId>com.albertarie.lib</groupId>
  <artifactId>the-odds-api-sdk</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

Usage

To use TheOddsApi SDK, you need to have an API key from TheOddsApi. You can sign up for a free account to get an API key.

Here's an example of how to use TheOddsApi SDK to retrieve available sports:

package com.example;

import com.albertarie.lib.TheOddsApi;
import com.albertarie.lib.data.Sport;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        TheOddsApi theOddsApi = new TheOddsApi("d00d974e5c129ded425d81328aab35c1");

        List<Sport> sports = new ArrayList<>();

        try {
            sports = theOddsApi.getSports(false);
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (Sport sport : sports) {
            System.out.println(sport.key + " - " + sport.title + " - " + sport.description);
        }
    }
}

Here's an example of how to use TheOddsApi SDK to retrieve available odds for a specific sport:

List<Game> games = new ArrayList<>();

try {
    games = theOddsApi.getOdds(
            SOCCER_EPL,
            List.of(UK),
            List.of(H2H),
            null,
            null,
            null,
            null,
            null,
            null
    );
} catch (Exception e) {
    e.printStackTrace();
}

for (Game game : games) {
    System.out.println(game.id);
    for (Bookmaker bookmaker : game.bookmakers) {
        System.out.println(bookmaker.key);
        for (com.albertarie.lib.data.Market market : bookmaker.markets) {
            System.out.println(market.key);
            for (com.albertarie.lib.data.Outcome outcome : market.outcomes) {
                System.out.println(outcome.name);
                System.out.println(outcome.price);
            }
        }
    }
}

License

The Odds Api SDK © 2024 by Albert Viilik, Arie Arya is licensed under CC BY-NC-SA 4.0

the-odds-api-sdk's People

Contributors

albertviilik avatar

Stargazers

 avatar

Watchers

 avatar  avatar

the-odds-api-sdk's Issues

Logging Improvement

  • Add logging where it's missing and remove redundant logging
  • Set appropriate log levels
  • Review the logging config

Error Handling Improvement

  • Review existing error handling
  • Add custom Exception classes with informative error messages
  • Handle currently unhandled exceptions
  • Log errors/warnings where appropriate

Licensing & Readme

  • Create a license file
  • Add a README.md file with a project overview
  • Add copyright notices above all files in the project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.