Sincronización de datos mediante un feed JSON

Configura tu JSON Feed para sincronizar tus datos con Clerk.io.

Introducción

Esta guía explica cómo configurar tus Feeds JSON para sincronizar tus datos con Clerk.io.

> Si estás usando una de nuestras plataformas soportadas, no necesitas configurar un JSON Feed.

Nuestro antiguo JSON Feed sigue siendo compatible, pero recomendamos utilizar el nuevo JSON Feed para nuevas integraciones.

El nuevo JSON Feed hace que sincronizar tus datos con Clerk.io sea más fácil y eficiente.

Esto se hace por ser capaz de sincronizar sus datos en archivos separados / puntos finales.

Y soportando paginación y actualizaciones incrementales para grandes conjuntos de datos. Panel de configuración de sincronización de datos para JSON Feed V2](data_sync_settings_overview.png)

Configuración

Para empezar, ve a my.clerk.io y haz clic en “Datos” en el menú de la izquierda.

Desplázate hasta “Configuración de sincronización de datos” y selecciona “Clerk.io JSON Feed V2” en el menú desplegable Método de sincronización de la esquina superior derecha.

Inserta las URL de tus fuentes JSON para tus Productos, Categorías, Pedidos, Clientes y Páginas, en Configuración de Sincronización de Datos. Vea aquí para saber cómo organizar las fuentes JSON para cada entidad.

Admitimos content-type: application/x-ndjson o application/json.

Seguridad

> ⚠️ ¡Tu debes mantenerte seguro, por lo que los endpoints que implementes deben requerir autenticación antes de ser desplegados! > > Por esta razón, HTTPS es forzado en todas las URLs.

Recomendamos que el feed JSON sólo acepte una conexión cifrada SSL y utilice autenticación HTTP si es posible.

Al consultar su punto final, la plataforma Clerk enviará una cabecera de autorización en cada solicitud HTTP, que deberá verificar:

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:

