ScoreShots API Documentation
General
The ScoreShots API allows you powerful interfacing with our data, using MySQL-like parameters & concepts. You can do CRUD operations, as well application-specific operations native to services such as S3. CRUD operations are batched, meaning you can send multiple requests with one API call. All requests return a JSON object
General Endpoint Structure
https://api.scoreshots.com/v1/TABLE/ACTION/DATA_MODE/
- TABLE - the table as it named in the Database
- ACTION - the action that we are perfoming on said table. Generally, these are: retrieve, update, delete, create. But there are more application-specific ones outlined below.
- DATA_MODE - this allows you to switch between production and staging data. Currently the accepted values are: prod & dev
General Data Specifications
To perform any requests to the API, a POST key of 'body' must be supplied each time. The body is generally an array, containing the children of the batched requests. Here are the parameters for each type of CRUD requests that the children of the body can accept.
Parameters applicable to all general ACTION
- body[].__key - A unique key that allows you to identify the request when it is sent back from the server.
- body[].object - Allows you to override the current TABLE that's being interfaced with
- body[].where - Performs a WHERE clause.
- body[].where.rule - Adds a conditional rule. Acceptable values are: "&&", "AND", "||", "OR"
- body[].where.conditions[] - The conditions. Returns : "WHERE ${body[].where.conditions[][][0]} ${body[].where.conditions[][][1]} ${body[].where.conditions[][][2]}";
/retrieve/
- body[].fields[] - Specifies the column fields that will be returned, default is '*' (returns all column fields);
- body[].limit - Specifies the limit on the amount of rows to be returned, default is '0,30'.
- body[].order_by - Specifies the order of the rows. Example: "ID DESC"
- body[].left_join[3] - Performs a left join. Returns: "LEFT JOIN ${body[].left_join[0]} ON ${body[].left_join[1]} = ${body[].left_join[2]}"
- body[].inner_join[3] - Performs an inner join. Returns: "INNER JOIN ${body[].inner_join[0]} ON ${body[].inner_join[1]} = ${body[].inner_join[2]}"
- body[].right_join[3] - Performs a right join. Returns: "RIGHT JOIN ${body[].right_join[0]} ON ${body[].right_join[1]} = ${body[].right_join[2]}"
- body[].full_join[3] - Performs a full join. Returns: "FULL OUTER JOIN ${body[].full_join[0]} ON ${body[].full_join[1]} = ${body[].full_join[2]}"
/update/
- body[].set[] - Allows you to perform a SET clause. Returns: "SET ${body[].set[][][0]} ='${body[].set[][][1]}' "
/create/
- body[].fields[] - Specifies the column fields that will be inserted.
- body[].values[] - Specifies the values that will be inserted, relative to the fields above.
/delete/
/describe-schema/
Shows all tables in the Database
Returns
On success, success is true, batched is true, and objects is an array of the batched objects. Each item in objects returns a boolean success, a key (which was set with the __key body parameter); if success is true, then a data array is returned, if not an error message is returned. If a message is returned, this usually indicates a MySQL error.
Application-specific endpoints
S3
/S3/create-access-token/ - Create access token for S3 firewall
Body parameters
Note: the body is not batched, so an array is not accepted.
- body.user_id - The user ID
- body.bucket - The S3 bucket
- body.folder - The folder within the S3 bucket
- body.admin - Boolean to determine whether this token gives admin privileges
Returns: *.token
/S3/put-object/ - Uploads new file to S3
Body parameters
Note: the body is not batched, so an array is not accepted.
- body.token - The S3 firewall access token
- body.file - Base64 encoded file
- body.object - The name of the file
- body.type - The content type of the file. Example: "image/png"
- body.folder - Overide existing folder controls. Only applicable to admin tokens.
Returns: *.s3_response
/S3/delete-object/ - Delete file in S3
Body parameters
Note: the body is not batched, so an array is not accepted.
- body.token - The S3 firewall access token
- body.object - The name of the file
- body.folder - Overide existing folder controls. Only applicable to admin tokens.
Returns: *.s3_response