Пример #1
0
#!/usr/bin/env python
#
# Retrieve match dates, kickoff times, and kickoff temps of all
# of USA's matches.
#

from soccermetrics.rest import SoccermetricsRestClient

if __name__ == "__main__":

    # Create a SoccermetricsRestClient object.  This call assumes that
    # SOCCERMETRICS_APP_ID and SOCCERMETRICS_APP_KEY are in your environment
    # variables, which we recommend.
    client = SoccermetricsRestClient()

    # Set national team variable to USA.  Enables reuse if we want to
    # repeat this analysis with other national teams.
    selection_name = "USA"

    # Get match info data from all matches.  We do this by first querying
    # for all of USA's home matches, then by querying their away matches.
    #
    # The result is a list, so we can join them together by concatenation.
    # (Order doesn't matter, we're going to sort the result in a sec.)
    matches = []
    for key in ['home_team_name', 'away_team_name']:
        param = {key: selection_name}
        matches.extend(client.natl.information.get(**param).all())

    # Results from the API are unsorted, so sort the results by match date.
    # You can also sort by matchday but not all matches are played in order.
 def setUp(self):
     self.client = SoccermetricsRestClient(account="APP_ID",
                                           api_key="APP_KEY")
Пример #3
0
 def setUp(self):
     self.client = SoccermetricsRestClient(base_uri="https://foo.uri",
                                           account="ID",
                                           api_key="KEY")
 def test_connect(self):
     self.client = SoccermetricsRestClient(account="APP_ID",
                                           api_key="APP_KEY")
     self.assertIsInstance(self.client, SoccermetricsRestClient)
Пример #5
0
 def test_connect(self):
     """Verify client object created upon full credentials sent."""
     self.client = SoccermetricsRestClient(account="APP_ID",
                                           api_key="APP_KEY")
     self.assertIsInstance(self.client, SoccermetricsRestClient)