Endpoint
POST https://quanstyst.com/api/v1/poll-gen
Usage
This endpoint takes game data and outputs an object containing a question and an array of possible answers to be used as a poll.
This endpoint utilizes a model that is trained on sports play by play data, and this allows you to feed it any data, live or static, and expect a poll with relevant, engaging questions.
Headers
Authorization: Requires setting your API Key as the the authorization
header's Bearer.
Content-Type: application/json
Body
The body requires a field content
. This field can be a string or an object.
String Content
Since the model has been trained on sports data, it understands games, players, different actions, etc.
All you need to do is provide it with enough data to give a relevant output. For example:
D. Booker made 16' pullup Jump Shot for 2 PTS. D. Ayton assisted. Score home is 0. Score away is 2. Teams playing are Phoenix Suns and Milwaukee Bucks. Action by Phoenix Suns.
In this string we see:
- The player performing an action
- A secondary player performing a secondary action.
- The current score.
- The teams that are playing.
The model then will return a Poll that looks something like this:
{ "question": "Deandre Ayton with the dish! Did Devin Booker's jumper have you jumping too?", "options": [ { "description": "Splash! 🌊🔥", "image_tag": "joy" }, { "description": "Needs more arc! 🙈", "image_tag": "dislike" } ] }
JSON Content
The model can also extract relevant data from JSON. The "String Content" example above was manually created using this live play data:
{ "actionNumber": 7, "clock": "PT11M44.00S", "timeActual": "2021-07-15T01:11:49.7Z", "period": 1, "periodType": "REGULAR", "teamId": 1610612756, "teamTricode": "PHX", "actionType": "2pt", "subType": "Jump Shot", "descriptor": "pullup", "personId": 1626164, "x": 21.50131406044678, "y": 64.77481617647058, "side": "left", "shotDistance": 16.69, "possession": 1610612756, "scoreHome": "0", "scoreAway": "2", "edited": "2021-07-15T01:12:40Z", "orderNumber": 70000, "isFieldGoal": 1, "shotResult": "Made", "pointsTotal": 2, "description": "D. Booker 16' pullup Jump Shot (2 PTS) (D. Ayton 1 AST)", "playerName": "Booker", "playerNameI": "D. Booker", "assistPlayerNameInitial": "D. Ayton", "assistPersonId": 1629028, "assistTotal": 1 }
The model will understand the context from this data, as long as the keys have logical english names.
For example it will understand "actionType": "2pt"
means the action taken was a 2 point shot. If instead a 2 point shot action was defined as "AT": "<action-type-id-number>"
, some pre-processing will be needed.
Response
The shape of the response is:
{ "question": string "options": [ { "description": string, "image_tag": string } ] }
cURL
curl --request POST \ --url https://quanstyst.com/api/v1/poll-gen \ --header authorization: Bearer <Your API Token> \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "content": "D. Booker made 16' pullup Jump Shot for 2 PTS...", } '
JavaScript
const options = { method: 'POST', headers: { authorization: 'Bearer <Your API Token>, accept: 'application/json', 'content-type': 'application/json' }, body: JSON.stringify({ "content": "D. Booker made 16' pullup Jump Shot for 2 PTS...", }) }; fetch('https://quanstyst.com/api/v1/poll-gen', options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));
Python
import requests url = "https://quanstyst.com/api/v1/poll-gen" payload = { "content": "D. Booker made 16' pullup Jump Shot for 2 PTS...", } headers = { "authorization": "Bearer <Your API Token>" "accept": "application/json", "content-type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response)
Training
Training the model on your own data is coming soon.
Upload your own data to improve responses, get different or better output, and add more context to the model's understanding.
Selected Keys and Custom Keys
Selected Keys and Custom Keys will be used mainly for the upcoming Training feature purposes
Selected Keys
To help improve the response, you can pare down your input to only the necessary keys. For example:
{ "timeActual": "2021-07-15T01:11:49.7Z", "period": 1, "teamId": 1610612756, "teamTricode": "PHX", "actionType": "2pt", "subType": "Jump Shot", "descriptor": "pullup", "scoreHome": "0", "scoreAway": "2", "shotResult": "Made", "pointsTotal": 2, "description": "D. Booker 16' pullup Jump Shot (2 PTS) (D. Ayton 1 AST)", "playerName": "Booker", "playerNameI": "D. Booker", "assistPlayerNameInitial": "D. Ayton", }
Sending only these fields would improve the response.
This can be manually done, but to make it easier, the selectedKeys
field can be sent in the API request.
This is an array of strings that are the keys you want to include
"selectedKeys": ["description", "actionType", "scoreHome", "scoreAway"]
Custom Keys
If there is any data that you believe is important for context, but isn't included in the data you are providing, you can add it to the customKeys
field, which is an object of key value pairs.
{custom_key: 'Custom Value'}