Discussion
 
4090 views
 
91% puke7
BotB API v1 View HTML Version
 

Battle of the Bits offers a fully public API.  Please do not abuse; request throttling and/or api access tokens might be implemented in the future.  Please enjoy.

'[#[Basic Syntax]
'[t[mono]battleofthebits.com/api/v1/{object_type}/{command}(/{param0}(/{param1}(/{param2(..))))'[/t]

A dynamically generated list of object_types with their allotted commands and properties is available here: 
https://battleofthebits.com/api/v1/documentation/index

'[#[Commands]
'[t[b3]load'[/t]
'[t[mono]battleofthebits.com/api/v1/{object_type}/load/{object_id}'[/t]

'[t[b3]list'[/t]
'[t[mono]battleofthebits.com/api/v1/{object_type}/list(/{page_number=0}(/{page_length=25}))'[/t]

Lists can be sorted by property values by using the GET method
'[t[mono]?sort={object_property}&desc=true'[/t]
The '[t[mono]desc'[/t] variable is optional; defaults to ascending.

Filters can be applied using the GET method.
'[t[mono]?filters={defined_filters}'[/t]
Filters are defined by pairing a key and value with '[t[mono]~'[/t].  Multiple filters can be defined by using '[t[mono]^'[/t] for separation.  
(example: '[t[mono]/api/v1/botbr/list/?filters=level~17^class~chipist'[/t])
*this may be deprecated in future versions

Conditionals can be applied using the POST '[t[mono]multipart/form-data'[/t] method. The API expects a JSON-style string array of filter objects assigned to '[t[mono]$_POST['conditions']'[/t]. These are much more versatile than the Filters using GET. Make sure to use '[t[mono]https://'[/t] for all POST requests or they will fail.
 
'[t[mono]"conditions": [
  { "property": "title", "operator": "LIKE", "operand": "%ass%" },
  { "property": "score_favs", "operator": ">", "operand": "40" },
  { "property": "format_token", "operator": "like", "operand": "%mod%" },
  { "property": "yt", "operator": "is", "operand": "NULL" }
]'[/t]

List of Operator Symbols: < > = >= <= !=

SQL style Operator Words: 
'[tab[-[20]"IN" (operand must be an array)
'[tab[-[20]"IS" or "IS NOT" (operand must be "NULL")
'[tab[-[20]"LIKE" (operand is text with % prefix/suffix for wildcards)

'[t[b3]search'[/t]
'[t[mono]battleofthebits.com/api/v1/{object_type}/search/{substring}(/{page_number=0}(/{page_length=25}))'[/t]

Each object type that supports the search command has a single searchable property such as 'name' or 'title'. This property is chosen within the system and is not modifiable by the end user.

'[#[Pagination]
Pagination is optional and only available for commands that support it.  The '[t[mono]page_number'[/t] is zero based and the default '[t[mono]page_length'[/t] is 25 objects.  The maximum number of objects that can be pulled in a single call is 250.

'[#[Examples]
Here are some example-requests to make it more clear:

Getting all currently ongoing battles:
'[t[mono]https://battleofthebits.com/api/v1/battle/current'[/t]
Search for a battle by name:
'[t[mono]https://battleofthebits.com/api/v1/battle/search/Winter+Chip+II'[/t]
Search for a lyceum article by name:
'[t[mono]https://battleofthebits.com/api/v1/lyceum_article/search/API'[/t]
Get a BotBr by name:
'[t[mono]https://battleofthebits.com/api/v1/botbr/list?filters=name~puke7'[/t]
'[t[mono]https://battleofthebits.com/api/v1/botbr/search/puke7'[/t]
Get a random entry:
'[t[mono]https://battleofthebits.com/api/v1/entry/random'[/t]
Get an entry by id:
'[t[mono]https://battleofthebits.com/api/v1/entry/load/12345'[/t]
Get the top 5 BotBr:
'[t[mono]https://battleofthebits.com/api/v1/botbr/list/0/5?sort=points&desc=true'[/t]
Get the top 5 BotBr filtered by class Chipist:
'[t[mono]https://battleofthebits.com/api/v1/botbr/list/0/5?filters=class~Chipist&sort=points&desc=true'[/t]
Get all (or the first 250) entries of a battle:
'[t[mono]https://battleofthebits.com/api/v1/entry/list/0/250?filters=battle_id~1234'[/t]

'[#[Response Formats]
The BotB API v1 default response format is a JSON object.  XML is also available by either setting the format via GET '[t[mono]?format=xml'[/t] or adding the '[t[mono].xml'[/t] extension to the URI.

 
C A T E G O R I E S
 
 
This Website