Skip to contents

Initializing Your Session

Our API uses bearer token authentication. This form of authentication is executed by providing your unique API Integration Key in a token request to your server. Which then the server will provide you with an access token in it’s response.

This process is what is executed within the get_access function of the package. We use this function to initialize our session and use all of the other functions of the hawkinR package. By using get_access and providing the necessary parameters, your access token will be stored in your session and accessible to any subsequent calls.

# use get_access to intialize session
get_access( refreshToken = "your_integration_key", region = "your_region")

"[1] Success! Your access token was recieved and stored for use by other hawkinR functions. Your token will expire at 2023-11-09 09:44:25"

If you need more information how to create an API Integration Key, you can check out our article on How to create an API token. Which has details on how to do this on your cloud site.

some user may feel they are in a situation where you can securely store your integration key on your device locally. You will be interested in our other article How to Store Your API Key.

Please note, only the Org Administrator (the account with the highest level of access) is able to create API tokens.  Please contact techsupport@hawkindynamics.com if you are unsure of your organization’s administrator.

Making Your First Calls

If this is your first time accessing your data through the API, or know you have had changes in your organization since your last session, a good place to start is by calling in your organizational data such as players, teams, and groups. While this information isn’t required to call in your test data, it can allow you to be more specific in your queries and save server processing and loading time when calling in test data.

The package was built to allow you the ability to make requests as specific as you need, and in as few lines of code as possible. To execute this, you will need this organizational information to input the parameters needed for that specificity. Each of these calls can be done in 1 line of code and one function. Each function returns a data frame that can be stored in an R object and used as necessary.

In this example, I will store athlete information in an object called ‘roster’, team information in an object called ‘teams’, and group information in an object named ‘groups’.

Get Athletes:

Returns a data frame with variables of: id, name, active, teams, groups, and external. If an athlete has external fields assigned to them, the string will contain the external name and external ID separated by a colon. And multiple externals will be separated by a comma.

# store player info in object called roster. 'inactive' is default to FALSE. Set to TRUE if you want to include inactive athletes.
roster <- get_athletes(inactive = FALSE)
id name active teams groups external
0kEjAzSLpBwUZc4Yp2Ov Athlete One TRUE 09u20ij0dj0 0j20j09jd9ud0j AMS:dj0203j0dj,GPS:md029j3209j2
1E1zYBv0CKbrKnsKz1vj Player Two TRUE 09u20ij0dj0 0j20j09jd9ud0j,92d2098d02j0 AMS:oin208ju09,GPS:od093j32
1lXEZKkNuNwvMLXiqFRr Person Three TRUE 9308dj209dj AMS:j029j0jd20j,GPS:0d28j098h3

Get Teams:

Returns a data frame with variables: id and name.

# store team info in an object called teams.
teams <- get_teams()
id name
09u20ij0dj0 Team One
9308dj209dj Team Two

Get Groups:

Returns a data frame with variables: id and name.

# store group info in an object called groups.
groups <- get_groups()
id name
0j20j09jd9ud0j Position Group
92d2098d02j0 Grad Year Group

Test Types

Lastly, there are 9 different test collection modes in our software. And thus, we have 9 different test type IDs. These test IDs are what will be used in get_tests_type function, NOT the test name. So it is a good idea to store the test types as an object as well. This also has a single function to execute, which returns a data frame with the test type name and ID.

# store test type IDs in an object called testIds
testIds <- get_testTypes()
name id
Countermovement Jump 7nNduHeM5zETPjHxvm7s
Squat Jump QEG7m7DhYsD6BrcQ8pic
Isometric Test 2uS5XD5kXmWgIZ5HhQ3A
Drop Jump gyBETpRXpdr63Ab2E0V8
Free Run 5pRSUQVSJVnxijpPMck3
CMJ Rebound pqgf2TPUOQOQs6r0HQWb
Multi Rebound r4fhrkPdYlLxYQxEeM78
Weigh In ubeWMPN1lJFbuQbAM97s
Drop Landing rKgI4y3ItTAzUekTUpvR

With these objects, you can access any of the IDs and information you would need for your test queries. See the other vignettes How to Get Tests and Accessing Force-Time Data of A Test for specific details on ways to execute those queries.