Search Functions · operationId:Invoke

Invoke a Search Function

POST /v1/search-functions/{functionId}/invoke

Description

Search Functions return nearest-neighbor Samples instead of a Label. Provide either data (raw input) or an existing sampleId as the query.

Path parameters

NameTypeRequiredDescription
functionId string yes

Query parameters

NameTypeRequiredDescription
sampleCount integer (int32) no

includeData boolean no

Whether to include the sample data in the response. Defaults to true

Request body

Content type: application/json. Body schema: SearchInvokeInput.

Responses

StatusDescriptionBody
200 Invoke succeeded array<SearchSample>

Code samples

curl
curl -X POST \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{
  "sampleId": "<sampleId>",
  "data": {
    "size": 0
  }
}' \
  'https://www.nyckel.com/v1/search-functions/<functionId>/invoke'
Python
import requests

url = 'https://www.nyckel.com/v1/search-functions/<functionId>/invoke'
headers = {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
}

body = """{
  "sampleId": "<sampleId>",
  "data": {
    "size": 0
  }
}"""
response = requests.post(url, headers=headers, data=body)
print(response.json())
JavaScript
fetch('https://www.nyckel.com/v1/search-functions/<functionId>/invoke', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <accessToken>',
    'Content-Type': 'application/json',
  },
  body: `{
  "sampleId": "<sampleId>",
  "data": {
    "size": 0
  }
}`,
})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/search-functions/<functionId>/invoke');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

$headers = array(
    'Authorization: Bearer <accessToken>',
    'Content-Type: application/json',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$body = <<<'NYCKEL_BODY'
{
  "sampleId": "<sampleId>",
  "data": {
    "size": 0
  }
}
NYCKEL_BODY;
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
curl_close($ch);
echo $response;