Skip to content

Wix

This recipe puts each frame you approve in Shootika on the matching Wix Stores product. It follows the pattern every recipe shares; this page covers the Wix side.

Wix Stores has two catalog versions, V1 and V3, with different APIs that are not compatible with each other. Wix says every site will move to V3 in time, and a site on V3 does not go back to V1. Step 3 tells you which one your site uses.

You need:

  • a Shootika API key (see Authentication);
  • a Wix API key from your Wix account, with permission to manage your site’s Stores products and its Media Manager;
  • your Wix site id.

A Wix API key is sent in the Authorization header, together with a wix-site-id header that names the site.

Terminal window
export WIX_API_KEY="your Wix API key"
export WIX_SITE_ID="your Wix site id"

When you create the product in Shootika, put the Wix product id in external_id:

Terminal window
curl https://api.shootika.com/v1/products \
-H "Authorization: Bearer $SHOOTIKA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Ribbed crew sweater",
"garment_category": "tops",
"external_id": "9e8924aa-c3f2-4fe6-bc98-ace47295c52d",
"image_urls": ["https://example.com/photos/sweater-flat.jpg"]
}'

Then shoot, and review the frames in Shootika, as in the pattern.

Read every page of the approved frames, starting with PAGE=1:

Terminal window
curl "https://api.shootika.com/v1/frames?approved=true&page=$PAGE&page_size=100" \
-H "Authorization: Bearer $SHOOTIKA_API_KEY"

Add one to PAGE and ask again until page times page_size reaches total. The list is newest first, so a frame shot weeks ago and approved today can be on a later page; reading only the first page misses it. Compare every frame id against your record of published frames. To check one product, add &product_id= with its Shootika id instead.

For each frame you have not published yet, keep its image.url and read its product’s external_id:

Terminal window
curl https://api.shootika.com/v1/products/$PRODUCT_ID \
-H "Authorization: Bearer $SHOOTIKA_API_KEY"
Terminal window
WIX_PRODUCT_ID="the product's external_id"
FRAME_URL="the frame's image.url"
Terminal window
curl https://www.wixapis.com/stores/v3/provision/version \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID"

catalogVersion is V1_CATALOG, V3_CATALOG or STORES_NOT_INSTALLED. On STORES_NOT_INSTALLED, stop: Wix Stores is not installed on the site. Wix recommends checking the version at the start of each flow.

4. Import the frame into your Media Manager

Section titled “4. Import the frame into your Media Manager”

Wix accepts an outside image address on a product, but its docs do not say that it keeps its own copy of an image added that way. Importing the frame into your site’s Media Manager first gives your store its own copy.

Terminal window
curl https://www.wixapis.com/site-media/v1/files/import \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID" \
-H "Content-Type: application/json" \
-d "{\"url\": \"$FRAME_URL\", \"mediaType\": \"IMAGE\", \"displayName\": \"Ribbed crew sweater, on model\"}"

Keep file.id from the answer:

Terminal window
WIX_FILE_ID="the file.id"

The file is not ready at once: its operationStatus starts as PENDING. Ask for it until it is READY, and stop if it is FAILED:

Terminal window
curl "https://www.wixapis.com/site-media/v1/files/get-file-by-id?fileId=$WIX_FILE_ID" \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID"

A ready file has its address on Wix in file.url. On Catalog V1 you need it:

Terminal window
WIX_FILE_URL="the file.url"

Every V3 product update carries the product’s current revision, and the media list you send replaces the product’s media. So first read the product with its media:

Terminal window
curl "https://www.wixapis.com/stores/v3/products/$WIX_PRODUCT_ID?fields=MEDIA_ITEMS_INFO" \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID"

Keep product.revision, and the id of each entry in product.media.itemsInfo.items, in order, with its altText when it has one:

Terminal window
WIX_REVISION="the product.revision"

Then send the entries back with the imported file added:

Terminal window
curl -X PATCH "https://www.wixapis.com/stores/v3/products/$WIX_PRODUCT_ID" \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID" \
-H "Content-Type: application/json" \
-d "{
\"product\": {
\"id\": \"$WIX_PRODUCT_ID\",
\"revision\": \"$WIX_REVISION\",
\"media\": {
\"itemsInfo\": {
\"items\": [
{\"id\": \"an existing item id\", \"altText\": \"its alt text\"},
{\"id\": \"$WIX_FILE_ID\", \"altText\": \"Ribbed crew sweater, worn by a model\"}
]
}
}
}
}"
  • Send altText only for an item that has one; Wix does not accept an empty altText.
  • The first item is the product’s main image. To make the frame the main image, put it first.
  • An item you leave out is removed from the product.
  • If the answer says the revision does not match, the product changed since you read it. Read it again and resend.

V1 adds media to a product without replacing what it has. Add the imported file by its Wix address, file.url from step 4:

Terminal window
curl https://www.wixapis.com/stores/v1/products/$WIX_PRODUCT_ID/media \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID" \
-H "Content-Type: application/json" \
-d "{\"media\": [{\"url\": \"$WIX_FILE_URL\"}]}"

When the product is updated, record the frame id as published.

If someone takes the frame’s approval down in Shootika, your Wix product keeps the image. Remove it in Wix.

On V3, send the product’s media without it, as in step 5.

On V1, Add Product Media answers with an empty object, so first read the product to find the image’s media id. It is the id of the matching entry in product.media.items:

Terminal window
curl https://www.wixapis.com/stores-reader/v1/products/$WIX_PRODUCT_ID \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID"

Then remove it with Remove Product Media:

Terminal window
curl https://www.wixapis.com/stores/v1/products/$WIX_PRODUCT_ID/media/delete \
-H "Authorization: $WIX_API_KEY" \
-H "wix-site-id: $WIX_SITE_ID" \
-H "Content-Type: application/json" \
-d '{"mediaIds": ["the media id"]}'