English
English
Appearance
English
English
Appearance
To upload the whole catalog and at the same time remove everything that is no longer part of it, open a sync, send the batches with its identifier, and commit at the end.
curl -X POST https://catalog.api.metty.eu/catalog/syncs \
-H "Authorization: Bearer <SECRET_API_KEY>"{ "sync_id": "sync_8f2c1d4e5a6b7c8d" }Send the batches with ?sync=:
curl -X PUT 'https://catalog.api.metty.eu/catalog/products?sync=sync_8f2c1d4e5a6b7c8d' \
-H "Authorization: Bearer <SECRET_API_KEY>" \
-H "Content-Type: application/json" \
-d '[ … ]'Once every batch is uploaded:
curl -X POST https://catalog.api.metty.eu/catalog/syncs/sync_8f2c1d4e5a6b7c8d/commit \
-H "Authorization: Bearer <SECRET_API_KEY>"{ "sync_id": "sync_8f2c1d4e5a6b7c8d", "status": "committed", "kept": 1240, "removed": 37 }Products that did not arrive during the sync are removed from the database and the index. A PUT without the sync parameter is an ordinary incremental update and does not count towards the sync.
Committing an incomplete snapshot would remove most of the catalog, so we reject it in these cases:
| situation | error |
|---|---|
| the sync contains no products | 409 generation_incomplete |
| the sync covers less than 50 % of the catalog | 409 generation_incomplete |
| the sync is already committed | 409 generation_committed |
| the sync identifier does not exist | 404 not_found |
If you are shrinking the catalog on purpose (for example after discontinuing half of your range), send {"force": true} in the commit body.
A commit closes the sync. A further write with the same sync_id returns 409 generation_committed, so a snapshot cannot be reopened.
?sync= parameter.status: "error".A working implementation of this procedure is in the examples.
The export is there to verify what state of the catalog Metty actually holds:
curl 'https://catalog.api.metty.eu/catalog/products?page=1&per_page=100' \
-H "Authorization: Bearer <SECRET_API_KEY>"{
"total": 1240,
"page": 1,
"per_page": 100,
"pages": 13,
"products": [
{
"id": "sku-1",
"name": "Príklepová vŕtačka Bosch",
"url": "https://eshop.sk/vrtacka",
"price": 129.9,
"list_price": 159.9,
"currency": "EUR",
"in_stock": true,
"brand": "Bosch",
"category": "Náradie > Vŕtačky",
"description": "Príklepová vŕtačka s reguláciou otáčok.",
"image": "https://eshop.sk/media/vrtacka.jpg",
"params": { "farba": "modrá" }
}
]
}The per_page parameter is clamped to 1–500 (default 100). Products come back in exactly the shape PUT accepts, so an export can be fed straight back in as input.
The export works for an e-shop in feed mode as well — the safeguard against mixing modes applies to writes only.