Get started with Acuity's API quickly with an example in bash, PHP or JavaScript.
Authentication
Find your API credentials in Acuity under Integrations.
Authentication to the API is done over SSL with HTTP Basic Auth, using your numeric User ID for the username and your API Key for the password. 401 Unauthorized will be returned on authentication failure.
For information on connecting multiple Acuity accounts to your app, check out OAuth2 access.
Example
curl -u ACUITY_USER_ID:ACUITY_API_KEY "https://acuityscheduling.com/api/v1/appointments"
var Acuity = require('acuityscheduling');
var acuity = Acuity.basic({
userId: ACUITY_USER_ID,
apiKey: 'ACUITY_API_KEY'
});
acuity.request('appointments', function (err, res, appointments) {
if (err) return console.error(err);
console.log(appointments);
});
<?php
require_once('vendor/autoload.php');
$acuity = new AcuityScheduling(array(
'userId' => ACUITY_USER_ID,
'apiKey' => 'ACUITY_API_KEY'
));
$appointments = $acuity->request('appointments');
print_r($appointments);
<?php
$userID = 'ACUITY_USER_ID';
$key = 'ACUITY_API_KEY';
// URL for all appointments (just an example):
$url = 'https://acuityscheduling.com/api/v1/appointments.json';
// Initiate curl:
// GET request, so no need to worry about setting post vars:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Grab response as string:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// HTTP auth:
curl_setopt($ch, CURLOPT_USERPWD, "$userID:$key");
// Execute request:
$result = curl_exec($ch);
// Don't forget to close the connection!
curl_close($ch);
$data = json_decode($result, true);
print_r($data);
Making Cross Origin Requests and Using AJAX
You must make API requests from your own or an external server where you can store your API credentials securely. Acuity does not support cross origin requests as client side requests expose any authentication that you're using. You can expose specific endpoints on your server for the APIs you'd like to access over AJAX.
For more information on additional APIs, check out our Enterprise API documentation.