Example request
cURL
JavaScript
PHP
Python
Ruby
Go
curl -X POST https://api.skryx.io/v1/indexes/products/documents/batch \
-H "Authorization: Bearer $SKRYX_API_KEY" \
-H "Content-Type: application/json" \
-d '
{
"documents": [
{
"id": "1",
"title": "Sony WH-1000XM5",
"brand": "Sony",
"category": "Headphones",
"price": 379
},
{
"id": "2",
"title": "Bose QuietComfort Ultra",
"brand": "Bose",
"category": "Headphones",
"price": 449
},
{
"id": "3",
"title": "AirPods Pro 2 USB-C",
"brand": "Apple",
"category": "Headphones",
"price": 279
}
],
"action": "upsert"
}
'
const response = await fetch('https://api.skryx.io/v1/indexes/products/documents/batch', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SKRYX_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
documents: [
{
id: '1',
title: 'Sony WH-1000XM5',
brand: 'Sony',
category: 'Headphones',
price: 379,
},
{
id: '2',
title: 'Bose QuietComfort Ultra',
brand: 'Bose',
category: 'Headphones',
price: 449,
},
{
id: '3',
title: 'AirPods Pro 2 USB-C',
brand: 'Apple',
category: 'Headphones',
price: 279,
}
],
action: 'upsert',
}),
});
const data = await response.json();
<?php
$ch = curl_init('https://api.skryx.io/v1/indexes/products/documents/batch');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SKRYX_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'documents' => [
0 => [
'id' => '1',
'title' => 'Sony WH-1000XM5',
'brand' => 'Sony',
'category' => 'Headphones',
'price' => 379,
],
1 => [
'id' => '2',
'title' => 'Bose QuietComfort Ultra',
'brand' => 'Bose',
'category' => 'Headphones',
'price' => 449,
],
2 => [
'id' => '3',
'title' => 'AirPods Pro 2 USB-C',
'brand' => 'Apple',
'category' => 'Headphones',
'price' => 279,
],
],
'action' => 'upsert',
]),
]);
$response = json_decode(curl_exec($ch), true);
import os
import requests
response = requests.post(
'https://api.skryx.io/v1/indexes/products/documents/batch',
headers={
'Authorization': f"Bearer {os.environ['SKRYX_API_KEY']}",
'Content-Type': 'application/json',
},
json={
'documents': [
{
'id': '1',
'title': 'Sony WH-1000XM5',
'brand': 'Sony',
'category': 'Headphones',
'price': 379,
},
{
'id': '2',
'title': 'Bose QuietComfort Ultra',
'brand': 'Bose',
'category': 'Headphones',
'price': 449,
},
{
'id': '3',
'title': 'AirPods Pro 2 USB-C',
'brand': 'Apple',
'category': 'Headphones',
'price': 279,
}
],
'action': 'upsert',
},
)
data = response.json()
require 'net/http'
require 'json'
uri = URI('https://api.skryx.io/v1/indexes/products/documents/batch')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {
'Authorization' => "Bearer #{ENV['SKRYX_API_KEY']}",
'Content-Type' => 'application/json',
})
request.body = {
'documents' => {
0 => {
'id' => '1',
'title' => 'Sony WH-1000XM5',
'brand' => 'Sony',
'category' => 'Headphones',
'price' => 379,
},
1 => {
'id' => '2',
'title' => 'Bose QuietComfort Ultra',
'brand' => 'Bose',
'category' => 'Headphones',
'price' => 449,
},
2 => {
'id' => '3',
'title' => 'AirPods Pro 2 USB-C',
'brand' => 'Apple',
'category' => 'Headphones',
'price' => 279,
},
},
'action' => 'upsert',
}.to_json
response = JSON.parse(http.request(request).body)
package main
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]interface{}{
"documents": map[string]interface{}{
"0": map[string]interface{}{
"id": '1',
"title": 'Sony WH-1000XM5',
"brand": 'Sony',
"category": 'Headphones',
"price": 379,
},
"1": map[string]interface{}{
"id": '2',
"title": 'Bose QuietComfort Ultra',
"brand": 'Bose',
"category": 'Headphones',
"price": 449,
},
"2": map[string]interface{}{
"id": '3',
"title": 'AirPods Pro 2 USB-C',
"brand": 'Apple',
"category": 'Headphones',
"price": 279,
},
},
"action": 'upsert',
})
req, _ := http.NewRequest("POST", "https://api.skryx.io/v1/indexes/products/documents/batch", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("SKRYX_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
response, _ := io.ReadAll(resp.Body)
_ = response
}