Skip to content

Lottery

GET/api/v1/lottery
GET
/api/v1/lottery

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Query Parameters

filter?

Conditions as filter[][]=. Conditions on different fields all apply. in (any of) and all (every one of, on fields holding several values) take a comma-separated list (\, for a literal comma). exists takes true or false. Datetimes are RFC 3339, now, or a time before now such as -30m, -6h or -7d.

q?string

Full-text search over this list's searchable fields.

Length1 <= length <= 200
sort?string

Comma-separated sort keys, - for descending, at most 1. Keys: item_count, total_weight, created_at. Default: -created_at.

limit?integer

Rows per page, 1 to 100 (default 25).

Range1 <= value <= 100
cursor?string

The page.next_cursor of the previous page. Cannot be combined with page.

page?integer

A 1-based page number, for jumping. Cannot be combined with cursor.

Range1 <= value
total?boolean

Set to true to include the number of matching rows in page.total.

Response Body

application/json

curl -X GET "https://example.com/api/v1/lottery"
{  "page": {    "has_more": true,    "next_cursor": "string",    "page": 0,    "total": 0  },  "tables": [    {      "created_at": "2019-08-24T14:15:22Z",      "name": "string",      "size": 0,      "total_weight": 0    }  ]}
GET/api/v1/lottery/{table_name}
GET
/api/v1/lottery/{table_name}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

table_name*string

Name of the lottery table

Response Body

application/json

curl -X GET "https://example.com/api/v1/lottery/string"
{  "created_at": "2019-08-24T14:15:22Z",  "description": "string",  "items": [    {      "item_id": "string",      "percentage": 0.1,      "weight": 0    }  ],  "size": 0,  "table_name": "string",  "total_weight": 0,  "updated_at": "2019-08-24T14:15:22Z"}
POST/api/v1/lottery/{table_name}
POST
/api/v1/lottery/{table_name}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

table_name*string

Name of the lottery table

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/api/v1/lottery/string" \  -H "Content-Type: application/json" \  -d '{    "item_id": "string",    "weight": 0  }'
{  "item_id": "string",  "previous_weight": 0,  "table_size": 0,  "weight": 0}
DELETE/api/v1/lottery/{table_name}
DELETE
/api/v1/lottery/{table_name}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

table_name*string

Name of the lottery table to delete

Response Body

application/json

curl -X DELETE "https://example.com/api/v1/lottery/string"
{  "items_removed": 0,  "table_name": "string"}
POST/api/v1/lottery/{table_name}/adjust-weight
POST
/api/v1/lottery/{table_name}/adjust-weight

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

table_name*string

Name of the lottery table

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/api/v1/lottery/string/adjust-weight" \  -H "Content-Type: application/json" \  -d '{    "increment": 0,    "item_id": "string"  }'
{  "item_id": "string",  "new_weight": 0,  "previous_weight": 0}
POST/api/v1/lottery/{table_name}/batch
POST
/api/v1/lottery/{table_name}/batch

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

table_name*string

Name of the lottery table

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

A batch of weighted items to add to one lottery table. Items are applied independently and fail-fast; the server enforces a per-batch cap.

Response Body

application/json

curl -X POST "https://example.com/api/v1/lottery/string/batch" \  -H "Content-Type: application/json" \  -d '{    "items": [      {        "item_id": "string",        "weight": 0      }    ]  }'
{  "count": 0,  "results": [    {      "item_id": "string",      "previous_weight": 0,      "table_size": 0,      "weight": 0    }  ]}
POST/api/v1/lottery/{table_name}/draw
POST
/api/v1/lottery/{table_name}/draw

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

table_name*string

Name of the lottery table

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/api/v1/lottery/string/draw" \  -H "Content-Type: application/json" \  -d '{}'
{  "items": [    {      "item_id": "string",      "meta": null,      "weight": 0    }  ],  "table_size": 0,  "total_weight": 0}
DELETE/api/v1/lottery/{table_name}/{item_id}
DELETE
/api/v1/lottery/{table_name}/{item_id}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

table_name*string

Name of the lottery table

item_id*string

ID of the item to delete

Response Body

application/json

curl -X DELETE "https://example.com/api/v1/lottery/string/string"
{  "item_id": "string",  "removed": true,  "table_size": 0}