The keyboard database supports external access so that your website or application can pull data on a particular keyboard or multiple keyboards in a standardised format. This page will detail how to make a request for such data and what format(s) the data will be provided in.
Please note that this is not an absolute guaranteed service - this service will run so long as there is no abuse of it and I have the funds to maintain the traffic it generates. As such, I reserve the right to discontinue the external access service as I please but I will strive to ensure there is at least a two-week notice of such action.
The API can be utilised by accessing the request URL https://sharktastica.co.uk/kb_db_req.php with some GET parametres. All requests will need to have at least three parametres to form a URL that looks like https://sharktastica.co.uk/kb_db_req.php?param1=x¶m2=y¶m3=z
, which are all explained below.
Match field is the first of two methods of searching for a result and thus a choice variable that can be used instead of search query. This parametre doesn't have a set name. Instead, it's used by specifying one of the field names and assigning it your search query. See the "Possible fields" table below to find out what fields you can use.
q
)Search query is the second of two methods of searching for a result and thus a choice variable that can be used instead of match field. The q
parametre is used to denote this. See the "Search query guide" below to find out how to form the queries to input into it.
dat
)The dat
parametre is a required variable that specifies that the returned data format should be. At present, the supported data formats are JSON (stable) and XML (beta).
fields
)The fields
parametre is a required variable that specifies what fields of data you want returned. See the "Possible fields" table below to find out what fields you can use. You can use one or more of the field names as a comma-separated list, or, you can use the '*' wildcard to indicate you want all fields.
c
)The c
parametre is an optional variable used for specifying a results count limit for your results.
Every single request made should return a result in either JSON or XML as per your dat parametre or JSON if no dat is specified. Below outlines all the possible members to expect.
The success
member is an always-present value that indicates if a request was successful (true
) or resulted in error (false
). Note that a request that produced no results is still a successful request.
The message
member is a success-dependent value that contains any error messages returned from attempting the request. The member will only be present if the request was unsuccessful. Note that at present, all unsuccessful requests are returned in JSON regardless of whether XML use has been flagged by a dat parametre.
The hits
member is a success-dependent value that indicates how many results were found with your request regardless of what row count limit was provided. If the request is a match field request, the value will always be 1 if a keyboard is found. For all types of request, 0 indicates no results found. The member will only be present if the request was successful.
The results
array is a success-dependent value that contains an array of all keyboard data found. If the request is a match field request, the array will only contain one element if a keyboard is found. If no results are found by an request, the array will still exist but will be empty. The member will only be present if the request was successful.
These field names are used for specifying a search parametre or for filtering what fields of data should be returned. Fields correspond to specific data on keyboards, which is explained in the key below.
If you decide to use search queries instead of match field, note that there are three types of searches you can pull off with the q
parametre. These are the same as the latter three searching strategies outlined in the Keyboard Database Help page for use with the website's public database interface. If you plan to allow users of your website or application to search via this request API, it might be prudent to link them to that help page or write a version of it for your website or application.
If you want something very specific, putting an exclamation mark before your query will flag that you want an exact match. In the example below, this will return all the keyboards that have a field that exactly reads "Model F Functional Key Keyboard".
If you want many results without exact matching and have them sorted about the amount of occurrences of each term in each result, comma-separate the terms. In the example below, this will return all keyboards that have a fields reading "IBM", "Model F" or "122" sorted by the ascending total number of occurrences found.
If you want very refined results without exact matching, semi-colon separate the terms. In the example below, this will return all keyboards that have fields reading "IBM", "Model F" and "122" at the same time sorted by part number.