limit={{limit}}
offset={{offset}}
modificado_después={{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 and bool.

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:

AttributeRequiredTypeDescription
id*int/strThe product ID, which should be unique for each product
name*strThe product name.
description*strThe product description.
price*floatThe product current selling price.
list_pricefloatThe product original list price. Useful to show discounts.
image*strThe full URL for the product image. When used for thumbnails we recommend a maximum image size of 200x200px.
url*strThe product URL.
categories*arrayAn array of category IDs that the product belongs to.
created_at*intThe UNIX timestamp of when the product was created.
brandstrThe product brand.
color_namesarrayAn array of color names for the product.
color_codesarrayAn array of color codes for the product.
reviews_amountintThe amount of reviews for the product.
reviews_avgfloatThe average review score for the product.

Example JSON Feed for products

[
  {
    "id": 135,
    "name": "Lightsaber",
    "description": "Antiguo Sable de Luz Rebelde",
    "price": 99995.95,
    "imagen": "https://galactic-empire-merch.com/images/a-r-lightsaber.jpg",
    "url": "https://galactic-empire-merch.com/antique-rebel-lightsaber",
    "marca": "Je'daii",
    "categories": [987, 654],
    "created_at": 1199145600,
    "color_names": ["Verde", "Rojo"],
    "color_codes": ["#7CFC00","#FF3131"],
    "reviews_amount": 164,
    "reviews_avg": 4.8
  },
  {
    "id": 261,
    "name": "Estrella de la Muerte Deluxe",
    "description": "Estrella de la Muerte - Garantizado a prueba de idiotas",
    "price": 99999999999999.95,
    "imagen": "https://galactic-empire-merch.com/images/death-star.jpg",
    "url": "https://galactic-empire-merch.com/death-star",
    "marca": "Imperial Inc.",
    "categories": [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:

AttributeTypeDescription
id*int/strThe category ID, this should be unique for each category.
name*strThe category name.
url*strThe category URL.
subcategories*arrayAn array of category IDs that are subcategories of this category.
imagestrThe full URL for the category image.
descriptionstrThe category description.

Example JSON Feed for Categories

[
  {
    "id": 1,
    "name": "Bienes Imperiales",
    "subcategorías": [42, 25],
    "url": "https://galactic-empire-merch.com/imperial-goods"
  },
  {
    "id": 42,
    "name": "Tatooine",
    "subcategories": [],
    "url": "https://galactic-empire-merch.com/imperial-goods/tatooine"
  },
  {
    "id": 25,
    "name": "Coruscant",
    "subcategories": [],
    "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",
    "productos": [{"id":456,"quantity":1,"price":200.00}, {"id":789,"quantity":2,"price":120.00}],
    "hora": 1389871120
  },
  {
    "id": 123456,
    "cliente": 456,
    "email": "obi.wan@kenobi.me",
    "productos": [{"id":456,"quantity":1,"price":200.00}, {"id":789,"quantity":2,"price":120.00},{"id":123,"quantity":2,"price":60.00}],
    "hora": 1389870977
  },
  {
    "id": 123457,
    "cliente": "",
    "productos": [{"id":789,"quantity":2,"price":120.00}],
    "hora": 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:

AttributeTypeDescription
id*int/strThe customer ID, this should be unique for each customer.
name*strThe customers full name.
email*strThe customer email.
subscribed*boolBoolean indicating whether the customer has subscribed to newsletters. This must be true for Clerk.io to send marketing emails to this customer.
zipstrThe customers zip code.
genderstrThe customers gender
ageintThe customers age.
is_b2bboolBoolean indicating whether the customer is a business customer.

Example JSON Feed for Customers

[
  {
    "id": 135,
    "name": "Luke Skywalker",
    "email": "luke@rebels.org",
    "suscrito": true,
    "género": "masculino",
    "código postal": "1134",
    "is_b2b": "false"
  },
  {
    "id": 165,
    "name": "Darth Vader",
    "email": "vader@empire.com",
    "suscrito": false,
    "género": "masculino",
    "edad": 45,
    "intereses": ["sable láser", "fuerza"],
    "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:

AttributeTypeDescription
id*int/strThe page ID, this should be unique for each page.
type*strThe type of the content. Used to separate different types of pages such as CMP pages, blog posts and landing pages.custom.
url*strThe URL of the content.
title*strThe title of the content.
text*strThe text of the content.
imagestrThe full URL for the content image.

Example JSON Feed for Pages

[
  {
    "id": 135,
    "type": "cms",
    "url": "https://galactic-empire-merch.com/imperial-goods/tatooine",
    "title": "Horario de apertura",
    "text": "El texto principal sobre nuestro horario de apertura..."
  },
  {
    "id": 1354,
    "type": "blog",
    "url": "https://galactic-empire-merch.com/imperial-goods/tatooine",
    "title": "Nueva entrada en el blog",
    "text": "El texto principal sobre nuestro horario de apertura...",
    "keywords": ["blog", "post", "nuevo"]
  }
]

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,
    "name": {"english":"Lightsaber","spanish":"Sable de luz", "italian":"Spada laser"},
    "description": {"english":"Antique Rebel Lightsaber","spanish":"Sable de luz rebelde antiguo","italian":"Antica spada laser ribelle"},
    "price": 99995.95,
    "imagen": {"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"},
    "marca": "Je'daii",
    "categories": [987, 654],
    "created_at": 1199145600,
    "color_names": ["Verde", "Rojo"],
    "color_codes": ["#7CFC00","#FF3131"],
    "reviews_amount": 164,
    "reviews_avg": 4.8
  },
  {
    "id": 261,
    "name": {"english":"Death Star Deluxe","spanish":"Estrella de la Muerte de lujo", "italian":"La Morte Nera Deluxe"},
    "description": {"english":"Death Star - Guaranteed idiot proof","spanish":"Estrella de la Muerte: a prueba de idiotas garantizada","italian":"Morte Nera - A prova di idiota garantita"},
    "price": 99999999999999.95,
    "imagen": {"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"},
    "marca": "Imperial Inc,
    "categories": [345678],
    "created_at": 1197565600
  }
]