HTTP API

Lottery

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

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Query Parameters

q?string

Full-text search query applied to table name and description

page?integer

1-indexed page number

Formatint64
Range0 <= value
page_size?integer

Page size

Formatint64
Range0 <= value
sort_by?string

Sort field (created_at, item_count, total_weight)

sort_order?string

Sort order (asc or desc)

Value in

  • "asc"
  • "desc"
filter?array<string>

Additional filter expressions in the form field:operator:value

Response Body

application/json

curl -X GET "https://example.com/api/v1/lottery"
{  "pagination": {    "has_more": true,    "page": 0,    "page_size": 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}

On this page