Enhancements to DBQuery REST Endpoint


#1

The following applies to the Nightly Build after 08 July 2017.

The REST API for DB queries has been enhanced to provide the following options:

 table=tableName&getAllRows                          - Get all rows from a table.
 table=tableName&getSortedRows                       - Get all rows sorted from a table.
 table=tableName&getSortedRowsByValue                - Get all rows sorted from a table.

 table=tableName&getSortedRows&order=DESC|ASC        - Options for getSortedRows, any combination may be used.
 table=tableName&getSortedRows&limit=n
 table=tableName&getSortedRows&offset=n

 table=tableName&getSortedRowsByValue&order=DESC|ASC
 table=tableName&getSortedRowsByValue&limit=n
 table=tableName&getSortedRowsByValue&offset=n

This will return data in the following format:

{
	"table": {
		"table_name" : "tableName",
		"results" : [
			{
				"key" : "keyString",
				"value" : "valueString"
			}
		]
	}
}

This will allow folks using the REST API to be able to pull all data from a database table and optionally sort that data and provide a limit and/or offset.

The following is an example query:

curl -X GET localhost:27000/dbquery?webauth=MyWebAuthKey\&table=points\&getSortedRowsByValue\&limit=10
{"table":{"table_name":"points","results":[{"key":"djabardo","value":"38507292"},{"key":"notillusionaryone","value":"693332"},{"key":"mivixof","value":"643154"},{"key":"nightmisty1","value":"643089"},{"key":"brandino2","value":"643001"},{"key":"sirjj777","value":"625290"},{"key":"illusionarybot","value":"306622"},{"key":"illusionaryone","value":"74363"},{"key":"scaniatv","value":"9586"},{"key":"sokail87","value":"4183"}]}}

Wordpress / PHP Generated Pages