Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
An API key and relevant Account ID - to authorise the request
Requesting an API key
Contact your Genius CSM to obtain an API key from the Genius IT team.
Uploading data
Method: POST
Queues a valid set of data for upload in the RevShare database. Once the upload is accepted and response 200 is received, the upload will be queued for full validation by the solution. Final validation information can be received by submitting the GET request shown below.
You should preferably submit the JSON body with 1000 fixtures per request. A bigger amount of fixtures may cause the API to respond slower than expected. Calls with more than 5000 fixtures may not succeed.
Each fixture must be placed in a separate JSON object. You can expand the fields below to see a full list of properties that must be submitted per fixture.
Please note that the JSON object keys must be lowercase!
The API returns a 200 response when the upload passes first-level validation (full validation is done later by the solution). In case the upload is successful, a JSON body is also returned in the request that also specifies the Upload ID. The Upload ID can later on be used to validate if the upload has any errors.
The API does not send notifications to the RevShare InPlay or NFL contact in case the data uploaded has no errors. In case of errors, the API will notify the RevShare contact that there was an error. The errors will be sent via email for each chunk of data that is loaded. Genius is looking to change this behaviour to one email per upload.
Example Python Function to upload data
The example below uses Python to upload API data. What it does in short:
Ingests a CSV, lowercases all keys and converts it to JSON objects
Submits the data to the API via the upload_revshare_data function which users the requests module. The function takes care of splitting the list of JSON objects to chunks of 1000 (if more than 1000).
The function returns, via print statements, the response of the API
import requests
import csv
import os
#The actual function that uploads RevShare data.
def upload_revshare_data (
endpoint,
uploaded_by,
account_id,
start_date,
end_date,
provided_for,
template,
reference,
token,
records):
# Set up Params for the Rquests module
params = {
'uploaded_by' : uploaded_by,
'account_id' : account_id,
'start_date' : start_date,
'end_date' : end_date,
'provided_for': provided_for,
'template' : template,
'reference' : reference,
'token' : token
}
#Break down the JSON data in chunks of 1000 items as this is the recommended maximum upload.
chunks = [records[x:x+1000] for x in range(0, len(records), 1000)]
for id, chunk in enumerate(chunks):
#Actual upload via the requests module
upload = requests.post(
url = endpoint,
params = params,
json = chunk
)
if upload.status_code == 200:
print("Succesfully uploaded chunk {0}!".format(id))
print("Response received \n {0}".format(upload._content))
else:
print("An error appeared, error code {0}".format(upload.status_code))
print("Response received \n {0}".format(upload._content))
###Program starts here:
if __name__ == '__main__':
api_key = os.getenv('REVSHARE_API_KEY')
## Load a CSV to upload as JSON
csv_data = []
with open('Entain Account Level NFL 2022 Game week 16 - API.csv', 'r', encoding='utf-8-sig') as file:
csv_reader = csv.DictReader(file)
for row in csv_reader:
csv_data.append(row)
## Lowecase the keys in the JSON records and add them to a new list:
json_data = []
for row in csv_data:
json_data.append({k.lower(): v for k, v in row.items()})
###Some preliminary knowns:
endpoint = 'https://uat.revshare.api.geniussports.com/api/uploads/json'
uploaded_by = 'xxxxx.xxxxx@geniussports.com'
## Template: nfl_account, nfl_brand, inplay_account, inplay_brand
template = 'nfl_account'
start_date = '2022-11-01'
end_date = '2022-11-30'
provided_for = 'nfl'
account_id = '0000000'
#Run the function with the required parameters:
upload = upload_revshare_data(
endpoint=endpoint,
uploaded_by=uploaded_by,
account_id=account_id,
start_date=start_date,
end_date=end_date,
provided_for=provided_for,
template=template,
reference='API upload NFL 2022 Game Week 16',
token=api_key,
records=json_data
)
Getting the status of an upload
Method: GET
Returns the status of an upload that was done via the request above. Returns rich error information for smaller numbers of errors.
The response will return the upload_uuid, upload_ref and status of the upload. Errors will be summarised per error type in the response.
{
"result":"success",
"data":{
"upload_id":"5xxxxxx3-8xx9-4xx6-8xx4-exxxxxxxxx17",
"upload_ref":"API upload NFL Account '22 Game Week 16 test 6 April",
"upload_valid":true,
"import_status":"partially_validated",
"imported_records":15,
"results":{
"valid_records":14,
"failed_records":1,
"ignored_records":0,
"number_of_errors":2,
"errors":[
{
"code":"BAD_LB_PCT_OF_TS",
"name":"Land-based % of Total Stake is out of range.",
"count":1
},
{
"code":"BAD_OL_PCT_OF_TS",
"name":"Online % of Total Stake is out of range.",
"count":1
}
]
}
}
}
Downloading Usage
Method: GET
Returns a full set of usage data from the Genius Sports systems for the specific customer account. All data is returned in B2B upload format (Brands included).
The API returns a 200 response when the usage data was successfully generated. The usage data is passed as a JSON in the body of the response. A “next” link is returned as part of the response that can be followed for the next page of results if multiple pages or results need to be served.
NB: usage_gameweek is only returned for NFL fixtures.
Malformed data errors are usually generated when the RevShare template is not fully filled out or there’s another issue with the source CSV file that was uploaded.
StringDataRightTruncation
This error occurs in the following scenarios:
The SPORT column has more than 50 symbols as a Sport name. Please reduce the string length.
The filter cell at the bottom of the file that gets generated when downloading the file from our BI portal was not removed. Please select the last two rows (blank row + row containing the filter) and delete rows.
UndefinedColumn
This error occurs in the following scenarios:
The FIXTURE_ID column in your file contains letters. Please do not edit Fixture ID’s after downloading from the BI portal. If you are using your own self-generated file, please make sure all fixture ID’s are only constructed of numbers and match the Genius Sports ID’s.
You have a blank line or multiple blank lines at the bottom of the file. Please select the first blank row after your data, highlight all cells till the bottom of the CSV file and then right click and delete rows. This will remove any blanks from the CSV file
SyntaxError
This error occurs in the following scenarios:
The FIXTURE_ID ends with a letter (ex: 123123123A). Please do not edit Fixture ID’s after downloading from the BI portal. If you are using your own self-generated file, please make sure all fixture ID’s are only constructed of numbers and match the Genius Sports ID’s.
The COMPETITION_ID contains letters. Please do not edit Competition ID’s after downloading from the BI portal. If you are using your own self-generated file, please make sure all Competition ID’s are only constructed of numbers and match the Genius Sports ID’s.