Developer Center

Resources to get you started with Algorithmia



The PHP client is still in development. For now, you can use cURL inside your PHP code to call any algorithm:

Calling an algorithm via cURL in PHP


  // get your API Key at
  $api_key = 'YOUR_API_KEY';
  // pick an algorithm at -- and append a version number
  $algorithm = 'util/Echo/0.2.1';
  // most algorithms accept JSON Objects
  $data = array('hello' => 'world');
  $data_json = json_encode($data);
  // prepare cURL to algorithm endpoint
  $ch = curl_init();
  $headers = array(
    'Content-Type: application/json',
    'Authorization: Simple ' . $api_key,
    'Content-Length: ' . strlen($data_json)
  curl_setopt_array($ch, array(
    CURLOPT_URL => '' . $algorithm,
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_POSTFIELDS => $data_json,
    CURLOPT_POST => true
  // run the algorithm and get the results (usually a JSON-encoded string)
  $response_json = curl_exec($ch);
  $response = json_decode($response_json);
  // $response->result contains algorithm results (if any)
  // $response->error contains errors (if any)
  // $response->metadata has meta-information
  if($response->error) {
    print('ERROR: ');
  } else {


Additional information

While most algorithms accept JSON Objects, you can also use Content-Type: text/plain for ones which require bare string input, or Content-Type: application/octet-stream for those that require a binary (such as an image file). Adjust the lines containing $data_json as needed.

See the full cURL Client Guide and API Specification for additional details on calling algorithms and managing data with cURL.