{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Analytics 4 Exporter: GA4 Reports to CSV, Excel & JSON",
    "description": "Export Google Analytics 4 reports from your own GA4 properties with Google's official Data API: traffic, channels, landing pages, pages, events, ecommerce, realtime or any custom report. Many properties per run, period comparisons, flat rows. $0.50 per 1,000 rows plus a small start fee.",
    "version": "1.0",
    "x-build-id": "GBM6kOzjm40bLXSk2"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/aaronoptimus~google-analytics-4-exporter/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-aaronoptimus-google-analytics-4-exporter",
        "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/aaronoptimus~google-analytics-4-exporter/runs": {
      "post": {
        "operationId": "runs-sync-aaronoptimus-google-analytics-4-exporter",
        "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/aaronoptimus~google-analytics-4-exporter/run-sync": {
      "post": {
        "operationId": "run-sync-aaronoptimus-google-analytics-4-exporter",
        "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": {
          "serviceAccountKey": {
            "title": "Service account key (JSON)",
            "type": "string",
            "description": "Paste the whole .json key file of a Google Cloud service account (Google Cloud → IAM & Admin → Service accounts → Keys → Add key → JSON). Then add the service account e-mail as Viewer in Google Analytics (Admin → Property access management). The key is stored encrypted, used only to sign in to Google, and never logged or saved in the results. Step-by-step guide in the README."
          },
          "propertyIds": {
            "title": "GA4 property IDs",
            "type": "array",
            "description": "Numeric GA4 property IDs, one per line (Admin → Property details, e.g. 123456789), or Google Analytics URLs containing p123456789. Leave empty to export every property the service account can read (needs the Google Analytics Admin API turned on).",
            "items": {
              "type": "string"
            }
          },
          "reports": {
            "title": "Ready-made reports",
            "type": "array",
            "description": "Pick one or more. Each report gives one row per value (day, channel, page, …) with the main GA4 metrics as columns. Leave empty to run only your custom report.",
            "items": {
              "type": "string",
              "enum": [
                "trafficOverview",
                "channels",
                "sourceMedium",
                "campaigns",
                "landingPages",
                "pages",
                "events",
                "keyEvents",
                "devices",
                "countries",
                "cities",
                "newVsReturning",
                "ecommerceItems",
                "ecommerceOverview",
                "realtime"
              ],
              "enumTitles": [
                "Traffic overview by day",
                "Traffic by channel (Organic Search, Paid, Social, …)",
                "Traffic by source / medium",
                "Campaigns (UTM)",
                "Landing pages",
                "Pages and screens",
                "Events",
                "Key events (conversions) by channel",
                "Devices, operating systems and browsers",
                "Countries",
                "Cities",
                "New vs returning users",
                "Ecommerce: products",
                "Ecommerce: revenue by day",
                "Realtime: last 30 minutes"
              ]
            },
            "default": [
              "trafficOverview",
              "channels",
              "landingPages"
            ]
          },
          "dateRange": {
            "title": "Date range",
            "enum": [
              "last7Days",
              "last28Days",
              "last30Days",
              "last90Days",
              "last12Months",
              "thisMonth",
              "lastMonth",
              "thisYear",
              "lastYear",
              "yesterday",
              "today",
              "custom"
            ],
            "type": "string",
            "description": "Days are counted in each property's own time zone. \"Last N days\" end yesterday (today's data is still being processed by Google). Pick \"Custom\" to use the start and end date below.",
            "default": "last28Days"
          },
          "startDate": {
            "title": "Start date (custom range)",
            "type": "string",
            "description": "YYYY-MM-DD, or relative: today, yesterday, 30daysAgo. Used when the date range is \"Custom\"."
          },
          "endDate": {
            "title": "End date (custom range)",
            "type": "string",
            "description": "YYYY-MM-DD, or relative: today, yesterday, 7daysAgo. Used when the date range is \"Custom\"."
          },
          "comparison": {
            "title": "Compare with",
            "enum": [
              "none",
              "previousPeriod",
              "previousYear"
            ],
            "type": "string",
            "description": "Adds <metric>Previous and <metric>ChangePct (percent change) columns to every row. Daily, weekly and monthly rows are paired by position (day 1 with day 1, and so on).",
            "default": "none"
          },
          "splitBy": {
            "title": "Split each report by",
            "enum": [
              "none",
              "day",
              "week",
              "month"
            ],
            "type": "string",
            "description": "Adds a time column to the ready-made reports, e.g. channels per day. Multiplies the number of rows (and the cost) by the number of days, weeks or months.",
            "default": "none"
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "Optional, one per line, applied to every report (all must match). Examples: country==United States, country==Germany|France, pagePath=@/blog (contains), pagePath=^/shop (starts with), sessionSource=~goo.* (regex), sessionDefaultChannelGroup!=Direct, sessions>100. Text matching ignores upper/lower case.",
            "items": {
              "type": "string"
            }
          },
          "metrics": {
            "title": "Custom report: metrics",
            "type": "array",
            "description": "GA4 metric API names, up to 10, e.g. sessions, activeUsers, screenPageViews, keyEvents, totalRevenue, or your custom metrics. Full list: developers.google.com/analytics/devguides/reporting/data/v1/api-schema",
            "items": {
              "type": "string"
            }
          },
          "dimensions": {
            "title": "Custom report: dimensions",
            "type": "array",
            "description": "GA4 dimension API names, up to 9, e.g. date, sessionSource, pagePath, country, deviceCategory, customEvent:your_parameter.",
            "items": {
              "type": "string"
            }
          },
          "orderBy": {
            "title": "Custom report: sort by",
            "type": "string",
            "description": "A metric or dimension of the custom report; put a minus in front for descending, e.g. -sessions. Default: by date if the report has one, else by the first metric, largest first."
          },
          "customReports": {
            "title": "More custom reports (JSON)",
            "type": "array",
            "description": "For several custom reports in one run: a list like [{\"name\": \"blog\", \"dimensions\": [\"pagePath\"], \"metrics\": [\"screenPageViews\"], \"filters\": [\"pagePath=^/blog\"], \"orderBy\": \"-screenPageViews\", \"limit\": 500}]. Add \"realtime\": true for a realtime report (last 30 minutes)."
          },
          "maxRowsPerReport": {
            "title": "Max rows per report",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Upper limit per report and property (top rows by the report's sort order). Up to 100,000 (50,000 with a comparison). Each row is one charged result.",
            "default": 10000
          },
          "keepEmptyRows": {
            "title": "Keep rows where every metric is 0",
            "type": "boolean",
            "description": "GA4 leaves out rows with only zeros by default (e.g. days without visits). Turn on for a complete daily series.",
            "default": false
          },
          "currencyCode": {
            "title": "Currency",
            "type": "string",
            "description": "Optional 3-letter code (e.g. USD, EUR) to convert revenue metrics. Default: each property's own currency (shown in the currency column)."
          },
          "maxConcurrency": {
            "title": "Reports in parallel",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "How many reports run at the same time. Google allows 10 concurrent requests per property; 3 is gentle on your quota.",
            "default": 3
          },
          "oauthClientId": {
            "title": "OAuth client ID (instead of a service account)",
            "type": "string",
            "description": "Only if your organisation blocks service account keys: an OAuth client ID with a refresh token that has the analytics.readonly scope. Leave empty when you use a service account key."
          },
          "oauthClientSecret": {
            "title": "OAuth client secret",
            "type": "string",
            "description": "The client secret of the OAuth client above."
          },
          "oauthRefreshToken": {
            "title": "OAuth refresh token",
            "type": "string",
            "description": "A refresh token for the scope https://www.googleapis.com/auth/analytics.readonly (for example from Google's OAuth Playground with your own client)."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}