Skip to docs content

PHP REST API Integration - REST API Tools & Database API

cURL is a PHP library and command-line tool perfect for integrating with Apito’s REST API tools and database API. It allows you to send and receive data from your instant API over HTTP and FTP. When working with our API builder, you can use proxies, pass data over SSL connections, set cookies, and access protected database API endpoints that require authentication.

Using curl in Raw PHP Project

Tip:

Always remember to replace API_SECRET in the Bearer Token and project-id in the URL with the correct values from the Apito console.
If you are unsure where to find your API secrets and endpoints for your project, visit this page.

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.apito.io/secured/rest/project-id",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "authorization: Bearer API_SECRET",
    "content-type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}