Skip to content

zhoudaqing/pinnacle-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Pinnacle Sports API Java Client

About

This is the Java client library for Pinnacle Sports API. Not only to get a response as XML or JSON, but to map them into an object or list of objects.

Usage

To set parameters

Create a new Parameter instance and set applicable parameters for the operation. You must set all of required parameters while don't have to set optional parameters.

Parameter parameter = Parameter.newInstance();
parameter.sportId(29);
parameter.leagueIds(2157, 2159);
parameter.stake("25.50"); // decimal
parameter.fromDate(LocalDate.of(2015, 6, 30)); // datetime

Pinnacle Sports provides ENUMs for some parameters. Every official ENUMs and three unofficial ENUMs are defined in this package.

parameter.betType(BET_TYPE.MONEYLINE);
parameter.oddsFormat(ODDS_FORMAT.AMERICAN);
parameter.periodNumber(PERIOD.SOCCER_MATCH);

Operations related with Parlay bet require nested parameters for each 'Leg', which represents a single bet in Parlay bet respectively. Create a new Parameter instance for each Leg.

Parameter leg1 = Parameter.newInstance();
leg1.uniqueLegId();
leg1.eventId(475764951);
Parameter leg2 = Parameter.newInstance();
leg2.uniqueLegId();
leg2.eventId(475764951);
parameter.legs(leg1, leg2);

These following operations require no parameter at all and then no need to create a Parameter instance.

  • Get Sports
  • Get Currencies
  • Get Client Balance
  • Get InRunning

To get a response as XML or JSON

Create a PinnacleAPI instance with your username and password.

PinnacleAPI api = new PinnacleAPI("username", "password");

You can also create an instance with encoded credentials.

PinnacleAPI api = new PinnacleAPI("encodedCredentials");

Then get a response as XML or JSON.

String json = api.getLineAsJson(parameter);
String xml = api.getLineAsXml(parameter);

Data format of a response depends on its operation. Some support only XML, some do only JSON. Pinnacle Sports stated that their long term aim is to support just the JSON format as a more compact format than XML.

To map a response to an object or list of objects

All operations except 'Get Feed' have functions to map their responses to an object respectively defined or list of objects.

Get a response as an object.

Odds odds = api.getOdds(parameter);
PlacedBet placedBet= api.placeBet(parameter);

Get a response as a list of objects.

List<League> leagues = api.getLeaguesAsList(parameter);
List<Fixture> fixtures = api.getFixturesAsList(parameter);

'Get Feed' operation

Pinnacle Sports announced 'Get Feed' operation will be obsolete, so this package doesn't implement an object for the operation and deprecates functions and ENUMs related with the operation. You can still get XML response.

Requirements

  • Java 1.8 or later
  • Pinnacle Sports Account

Third Party Libraries and Dependencies

License

Under the MIT license.

About

Java client library for Pinnacle Sports API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages