How do I access a specific record in a Grist Table via API?

Hi Michael,

Here is a sample php code that works for me. When you use your API key, you should be able
to invoke it as it is. It gets records from one of Grist’s templates (link) and filters them by the order id column.
You can read more about the API in the help center API reference - Grist Help Center. Each endpoint has an accordion section with examples how to construct URLs to the Grist API, for example:
image

<?php
   function gristQuery($pquery) {
    // This is a Grist template document located at https://templates.getgrist.com/eVgQezBkmQVc/Digital-Sales-CRM/p/2
    $docId = "eVgQezBkmQVccB9qV6ParT";
    $tableId = "Orders";
    // Here use your API key.
    $apiKey = "<<paste api key>>";
    $url = "https://docs.getgrist.com/api/docs/${docId}/tables/${tableId}/records?".$pquery;
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $headers = array(
      'Authorization: Bearer '.$apiKey
    );
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    $resp = curl_exec($curl);
    curl_close($curl);
    $output = json_decode($resp, true);
    return $output;
   }

   $invoice_id = '123';
   $query_string = 'filter={"Order_No_": "'.$invoice_id.'"]}';
   $query = urlencode($query_string);
   $record = gristQuery($query);
   var_dump($record);
?>