Java client for requesting data from sportdataapi.com.
This Java client provides access to sportdataapi.com's REST API (soccer only). It returns data as respective Java objects and encapsulates the REST API boilerplate of handling encoding/decoding JSON or correct URL, HTTP headers and query parameter syntax.
Attention! A valid subscription is required to use this client. Anonymous clients will not work.
The project is stuck in Beta phase and was aborted (due to missing production usage). Interested parties may takeover this project. Please contact me
- Implementation of all soccer REST endpoints
- Handling of HTTP 404 return codes and returning empty lists or
null
values. - Automatic decoding of values into corresponding Java objects wherever possible
- Not thread-safe. You will need a
SdaClient
per thread in case this is your requirement.
<dependency>
<groupId>eu.ralph-schuster</groupId>
<artifactId>sportdata-api-client</artifactId>
<version>0.9.6</version>
</dependency>
API Javadoc for all versions is available via javadoc.io.
sportdata-api-client is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation.
sportdata-api-client is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with sportdata-api-client. If not, see https://www.gnu.org/licenses/lgpl-3.0.html.
Summary:
- You are free to use all this code in any private or commercial project.
- You must distribute license and author information along with your project.
- You are not required to publish your own source code.
First, create your client instance via the SdaClientFactory
using your API key:
String myApiKey = '00000000-0000-0000-0000-000000000000';
SdaClient client = SdaClientFactory.newClient(myApiKey);
Next is to retrieve the subclient for the API you wish to use and make your request, e.g.:
LeaguesClient leaguesClient = client.soccer().leagues();
List<League> germanLeagues = leaguesClient.list(48);
Now, you could try to find the current season of each league:
SeasonsClient seasonsClient = client.soccer.seasons();
for (League league : germanLeagues) {
List<Season> seasons = seasonsClient.list(league.getId());
for (Season season : seasons) {
if (season.isCurrent()) {
...
}
}
}
Once you are finished, you will need to close the client accordingly:
client.close();
PS: It is a good pattern to always wrap the get()
and list()
calls in try {} catch () {}
blocks
as the methods can still throw ForbiddenException
or other exceptions that result from errors returned by the server.
Please be aware that JUnit tests require a valid API key from sportdataapi.com with the correct leagues subscribed to. Provide
the key either by setting environment variable SDA_API_TOKEN
or creating a file my-apikey.txt
that is available
in any of the classpath's folders, e.g. in src/test/resources
. Be careful not to submit this file in any of your
code repositories.
Report a bug, request an enhancement or pull request at the GitHub Issue Tracker. Make sure you have checked out the Contribution Guideline