Game Code / Key Distribution

The Game Code system provides a way to reward viewers with game or DLC codes. This is often used to automatically send digital content to viewers who correctly vote in polls.

Uploading Codes

Before calling the routes in this document read up on how to make calls from an external server Server Communication.

This set is just two dimensional array of codes, with a parallel set of names.

PUT https://api.muxy.io/v1/e/codes

{
  "codes": [
    ["3c21-256d-6c", "306e-223a-25", "445e-7676-75"],
    ["555f-4e21-55", "476e-7e76-31", "2d31-5850-7a"]
  ],
  "names": ["Pistol skin", "Fancy Hat"],
  "indices": [0, 1]
}

You may specify different names in any given PUT request. You may only have 10 active rewards at any given time, with unique names. Each code should be less than 64 characters. Each array must be under 1 million entries.

These codes are extension wide, and expire after 90 days.

The indices parameter is optional, if not set, the assumed indices are set to 0, 1, …. N where N is the number of codes specified in the request. All indices must be in the range [0, 9].

Competing for codes

Using the built in polling system you can automatically reward codes to viewers that guess the correct answer. The other option is to collect and store twitch user IDs for certain actions of viewing time, ex. the Twitch VHS system.

Marking Code Eligibility

This is where the system is told who can redeem what codes

Marking from Poll

This endpoint marks all the users who have voted correctly in the given poll as eligible for a given prize.

POST /v1/e/codes/mark_from_poll

This endpoint accepts a body in the form

{
  "prize_limits" : [1, 1], // max number of prizes the user can have
  "prizes": [3, 4], // prizes to award
  "correct": 3, // the poll index that was correct
  "cutoff_timestamp": 1538621638 // what time the users should have voted by
}
Marking from list

This endpoint marks all the users in a list eligible for a given prize.

POST /v1/e/codes/mark_from_list

This endpoint accepts a body in the form

{
  "prize_limits": [1, 1], // max number of prizes the user can have
  "prizes": [3, 4], // prizes to award
  "users": ["123456", "65432"] // A list of user IDs
}

Redeeming Codes

The flow for users is to:

getEligibleCodes

getRedeemedCodes

Removing Codes

Deleting a set of codes deactivates the code list, and returns the number of codes distributed. All codes are distributed linearly from the submitted list.

DELETE /v1/e/codes

{
  "distributed": [15612, 42]
}

Getting code information

Retrieve information returns the name listing.

GET /v1/e/codes

{
  "names": ["Pistol Skin", "Fancy Hat"]
}