# Shopify Product Image & Alt Text Inventory (`practical_ai_lab_jp/pal-shopify-product-image-inventory`) Actor

Audit image records and alt attributes from product exports before catalog migration. For Shopify media QA and accessibility teams. Check the live Pricing tab and input limits.

- **URL**: https://apify.com/practical_ai_lab_jp/pal-shopify-product-image-inventory.md
- **Developed by:** [Practical AI Lab](https://apify.com/practical_ai_lab_jp) (community)
- **Categories:** E-commerce, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 image records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Shopify Product Image & Alt Text Inventory

Export every product image from a store's **public** Shopify product feed, together with the product it belongs to, the variants it is linked to, its alt text, its reported size, and a list of quality flags. Use it to find missing images, missing or weak alt text, variants without their own picture, and images reused across products.

This Actor is built for catalog clean-up and migration prep. It is not a general product scraper: it does not export prices, descriptions or inventory, and it never downloads the image files.

### What you get

One dataset, several record types (field `recordType`):

| recordType | Meaning |
| --- | --- |
| `image` | One row per product image: product ID/handle/title/URL, image ID, position, image URL, filename, width, height, alt text, linked variant IDs/titles/SKUs, `associationScope` (`variant` or `product`), flags |
| `missing-image` | A product that has no image at all (`NO_IMAGES`) |
| `variant-gap` | A variant without its own image while other variants of the same product have one |
| `shop-summary` | Per-store counts, flag totals, pages read, truncation status and a sample caveat |
| `error` | A store that could not be read, with the reason |

#### Quality flags

| Flag | Rule |
| --- | --- |
| `MISSING_ALT` | Alt text is empty |
| `SHORT_ALT` | Alt text is shorter than `minAltTextLength` |
| `ALT_LOOKS_LIKE_FILENAME` | Alt ends with an image extension or equals the file name (size suffixes like `_800x` ignored) |
| `DUPLICATE_ALT_IN_PRODUCT` | Same alt text (case/punctuation-insensitive) on more than one image of a product |
| `DUPLICATE_IMAGE_IN_PRODUCT` | Same image file listed twice in one product (cache query strings ignored) |
| `SHARED_IMAGE_ACROSS_PRODUCTS` | Same image file used by several products in the sample |
| `MISSING_DIMENSIONS` | The feed gives no width or height |
| `LOW_RESOLUTION` | Shorter side reported by the feed is below `minImageDimension` |
| `INSECURE_URL` | Image URL is not HTTPS |
| `TOO_FEW_IMAGES` | Product has fewer than `minImagesPerProduct` images |
| `NO_IMAGES` | Product has no image |
| `VARIANT_WITHOUT_IMAGE` | See `variant-gap` above |

Flags are heuristics to build a work list, not verdicts. Your own accessibility or SEO guidelines decide what counts as a problem.

### Input

Copy-and-run example:

```json
{
    "shopUrls": ["https://www.allbirds.com"],
    "maxProductsPerShop": 50,
    "minImagesPerProduct": 3,
    "minImageDimension": 800,
    "minAltTextLength": 10,
    "includeProductsWithoutImages": true,
    "includeVariantGaps": true,
    "onlyFlagged": false,
    "requestDelayMs": 1000
}
```

Replace the store with one you are allowed to analyse. The example store is only a placeholder; whether its feed is enabled and permitted by its robots.txt can change at any time, in which case you get an `error` record instead of data.

Accepted addresses: a store domain (`https://example.com`) or a collection (`https://example.com/collections/sale`). Product pages, IP addresses, custom ports, credentials and non-HTTPS URLs are rejected.

### Example `image` record (illustrative, not a real result)

```json
{
    "recordType": "image",
    "shop": "shop.example.com",
    "productId": 1,
    "productTitle": "Tee",
    "imageId": 11,
    "position": 1,
    "imageUrl": "https://cdn.shopify.com/s/files/img11.jpg",
    "imageWidth": 1200,
    "imageHeight": 1200,
    "altText": "",
    "associationScope": "variant",
    "variantIds": [101],
    "variantTitles": ["Red"],
    "variantSkus": ["R1"],
    "flags": ["MISSING_ALT"]
}
```

### Limitations and sample-size caveats

- **Default is a sample.** `maxProductsPerShop` defaults to 50 and products come in the feed's own order, which is not random. Percentages from a sample must not be generalised to the whole catalog. The summary says when more products were available (`truncatedByProductLimit`). The hard maximum is 5,000 products per store.
- **Only stores with an enabled, robots-permitted `/products.json` feed** can be read. Password-protected stores, stores that disabled the feed, or stores that block the request return an `error` record. No proxies or workarounds are used.
- **Feed data, not the rendered page.** Alt text, image order and variant links come from the feed. A theme may render different alt text or hide images, and some stores assign images to variants in ways the feed does not expose.
- **Variant gaps** are reported only when at least one variant has its own image. If no variant is linked to any image, all variants share the product gallery and no gap is reported.
- **Resolution** is the width/height the feed reports. Images are not downloaded, so blur, watermarks, wrong crops or duplicate pictures with different file names are not detected.
- **Shared/duplicate image checks** only compare products inside the same run and sample.
- Collection feeds list the products of that collection only.
- DNS is checked before every request, but a host that changes its DNS answer between the check and the connection cannot be fully excluded.
- robots.txt is evaluated with a built-in parser (user-agent groups, `Allow`/`Disallow`, `*` and `$`); unusual files may be interpreted differently by other tools. A robots.txt that cannot be read (other than 404/410) skips the store.
- Requests are sequential, one at a time, with a configurable delay (500 ms minimum), at most 21 feed pages per store and no retries. A 429 response stops that store.
- Public product data may still be subject to a store's terms and to copyright of the images themselves. This Actor lists image URLs; it does not grant any right to reuse the images.

### Billing note

The code tags each `image`, `missing-image` and `variant-gap` row with the pay-per-event name `image-record`. **No payable plan or price is configured in this project.** `shop-summary` and `error` records carry no event, and a store is analysed only after it was read completely, so a store that fails is never charged for rows. Pricing must be decided and configured separately after cost checks.

### Project layout

- `src/urlsafety.py` – URL validation, public-IP check, same-host redirects
- `src/robots.py` – robots.txt policy
- `src/feed.py` – bounded HTTP reader and pagination
- `src/analysis.py` – compaction, association and flag logic
- `src/pipeline.py` – one-store fetch without Apify dependencies
- `src/main.py` – Apify entrypoint
- `tests/` – offline unit tests (fake transport and DNS, no network)

Run the offline tests from the project folder with `python -m unittest discover -s tests -t .`.

# Actor input Schema

## `shopUrls` (type: `array`):

One to 20 store addresses (HTTPS only), for example https://www.allbirds.com. You may also pass a collection address such as https://example.com/collections/sale. Only stores whose public /products.json feed is enabled and allowed by robots.txt can be processed.

## `maxProductsPerShop` (type: `integer`):

Upper bound of products read from each store, in the order the feed returns them. The default is a small sample, not a full audit.

## `minImagesPerProduct` (type: `integer`):

Products with fewer images get the TOO_FEW_IMAGES flag. Use 0 to disable this check.

## `minImageDimension` (type: `integer`):

Images whose shorter side, as reported by the feed, is below this value get LOW_RESOLUTION. Use 0 to disable. Images are never downloaded.

## `minAltTextLength` (type: `integer`):

Non-empty alt text shorter than this gets SHORT_ALT. Use 0 to disable.

## `includeProductsWithoutImages` (type: `boolean`):

Emit one missing-image record for each product that has no image at all.

## `includeVariantGaps` (type: `boolean`):

Emit a variant-gap record for variants without their own image when other variants of the same product have one.

## `onlyFlagged` (type: `boolean`):

Output only records that carry at least one quality flag. Store summaries are always output.

## `requestDelayMs` (type: `integer`):

Pause between HTTP requests to the stores. Sequential requests only.

## Actor input object example

```json
{
  "shopUrls": [
    "https://www.allbirds.com"
  ],
  "maxProductsPerShop": 50,
  "minImagesPerProduct": 3,
  "minImageDimension": 800,
  "minAltTextLength": 10,
  "includeProductsWithoutImages": true,
  "includeVariantGaps": true,
  "onlyFlagged": false,
  "requestDelayMs": 1000
}
```

# Actor output Schema

## `results` (type: `string`):

Download rows from the latest run in JSON/CSV.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "shopUrls": [
        "https://www.allbirds.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-shopify-product-image-inventory").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "shopUrls": ["https://www.allbirds.com"] }

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-shopify-product-image-inventory").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "shopUrls": [
    "https://www.allbirds.com"
  ]
}' |
apify call practical_ai_lab_jp/pal-shopify-product-image-inventory --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,practical_ai_lab_jp/pal-shopify-product-image-inventory"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/HaaLvsGEMaArAaTLJ/builds/KFndE6irqvbQAWAXk/openapi.json
