{
  "openapi": "3.0.1",
  "info": {
    "title": "Apify Dataset Replicator",
    "description": "Sync the results of your Apify Actors to PostgreSQL or S3-compatible storage - continuously, incrementally, and without ever starting from scratch. Give it a connection string and every new successful run lands in your database as clean rows, ready for your application, BI dashboard, or AI pipeline.",
    "version": "0.0",
    "x-build-id": "MwIk2NnFKSwQGhP3i"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/dtrungtin~apify-dataset-replicator/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-dtrungtin-apify-dataset-replicator",
        "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/dtrungtin~apify-dataset-replicator/runs": {
      "post": {
        "operationId": "runs-sync-dtrungtin-apify-dataset-replicator",
        "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/dtrungtin~apify-dataset-replicator/run-sync": {
      "post": {
        "operationId": "run-sync-dtrungtin-apify-dataset-replicator",
        "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": {
          "sourceType": {
            "title": "Source type",
            "enum": [
              "newRuns",
              "lastRun",
              "dataset"
            ],
            "type": "string",
            "description": "Where the data comes from. <b>New successful runs</b> watches an Actor and replicates every successful run exactly once. <b>Last successful run</b> replicates only the most recent one. <b>Specific dataset</b> replicates a single (possibly growing) dataset incrementally.",
            "default": "newRuns"
          },
          "actorId": {
            "title": "Actor",
            "type": "string",
            "description": "The Actor whose run results to replicate, e.g. <code>apify/google-maps-scraper</code>. Required for the Actor source types."
          },
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "ID or name of the dataset to replicate. Required when the source type is <b>Specific dataset</b>."
          },
          "destinationType": {
            "title": "Destination type",
            "enum": [
              "postgres",
              "s3"
            ],
            "type": "string",
            "description": "Where to replicate the data. PostgreSQL covers Supabase, Neon, Railway, Render, RDS, Cloud SQL and self-hosted servers. S3 covers AWS S3, Cloudflare R2, Backblaze B2, Wasabi, MinIO and other S3-compatible storage.",
            "default": "postgres"
          },
          "connectionString": {
            "title": "PostgreSQL connection string",
            "type": "string",
            "description": "Connection string in the form <code>postgresql://user:password@host:5432/database</code>. Stored encrypted."
          },
          "tableSchema": {
            "title": "PostgreSQL schema",
            "type": "string",
            "description": "Database schema of the destination table.",
            "default": "public"
          },
          "tableName": {
            "title": "Table name",
            "type": "string",
            "description": "The table to replicate into, e.g. <code>google_places</code>."
          },
          "createTable": {
            "title": "Automatically create table",
            "type": "boolean",
            "description": "Create the destination table (and the unique index required for upsert) if it does not exist yet.",
            "default": true
          },
          "s3Bucket": {
            "title": "S3 bucket",
            "type": "string",
            "description": "Name of the destination bucket."
          },
          "s3Prefix": {
            "title": "S3 key prefix",
            "type": "string",
            "description": "Folder prefix for replicated files, e.g. <code>apify</code>. Files are written as <code>{prefix}/{actor}/{date}/run-{runId}/part-000001.jsonl.gz</code> plus a <code>manifest.json</code>.",
            "default": "apify"
          },
          "s3Region": {
            "title": "S3 region",
            "type": "string",
            "description": "Region of the bucket (or any value accepted by the provider, e.g. <code>auto</code> for Cloudflare R2).",
            "default": "us-east-1"
          },
          "s3Endpoint": {
            "title": "S3 endpoint URL",
            "type": "string",
            "description": "Custom endpoint for S3-compatible providers, e.g. <code>https://&lt;account&gt;.r2.cloudflarestorage.com</code> or a MinIO URL. Leave empty for AWS S3."
          },
          "s3AccessKeyId": {
            "title": "S3 access key ID",
            "type": "string",
            "description": "Access key for the bucket. Stored encrypted."
          },
          "s3SecretAccessKey": {
            "title": "S3 secret access key",
            "type": "string",
            "description": "Secret key for the bucket. Stored encrypted."
          },
          "s3ForcePathStyle": {
            "title": "Use path-style S3 addressing",
            "type": "boolean",
            "description": "Required by MinIO and some other S3-compatible services. Defaults to on when a custom endpoint is set.",
            "default": false
          },
          "writeMode": {
            "title": "Write mode",
            "enum": [
              "upsert",
              "append",
              "ignoreDuplicates",
              "replace"
            ],
            "type": "string",
            "description": "<b>Upsert</b> inserts or updates by primary key (recommended — makes replication idempotent). <b>Append</b> always inserts. <b>Ignore duplicates</b> inserts only unseen keys. <b>Replace</b> truncates the table and reloads everything on every run.",
            "default": "upsert"
          },
          "primaryKey": {
            "title": "Primary key field(s)",
            "type": "array",
            "description": "Field(s) that uniquely identify a record, e.g. <code>url</code>, <code>placeId</code>, <code>asin</code>. Required for upsert and ignore-duplicates modes. Refers to field names after transformation (pick / mapping / flatten).",
            "items": {
              "type": "string"
            }
          },
          "schemaMode": {
            "title": "Table schema mode",
            "enum": [
              "json",
              "infer"
            ],
            "type": "string",
            "description": "<b>JSON</b> (safest) stores each item in a JSONB <code>data</code> column with Apify lineage columns — immune to schema changes. <b>Infer</b> converts item fields into typed SQL columns.",
            "default": "json"
          },
          "schemaEvolution": {
            "title": "Schema evolution",
            "enum": [
              "add-columns",
              "ignore",
              "fail"
            ],
            "type": "string",
            "description": "What to do when the source data grows new fields (infer mode only): add columns automatically, ignore the new fields, or fail the run.",
            "default": "add-columns"
          },
          "nestedObjects": {
            "title": "Nested objects & arrays",
            "enum": [
              "jsonb",
              "flatten",
              "stringify"
            ],
            "type": "string",
            "description": "<b>JSONB</b> keeps nested values as JSON. <b>Flatten</b> turns <code>seller.name</code> into a <code>seller_name</code> column. <b>Stringify</b> serializes nested values to JSON strings.",
            "default": "jsonb"
          },
          "batchSize": {
            "title": "Batch size",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Number of items read and written per batch. Larger batches are faster for big datasets.",
            "default": 1000
          },
          "maxItems": {
            "title": "Max items per run",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after replicating this many items in one run (0 = unlimited). The checkpoint resumes the rest on the next run — useful for testing and for capping run cost.",
            "default": 0
          },
          "rememberCheckpoint": {
            "title": "Remember sync position",
            "type": "boolean",
            "description": "Persist checkpoints and the processed-run registry across runs, so only new data is replicated and interrupted runs resume automatically. Disable to re-replicate everything on each run.",
            "default": true
          },
          "includeMetadata": {
            "title": "Include Apify metadata",
            "type": "boolean",
            "description": "Add an <code>_apify</code> field (Actor ID, run ID, dataset ID, item offset, replication time) to every record for lineage and debugging.",
            "default": true
          },
          "pickFields": {
            "title": "Fields to replicate",
            "type": "array",
            "description": "Replicate only these fields (dot paths supported, e.g. <code>seller.name</code> becomes <code>seller_name</code>). Leave empty to replicate all fields.",
            "items": {
              "type": "string"
            }
          },
          "fieldMapping": {
            "title": "Field mapping",
            "type": "object",
            "description": "Rename fields: an object of <code>{\"destination_field\": \"source.path\"}</code>, e.g. <code>{\"video_url\": \"url\", \"channel\": \"channel.name\"}</code>. When used without \"Fields to replicate\", only the mapped fields are replicated."
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}