Example request
cURL
JavaScript
PHP
Python
Ruby
Go
curl -X POST https://api.skryx.io/v1/indexes \
-H "Authorization: Bearer $SKRYX_API_KEY" \
-H "Content-Type: application/json" \
-d '
{
"name": "products",
"schema": {
"fields": [
{
"name": "title",
"type": "string"
},
{
"name": "brand",
"type": "string",
"facet": true
},
{
"name": "category",
"type": "string",
"facet": true
},
{
"name": "price",
"type": "float",
"facet": true
}
],
"default_sorting_field": "price"
}
}
'
const response = await fetch('https://api.skryx.io/v1/indexes', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SKRYX_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'products',
schema: {
fields: [
{
name: 'title',
type: 'string',
},
{
name: 'brand',
type: 'string',
facet: true,
},
{
name: 'category',
type: 'string',
facet: true,
},
{
name: 'price',
type: 'float',
facet: true,
}
],
default_sorting_field: 'price',
},
}),
});
const data = await response.json();
<?php
$ch = curl_init('https://api.skryx.io/v1/indexes');
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([
'name' => 'products',
'schema' => [
'fields' => [
0 => [
'name' => 'title',
'type' => 'string',
],
1 => [
'name' => 'brand',
'type' => 'string',
'facet' => true,
],
2 => [
'name' => 'category',
'type' => 'string',
'facet' => true,
],
3 => [
'name' => 'price',
'type' => 'float',
'facet' => true,
],
],
'default_sorting_field' => 'price',
],
]),
]);
$response = json_decode(curl_exec($ch), true);
import os
import requests
response = requests.post(
'https://api.skryx.io/v1/indexes',
headers={
'Authorization': f"Bearer {os.environ['SKRYX_API_KEY']}",
'Content-Type': 'application/json',
},
json={
'name': 'products',
'schema': {
'fields': [
{
'name': 'title',
'type': 'string',
},
{
'name': 'brand',
'type': 'string',
'facet': True,
},
{
'name': 'category',
'type': 'string',
'facet': True,
},
{
'name': 'price',
'type': 'float',
'facet': True,
}
],
'default_sorting_field': 'price',
},
},
)
data = response.json()
require 'net/http'
require 'json'
uri = URI('https://api.skryx.io/v1/indexes')
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 = {
'name' => 'products',
'schema' => {
'fields' => {
0 => {
'name' => 'title',
'type' => 'string',
},
1 => {
'name' => 'brand',
'type' => 'string',
'facet' => true,
},
2 => {
'name' => 'category',
'type' => 'string',
'facet' => true,
},
3 => {
'name' => 'price',
'type' => 'float',
'facet' => true,
},
},
'default_sorting_field' => 'price',
},
}.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{}{
"name": 'products',
"schema": map[string]interface{}{
"fields": map[string]interface{}{
"0": map[string]interface{}{
"name": 'title',
"type": 'string',
},
"1": map[string]interface{}{
"name": 'brand',
"type": 'string',
"facet": true,
},
"2": map[string]interface{}{
"name": 'category',
"type": 'string',
"facet": true,
},
"3": map[string]interface{}{
"name": 'price',
"type": 'float',
"facet": true,
},
},
"default_sorting_field": 'price',
},
})
req, _ := http.NewRequest("POST", "https://api.skryx.io/v1/indexes", 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
}