Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

statsllc

STATS.com connection

Description

The statsllc function creates a statsllc object. The statsllc object represents a STATS.com connection.

You can retrieve athlete, team, and event data using the statsllc object. You can retrieve data for the sport and time period that you have access to using your credentials. The credentials consist of an API key and secret pass code. To retrieve data for different athletes, teams, events, and time periods, specify query parameters. For credentials, contact STATS.com. For all available query parameters, see STATS Developer Center I/O Docs.

Creation

Syntax

c = statsllc(apikey,secret)
c = statsllc(apikey,secret,QueryName1,QueryValue1,...,QueryNameN,QueryValueN)

Description

example

c = statsllc(apikey,secret) creates an empty STATS.com connection c using the API key and secret pass code. To retrieve data with a custom URL, use this syntax with fetchUrl. Or, to retrieve data without a custom URL, use this syntax, set the object properties, and run fetch.

example

c = statsllc(apikey,secret,QueryName1,QueryValue1,...,QueryNameN,QueryValueN) creates a STATS.com connection c using web service query parameters, as specified by one or more name-value pair arguments. The STATS.com web service defines the query parameters. For query parameters, see STATS Developer Center I/O Docs. To retrieve data, use this syntax with fetch.

Input Arguments

expand all

STATS.com API key, specified as a character vector or string scalar. To request your API key, contact STATS.com.

Data Types: char | string

STATS.com secret pass code, specified as a character vector or string scalar. To request your secret pass code, contact STATS.com.

Data Types: char | string

Web service query parameters, specified as one or more pairs of name-value arguments. A QueryName argument is a character vector or string scalar that specifies the name of a query parameter. A QueryValue argument is a character vector or string scalar that specifies the value of the query parameter.

The web service defines name-value pairs that it accepts as part of a request. For valid name-value pairs, see STATS Developer Center I/O Docs. To understand which name-value pairs you have access to, check your license or contact STATS.com.

Example: statsllc('gkfrq6fabcfehmn2yctrc6j5','aBC5cuBQgc','DataType','stats','LeagueAbbreviation','mlb','Resource','standings','SportName','baseball','VersionNumber','v1') retrieves the standings for the current or most recent baseball season.

Data Types: char | string

Properties

expand all

STATS.com type of data, specified as a character vector or string scalar.

The type 'stats' means statistical data. The type 'optical' means spatial data that is derived from video recordings. For other types of data, contact STATS.com.

Data Types: char | string

Abbreviation for a sports league name, specified as a character vector or string scalar.

Example: 'mlb'

Data Types: char | string

Player or team identifier, specified as a character vector or string scalar.

Example: '548033'

Data Types: char | string

Type of information to request, specified as a character vector or string scalar.

To request data for games, specify 'events'. To request statistical data for a player, specify 'stats/players'. For other resources, contact STATS.com.

Data Types: char | string

Sport name, specified as a character vector or string scalar.

Example: 'baseball'

Data Types: char | string

URL, specified as a character vector or string scalar. STATS.com uses a custom-built URL to make the data request. For details about the URL, contact STATS.com.

The base URL stub for creating the web request is 'http://api.stats.com'.

Data Types: char | string

STATS.com version number, specified as a character vector or string scalar. For details about the STATS.com version number, contact STATS.com.

Example: 'v1'

Data Types: char | string

Object Functions

fetchRetrieve data from STATS.com
fetchUrlRetrieve data from STATS.com with URL

Examples

expand all

Connect to STATS.com using an API key and secret pass code.

apikey = 'gkfrq6fabcfehmn2yctrc6j5';
secret = 'aBC5cuBQgc';

sBasketball = statsllc(apikey,secret)
sBasketball = 

  statsllc with properties:

              DataType: []
    LeagueAbbreviation: []
                Method: []
              Resource: []
             SportName: []
                   URL: 'http://api.stats.com'
         VersionNumber: []

sBasketball is the STATS.com connection object.

Retrieve basketball statistics for individual players in the sport league named 'nba'. To specify the statistics for retrieval, create a URL suffix.

urlsuffix = '/v1/stats/basketball/nba/participants';

d = fetchUrl(sBasketball,urlsuffix);

d contains statistical basketball data for individual players. For details about data retrieval, see fetchUrl.

Retrieving data from STATS.com indicates a successful connection. If there are connection issues, an error displays. For details about errors, see STATS.com Data Retrieval Errors.

Connect to STATS.com using an API key and secret pass code.

apikey = 'gkfrq6fabcfehmn2yctrc6j5';
secret = 'aBC5cuBQgc';

sBasketball = statsllc(apikey,secret)
sBasketball = 

  statsllc with properties:

              DataType: []
    LeagueAbbreviation: []
                Method: []
              Resource: []
             SportName: []
                   URL: 'http://api.stats.com'
         VersionNumber: []

sBasketball is the STATS.com connection object.

Set the object properties in sBasketball to create a specific data request. Specify statistical standings data for basketball teams in the sport league named 'nba'.

sBasketball.DataType = 'stats';
sBasketball.LeagueAbbreviation = 'nba';
sBasketball.Resource = 'standings';
sBasketball.SportName = 'basketball';
sBasketball.VersionNumber = 'v1';

Retrieve basketball team data using the STATS.com connection sBasketball.

d = fetch(sBasketball);

d contains statistical basketball data for individual players. For details about data retrieval, see fetch.

Retrieving data from STATS.com indicates a successful connection. If there are connection issues, an error displays. For details about errors, see STATS.com Data Retrieval Errors.

Connect to STATS.com using an API key and secret pass code. Specify statistical standings data for basketball teams in the sport league named 'nba' using query parameters.

apikey = 'gkfrq6fabcfehmn2yctrc6j5';
secret = 'aBC5cuBQgc';

sBasketball = statsllc(apikey,secret, ...
    'DataType','stats','LeagueAbbreviation','nba', ...
    'Resource','standings','SportName','basketball', ...
    'VersionNumber','v1')
sBasketball = 

  statsllc with properties:

              DataType: []
    LeagueAbbreviation: []
                Method: []
              Resource: []
             SportName: []
                   URL: 'http://api.stats.com'
         VersionNumber: []

sBasketball is the STATS.com connection object.

Retrieve the basketball team data for the 2015 season.

d = fetch(sBasketball,'season','2015');

d contains statistical basketball data for individual players. For details about data retrieval, see fetch.

Retrieving data from STATS.com indicates a successful connection. If there are connection issues, an error displays. For details about errors, see STATS.com Data Retrieval Errors.

Introduced in R2016b

Was this topic helpful?