Tenon API Quick Start
Intro to the Test API
To see Tenon in action and to verify it doesn't suck: take a quick trip to our homepage: https://tenon.io.
Now, let's dive in:
Reading endless documentation is no fun. Here's what you need to get started:
- You need an API key. If you don't have one, go to https://tenon.io/register.php.
- The API URL to submit your requests to is https://tenon.io/api.
- You'll be sending a POST request to that URL. GET requests get no response.
- The only required parameter is 'key'. Put your API key here
- You must also supply either an 'url' parameter or a 'src' parameter.
- Their names are self-explanatory: the 'url' is the address of a publicly reachable URL. Alternately, the 'src' is the full document source for a page you want tested.
- All other parameters are optional so we aren't talking about them here.
Below we show a handful of examples for submitting a request to the API. All examples below show submitting a request to test an URL. Note: none of these are "production-ready" code. You'll need to customize them to make them your own.
The single easiest way to test the API is from command line, using cURL to POST your request:
Naturally, in the above, you'd replace URL-TO-TEST with the URL you want to test and you'd replace PUT-YOUR-KEY-HERE with your API key.
As you'll see by running this command, the response is JSON-formatted and therefore it is not very useful to use Tenon strictly from the command line, but you get the point.
PHP & cURL
A more useful approach would be to POST the request using PHP and cURL. The below example shows getting the JSON response as a variable named $result.
Python 2 & urllib
Python 3 & urllib
Naturally you'll want to do something more useful with this example than simply logging it to console.
Dealing with the response
The methods above will return a JSON response which you'll then need to do something useful with. Read 'Overview of the Tenon API Response' elsewhere in these docs to get an overview of the exact response format.
There are a variety of additional parameters that can be submitted with your request. Read 'Understanding API Request Parameters' to see what they are.