My projet is based on PHP.
Is there and SDK for it?
Are there exaples using PHP?
Hi @shlomo1. Pinecone doesn’t offer an official PHP SDK, but it looks like there are some community-supported SDKs out there. Pinecone hasn’t tested any of them, but at first glance, this one looks more up-to-date than some others: GitHub - probots-io/pinecone-php: A beautiful, extendable PHP Package to communicate with your pinecone.io indices, collections and vectors..
Interested to hear if that works for you. If not, it’s always an option to use the API directly with curl
, for example:
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pinecone.io/indexes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"deletion_protection\": \"enabled\",\n \"dimension\": 1536,\n \"metric\": \"cosine\",\n \"name\": \"movie-recommendations\",\n \"spec\": {\n \"serverless\": {\n \"cloud\": \"gcp\",\n \"region\": \"us-east1\"\n }\n }\n}",
CURLOPT_HTTPHEADER => [
"Api-Key: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Best,
Jesse