API Documentation
We’ve built a WordPress Plugin and Zapier Integration already, but you can integrate EveryAlt into any software using our simple, powerful API.
We encourage you to use our open-source WordPress Plugin as a guide when coding your own application. We recommend – but do not require – that you release your EveryAlt API integrations under the open-source General Public License. If you’re working on a public EveryAlt-powered tool, please share it with us so we can promote it and give you free image credits for testing.
Getting Started
You’ll need to create a free EveryAlt account to get your API key. Please note that you shouldn’t include your own key in a publicly accessible application, since other users would then be able to use your image quota. Instead, build a way for your users to enter their own EveryAlt API key.
Sending an API request is easy. Here’s the endpoint:
https://everyalt.com/wp-json/api/v1/altimages
Send a POST request with a single element called url
. The value of url
should be the URL of the image you want to analyze. Send a header called Authorization
with the value Bearer: [Your API Key]
.
Here’s a full PHP cURL Request, adapted from our WordPress plugin:
function every_alt_generate_alt($url, $api_key){ $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://everyalt.com/wp-json/api/v1/altimages', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('url' => $url), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer '. $api_key ), )); $response = curl_exec($curl); curl_close($curl); return json_decode($response); }
A successful response will contain the alternative text for the image you provided, as well as your current image credit quota (tokens
) and how much of that quota you’ve used to date (used_tokens
). Here’s an example:
{ "tokens": "100", "used_tokens": "10", "url": [The URL you submitted], "alt": [The alternative text generated by EveryAlt] "full_text": [If the image contains text, such as a screenshot, it will appear here.] }
Note that the full_text
key is optional. It will only appear in your response if EveryAlt interprets your image as a screenshot or an image that contains lots of text. In that case, the alt
will contain a brief description of the image, and the full_text
will contain all the readable text from the image.
If you receive an error in response, it will look like this:
{ "code": "rest_forbidden", "message": "Your API key is invalid.", "data": { "status": 401 } }
Two possible error messages are Your API key is invalid.
and You've used all the image credits for this API key. Add more at EveryAlt.com.
Please note that every time you hit this endpoint and get a successful response, it will deduct one image credit from your balance.
Checking Your Image Quota
To check the remaining image credits associated with your API key, send the same request as above to the following endpoint. Please note that you do not need any POST array on this request, but it should still be set up as a POST request (i.e. as if you had submitted an empty form).
https://everyalt.com/wp-json/api/v1/get_available_tokens
This will return JSON showing your remaining image credits. Hitting this endpoint does not deduct from your credit balance, but we may rate-limit this endpoint within reason.
Questions?
Keep in mind that the API is intended for experienced developers only. If you don’t want to dig into code, use our easy, plug-and-play WordPress Plugin or Zapier Integration instead.
If you’d like to talk shop about building an API integration, we’re here to help.