/Soccer-Ethiopia-API

Android lib to get the latest Ethiopian premier league data

Primary LanguageJavaApache License 2.0Apache-2.0

This project is no longer maintained! Checkout the node-js implementation.

Soccer Ethiopia

Soccer Ethiopia API

Current Version CircleCI Codacy Badge

This is an Android api that serve the latest Ethiopian premier league standing data

The data is fetched from Soccer Ethiopia. And this is an unoffical api.

follow the following steps to add the dependency to your app:

  • make sure to add jitpack to your repositories
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
  • implement this lib
    dependencies {
        implementation 'com.github.brookmg:Soccer-Ethiopia-API:0.6.0'
    }

Samples

  • Initialising the library With Caching
    SoccerEthiopiaApi apiEntry = new SoccerEthiopiaApi(getApplicationContext()); //recommended to use application context
  • Initialising the library Without Caching
    SoccerEthiopiaApi apiEntry = new SoccerEthiopiaApi(getApplicationContext(), false); //recommended to use application context
  • And simply fetch the latest data from your activity or fragment like:
    apiEntry.getLatestTeamRanking(ranking -> {
            for (RankItem item : ranking) {
                Log.v("data" , item.getTeam().getTeamFullName() + ", " + item.getTeam().getTeamLogo() + ", " + item.getRank()
                        + ", " + item.getPlayedGames() + ", " + item.getWonGames() + ", " + item.getDrawGames() 
                        + ", " + item.getLostGames()
                );
            }
        }, 
        error -> Log.e("Error" , error)
    );
  • Also you can get the league schedule data like:
    apiEntry.getLeagueSchedule(scheduleItems -> {
        for (LeagueScheduleItem item : scheduleItems) {
            Log.v("data_league" , item.getGameWeek() + " | " + item.getGameDetail() + 
            " | " + item.getGameDate() + " | " + item.getGameStatus());
        }
    }, error -> Log.e("Error_League" , error));
  • Or for a specific game week (in this case the 5th game week):
    apiEntry.getLeagueSchedule( 5, scheduleItems -> {
        for (LeagueScheduleItem item : scheduleItems) {
            Log.v("data_league" , item.getGameWeek() + " | " + item.getGameDetail() + 
            " | " + item.getGameDate() + " | " + item.getGameStatus());
        }
    }, error -> Log.e("Error_League" , error));
  • You can fetch last week's, this week's and next week's league schedule too.
    apiEntry.getThisWeekLeagueSchedule(  //THIS WEEK'S
        scheduleItems -> {
            for (LeagueScheduleItem item : scheduleItems) {
                Log.v("data_this_week" , item.getGameWeek() + " | " + item.getGameDetail() + " | " + item.getGameDate() + " | " + item.getGameStatus());
            }
        },
        error -> Log.e("Error_League" , error)
    );

    apiEntry.getLastWeekLeagueSchedule(  //LAST WEEK'S
        scheduleItems -> {
            for (LeagueScheduleItem item : scheduleItems) {
                Log.v("data_last_week" , item.getGameWeek() + " | " + item.getGameDetail() + " | " + item.getGameDate() + " | " + item.getGameStatus());
            }
        },
        error -> Log.e("Error_League" , error)
    );

    apiEntry.getNextWeekLeagueSchedule(  //NEXT WEEK'S
        scheduleItems -> {
            for (LeagueScheduleItem item : scheduleItems) {
                Log.v("data_next_week" , item.getGameWeek() + " | " + item.getGameDetail() + " | " + item.getGameDate() + " | " + item.getGameStatus());
            }
        },
        error -> Log.e("Error_League" , error)
    );
  • You can also get detail about a specific team like the following.
   apiEntry.getTeamDetail(Constants.ADAMA_KETEMA , team -> Log.v("data_team_detail" ,
        team.toString()),
        error -> Log.e("Error_Team" , error)
   );
  • For getting the latest top players in the league
    apiEntry.getTopPlayers(
        players -> Log.v("players" , Arrays.toString(players.toArray())),
        error -> Log.e("players_error", error)
    );
  • To get the top players and then to get player detail
    apiEntry.getTopPlayers(
        players -> {
            if (players.size() > 0) {
                apiEntry.getPlayerDetail(	//This part is used to get the player's detail
                    players.get(0),
                    player -> {
                        if (!player.getCurrentTeam().isComplete()) {
                            apiEntry.getTeamDetail(player.getCurrentTeam(), player::setCurrentTeam, error -> {});
                        }
                        Log.v("player_detailed", player.toString());
                    },
                    error -> Log.e("player_detailed" , error)
                );
            }
        },
        error -> Log.e("players_error", error)
    );
  • To fetch latest sport related news using this api
    apiEntry.getLatestNews(news -> {
        for (NewsItem item : news) Log.v("news_fetch", item.toString());
    }, error -> Log.e("news_fetch", error));
  • To fetch the content of a specific news item
    apiEntry.getLatestNews(news -> 
        apiEntry.getNewsItemContent(
                news.get(0),
                newsWithContent -> Log.v("news_item", newsWithContent.toString()),
                error -> Log.e("news_item", error)
        ),
        error -> Log.e("news_fetch", error)
    );

Features in this lib:

  • Latest teams' standing data
  • League schedule
  • Team details
  • Player details
  • Top players list
  • News with content
  • Do parsing on a different thread
  • Make the api lifecycle aware

make sure you have enabled java8 in your project

    android {
        ...
        
        compileOptions {
            sourceCompatibility = '1.8'
            targetCompatibility = '1.8'
        }
    }

License

Copyright (C) 2019 Brook Mezgebu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.