{
  "openapi": "3.0.1",
  "info": {
    "title": "Image Compressor API - Batch JPG, PNG, WebP to Target Size",
    "description": "Most image compressors bill every image they touch, even when the file did not get smaller. This one charges only when the delivered image really shrank: if nothing was saved you get the original back free, with the reason on the row.",
    "version": "0.1",
    "x-build-id": "hfCGeUyhpnkaFj6mV"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/stas_k~image-compressor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-stas_k-image-compressor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/stas_k~image-compressor/runs": {
      "post": {
        "operationId": "runs-sync-stas_k-image-compressor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/stas_k~image-compressor/run-sync": {
      "post": {
        "operationId": "run-sync-stas_k-image-compressor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "imageUrls": {
            "title": "Image urls",
            "type": "array",
            "description": "One http(s) url per line. Each url is read once: a repeat, a line that is not a url and a line beyond maxImages come back as their own free row with the reason. The file signature decides whether the bytes are an image, never the file name or the content type.",
            "items": {
              "type": "string"
            }
          },
          "targetKB": {
            "title": "Target size in KB (0 = no target)",
            "minimum": 0,
            "maximum": 25600,
            "type": "integer",
            "description": "The weight every delivered image should fit under. The encoder lowers quality until the file fits, and only then scales the picture down, because a sharp photo beats a blurry one. 0 means no target: the image is re-encoded at your quality and nothing else. The row says whether the target was reached, and an image that cannot be squeezed under it is delivered at the smallest size found, priced the same.",
            "default": 0
          },
          "quality": {
            "title": "Quality",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Encoder quality for JPEG, WebP and AVIF, and the ceiling of the search when targetKB is set: the search never goes above this number. 80 is the point where a photo stops looking different at half the size; below 60 artefacts show on gradients. PNG is lossless and ignores it.",
            "default": 80
          },
          "format": {
            "title": "Output format",
            "enum": [
              "keep",
              "webp",
              "jpeg",
              "png",
              "avif"
            ],
            "type": "string",
            "description": "Keep means the format stays the one the bytes already have, so a compressor does not quietly convert your png into a jpeg. A source format this actor cannot write back (gif, heic, tiff, bmp) is delivered as jpeg, and the row names the source format it came from. Naming a format asks for a conversion.",
            "default": "keep"
          },
          "maxWidth": {
            "title": "Max width in pixels (0 = keep)",
            "minimum": 0,
            "type": "integer",
            "description": "A wider image is scaled down to this width and never upscaled. 0 keeps every pixel: this actor sells weight, not dimensions, and it does not resize unless you ask.",
            "default": 0
          },
          "maxHeight": {
            "title": "Max height in pixels (0 = keep)",
            "minimum": 0,
            "type": "integer",
            "description": "The same limit for the height. 0 keeps every pixel.",
            "default": 0
          },
          "stripMetadata": {
            "title": "Strip metadata",
            "type": "boolean",
            "description": "Drops EXIF, GPS, camera and software tags from the delivered file, which is usually a few kilobytes of the weight and all of the privacy. The orientation itself is applied to the pixels first, so a phone photo stays upright. Turn it off only when the metadata is the point.",
            "default": true
          },
          "background": {
            "title": "Background for transparency",
            "type": "string",
            "description": "The colour an image with transparency is flattened onto when the delivered format has no alpha channel, which is JPEG. A hex colour like #FFFFFF or #000000.",
            "default": "#FFFFFF"
          },
          "maxImages": {
            "title": "Max images",
            "minimum": 0,
            "type": "integer",
            "description": "The list is cut here and the rest comes back free with status NOT_CHECKED_LIMIT. 0 means the default of 20, and the summary reports the number actually applied.",
            "default": 20
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}