Introduzione #
Questa guida spiega come impostare i feed JSON per sincronizzare i dati con Clerk.io.
> Se si utilizza una delle nostre piattaforme supportate, non è necessario impostare un feed JSON.
Il nostro vecchio Feed JSON è ancora supportato, ma consigliamo di utilizzare il nuovo Feed JSON per le nuove integrazioni.
Il nuovo Feed JSON rende più semplice ed efficiente la sincronizzazione dei dati con Clerk.io.
Ciò avviene grazie alla possibilità di sincronizzare i dati in file/endpoint separati.
E supporta la paginazione e gli aggiornamenti incrementali per i set di dati di grandi dimensioni.
Impostazione #
Per iniziare, andare su my.clerk.io e fare clic su “Dati” nel menu a sinistra.
Scorrere fino a “Impostazioni di sincronizzazione dei dati” e scegliere “Clerk.io JSON Feed V2” dal menu a tendina “Metodo di sincronizzazione” nell’angolo in alto a destra.
Inserire gli URL dei feed JSON per i prodotti, le categorie, gli ordini, i clienti e le pagine in Impostazioni di sincronizzazione dei dati. [Vedere qui] (#expected-json-feed-structure) per sapere come organizzare i feed JSON per ciascuna entità.
Supportiamo il tipo di contenuto
: application/x-ndjson
o application/json
.
Sicurezza #
> ⚠️ Il vostro deve essere mantenuto sicuro, quindi gli endpoint che implementate devono richiedere l’autenticazione prima di essere distribuiti! > > Per questo motivo, l’HTTPS è forzato su tutti gli URL.
Si raccomanda che il feed JSON accetti solo una connessione crittografata SSL e che utilizzi l’autenticazione HTTP, se possibile.
Quando si interroga l’endpoint, la piattaforma Clerk invia un’intestazione di autorizzazione a ogni richiesta HTTP, che deve essere verificata:
X-Clerk-Authorization : Bearer THE_TOKEN
You can verify the token with a POST request to the token/verify endpoint https://api.clerk.io/v2/token/verify
:
{ "token": "THE_TOKEN", "key": "your_store_public_key"}
See our api documentation for more details
Incremental Updates #
Products, Categories, Customers and Pages are deleted if not present in the JSON Feed. Use the
modified_after
query parameter to enable incremental updates and keep existing data that has not been modified. See Below
Orders are always retained
By default Clerk.io will delete Products, Categories, Customers and Pages that are not present in the JSON Feed.
When having big data sets, this can be a problem, as it can take a long time to sync all data.
In this case, you can send only the data that has bene modified after a given date, which can be done by using the modified_after
query parameter. See Below
Orders are always retained. These can be deleted by sending a DELETE request to the orders endpoint.
Query Parameters #
To support pagination and incremental updates for large data sets, we support the following query parameters:
limite={{limit}}
offset={{offset}}
modified_after={{modified_after}}
Paging size with {{limit}}
and {{offset}}
#
The limit
query parameter can be used to limit the amount of entities returned in each request.
The default value is 25 and the maximum value is 1000.\
When using the limit
query parameter, you must also use the offset
query parameter.
As we increase the offset
by the limit
until no more data is returned, either by returning an empty array or by an empty response.
Using the modified_after
query parameter
#
Retaining only works if {{modified_after}} is present in the URL and a value in
Incremental Time
.
To retain existing data, you can use the modified_after
query parameter.
{{modified_after}}
needs to be present in the URL as well as a value in Incremental Time
in Data Sync Settings for this to take effect.
This only effects each URL individually, so if you have multiple URLs, you need to add {{modified_after}}
to each URL.
To delete Products, Categories, Customers and Pages that are not present in the JSON Feed, you can send a DELETE request to the products endpoint, categories endpoint, customers endpoint and pages endpoint.
JSON Feed Structure #
We only support attributes of the types:
int
,float
,str
,array
andbool
.
Each JSON Feed should be an array of objects, where each object represents a single entity (product, category, order, customer or page). Objects in the Products URL should represent products, objects in the Categories URL should represent categories, etc.
Each object must contain the mandatory fields for the entity type, and can optionally contain any extra attributes.
Mandatory fields are marked with a * in the tables below.
Products #
The JSON Feed for products should be an array of objects, where each object represents a single product.
Table of mandatory and some examples of optional fields for a product object:
Attribute | Required | Type | Description |
---|---|---|---|
id | * | int/str | The product ID, which should be unique for each product |
name | * | str | The product name. |
description | * | str | The product description. |
price | * | float | The product current selling price. |
list_price | float | The product original list price. Useful to show discounts. | |
image | * | str | The full URL for the product image. When used for thumbnails we recommend a maximum image size of 200x200px. |
url | * | str | The product URL. |
categories | * | array | An array of category IDs that the product belongs to. |
created_at | * | int | The UNIX timestamp of when the product was created. |
brand | str | The product brand. | |
color_names | array | An array of color names for the product. | |
color_codes | array | An array of color codes for the product. | |
reviews_amount | int | The amount of reviews for the product. | |
reviews_avg | float | The average review score for the product. |
Example JSON Feed for products #
[
{
"id": 135,
"nome": "Spada laser",
"descrizione": "Antica spada laser ribelle",
"prezzo": 99995.95,
"immagine": "https://galactic-empire-merch.com/images/a-r-lightsaber.jpg",
"url": "https://galactic-empire-merch.com/antique-rebel-lightsaber",
"marchio": "Je'daii",
"categorie": [987, 654],
"created_at": 1199145600,
"nomi_colori": ["Verde", "Rosso"],
"codici_colore": ["#7CFC00","#FF3131"],
"importo_recensioni": 164,
"recensioni_avg": 4.8
},
{
"id": 261,
"nome": "Morte Nera Deluxe",
"descrizione": "Morte Nera - Garantita a prova di idiota",
"prezzo": 99999999999999.95,
"immagine": "https://galactic-empire-merch.com/images/death-star.jpg",
"url": "https://galactic-empire-merch.com/death-star",
"marchio": "Imperial Inc.",
"categorie": [345678],
"created_at": 1197565600
}
]
Categories #
The JSON Feed for Categories should be an array of objects, where each object represents a single category.
Table of mandatory and some examples of optional fields for a category object:
Attribute | Type | Description | |
---|---|---|---|
id | * | int/str | The category ID, this should be unique for each category. |
name | * | str | The category name. |
url | * | str | The category URL. |
subcategories | * | array | An array of category IDs that are subcategories of this category. |
image | str | The full URL for the category image. | |
description | str | The category description. |
Example JSON Feed for Categories #
[
{
"id": 1,
"nome": "Beni Imperiali",
"sottocategorie": [42, 25],
"url": "https://galactic-empire-merch.com/imperial-goods"
},
{
"id": 42,
"nome": "Tatooine",
"sottocategorie": [],
"url": "https://galactic-empire-merch.com/imperial-goods/tatooine"
},
{
"id": 25,
"nome": "Coruscant",
"sottocategorie": [],
"url": "https://galactic-empire-merch.com/imperial-goods/coruscant"
}
]
Orders #
Orders are stored as a log and thus never deleted. If you want to delete an order, you can do so by sending a DELETE request to the orders endpoint.
The JSON Feed for Orders should be an array of objects, where each object represents a single order.
Table of mandatory and some examples of optional fields for a order object:
Example JSON Feed for Orders #
[
{
"id": 123458,
"cliente": 789,
"email": "vader@the-death-star.com",
"prodotti": [{"id":456,"quantity":1,"price":200.00}, {"id":789,"quantity":2,"price":120.00}],
"orario": 1389871120
},
{
"id": 123456,
"cliente": 456,
"email": "obi.wan@kenobi.me",
"prodotti": [{"id":456,"quantity":1,"price":200.00}, {"id":789,"quantity":2,"price":120.00},{"id":123,"quantity":2,"price":60.00}],
"orario": 1389870977
},
{
"id": 123457,
"cliente": "",
"prodotti": [{"id":789,"quantity":2,"price":120.00}],
"ora": 1389871090
}
]
Customers #
The JSON Feed for Customers should be an array of objects, where each object represents a single customer.
Table of mandatory and some examples of optional fields for a customer object:
Attribute | Type | Description | |
---|---|---|---|
id | * | int/str | The customer ID, this should be unique for each customer. |
name | * | str | The customers full name. |
email | * | str | The customer email. |
subscribed | * | bool | Boolean indicating whether the customer has subscribed to newsletters. This must be true for Clerk.io to send marketing emails to this customer. |
zip | str | The customers zip code. | |
gender | str | The customers gender | |
age | int | The customers age. | |
is_b2b | bool | Boolean indicating whether the customer is a business customer. |
Example JSON Feed for Customers #
[
{
"id": 135,
"nome": "Luke Skywalker",
"email": "luke@rebels.org",
"sottoscritto": true,
"genere": "maschio",
"CAP": "1134",
"is_b2b": "false"
},
{
"id": 165,
"nome": "Darth Vader",
"email": "vader@empire.com",
"sottoscritto": false,
"genere": "maschio",
"età": 45,
"interessi": ["spada laser", "forza"],
"is_b2b": true
}
]
Pages #
The JSON Feed for Pages should be an array of objects, where each object represents a single page.
Table of mandatory and some examples of optional fields for a page object:
Attribute | Type | Description | |
---|---|---|---|
id | * | int/str | The page ID, this should be unique for each page. |
type | * | str | The type of the content. Used to separate different types of pages such as CMP pages, blog posts and landing pages.custom . |
url | * | str | The URL of the content. |
title | * | str | The title of the content. |
text | * | str | The text of the content. |
image | str | The full URL for the content image. |
Example JSON Feed for Pages #
[
{
"id": 135,
"tipo": "cms",
"url": "https://galactic-empire-merch.com/imperial-goods/tatooine",
"title": "Orari di apertura",
"text": "Il testo principale sugli orari di apertura...".
},
{
"id": 1354,
"tipo": "blog",
"url": "https://galactic-empire-merch.com/imperial-goods/tatooine",
"title": "Nuovo post sul blog",
"text": "Il testo principale sui nostri orari di apertura...",
"parole chiave": ["blog", "post", "nuovo"].
}
]
Multi-language feed #
Please note that multi-language feed is not generally recommended. We do not support all features e.g. Pages import. We do not generally advice this due to how easy it is to mess up the indexation if the requirements are not met.
Example JSON Feed for products #
[
{
"id": 135,
"nome": {"english":"Lightsaber","spanish":"Sable de luz", "italian":"Spada laser"},
"descrizione": {"english":"Antique Rebel Lightsaber","spanish":"Sable de luz rebelde antiguo","italian":"Antica spada laser ribelle"},
"prezzo": 99995.95,
"immagine": {"english":"https://galactic-empire-merch.com/images/a-r-lightsaber.jpg","spanish":"https://galactic-empire-merch.com/es/images/a-r-lightsaber.jpg","italian":"https://galactic-empire-merch.com/it/images/a-r-lightsaber.jpg"},
"url": {"english":"https://galactic-empire-merch.com/antique-rebel-lightsaber","spanish":"https://galactic-empire-merch.com/es/antique-rebel-lightsaber","italian":"https://galactic-empire-merch.com/it/antique-rebel-lightsaber"},
"marchio": "Je'daii",
"categorie": [987, 654],
"created_at": 1199145600,
"nomi_colori": ["Verde", "Rosso"],
"codici_colore": ["#7CFC00","#FF3131"],
"importo_recensioni": 164,
"recensioni_avg": 4.8
},
{
"id": 261,
"nome": {"english":"Death Star Deluxe","spanish":"Estrella de la Muerte de lujo", "italian":"La Morte Nera Deluxe"},
"descrizione": {"english":"Death Star - Guaranteed idiot proof","spanish":"Estrella de la Muerte: a prueba de idiotas garantizada","italian":"Morte Nera - A prova di idiota garantita"},
"prezzo": 99999999999999.95,
"immagine": {"english":"https://galactic-empire-merch.com/images/death-star.jpg","spanish":"https://galactic-empire-merch.com/es/images/death-star.jpg","italian":"https://galactic-empire-merch.com/it/images/death-star.jpg"},
"url": {"english":"https://galactic-empire-merch.com/death-star","spanish":"https://galactic-empire-merch.com/es/death-star","italian":"https://galactic-empire-merch.com/it/death-star"},
"marchio": "Imperial Inc."
"categorie": [345678],
"created_at": 1197565600
}
]