{
  "openapi": "3.1.0",
  "info": {
    "title": "SameAPI",
    "version": "1.0.0",
    "description": "Website traffic and AI traffic data for any domain: estimated monthly visits, traffic sources, rank,\ntop countries and the AI assistants that send visits (ChatGPT, Gemini, Claude, Perplexity, Copilot, Grok).\nLook up one domain, or run a job for a list of domains and read the results while it runs.\n\nAuthentication: send your API key in the `X-API-Key` header. API access starts with the Pro plan\n(https://sameapi.io/pricing). Full guide with examples: https://sameapi.io/docs",
    "contact": {
      "name": "SameAPI support",
      "email": "support@sameapi.io",
      "url": "https://sameapi.io/contact"
    },
    "termsOfService": "https://sameapi.io/terms"
  },
  "externalDocs": {
    "description": "SameAPI API documentation",
    "url": "https://sameapi.io/docs"
  },
  "servers": [
    {
      "url": "https://sameapi.io"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/api/v1/jobs": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Create Job",
        "description": "Create new job (Unified for API & Dashboard)",
        "operationId": "create_job_api_v1_jobs_post",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}/domains": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Upload Job Domains",
        "description": "Chunked upload of domains for a Draft Job.\nMax 10,000 domains per request.\n\nPlain `def` on purpose (BUG-95): the work is synchronous database work and takes seconds\nfor a big chunk; FastAPI runs it in a worker thread so the process stays free for other calls.",
        "operationId": "upload_job_domains_api_v1_jobs__job_id__domains_post",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobChunkUpload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}/finalize": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Finalize Job",
        "description": "Finalize a draft job and start processing.",
        "operationId": "finalize_job_api_v1_jobs__job_id__finalize_post",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "Get Job",
        "description": "Get specific job",
        "operationId": "get_job_api_v1_jobs__job_id__get",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}/resume": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Resume Job",
        "description": "Explicit Resume Endpoint",
        "operationId": "resume_job_api_v1_jobs__job_id__resume_post",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}/pause": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Pause Job",
        "operationId": "pause_job_api_v1_jobs__job_id__pause_post",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}/cancel": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Cancel Job",
        "operationId": "cancel_job_api_v1_jobs__job_id__cancel_post",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}/retry-failed": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Retry Failed Job",
        "operationId": "retry_failed_job_api_v1_jobs__job_id__retry_failed_post",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}/results": {
      "get": {
        "tags": [
          "jobs"
        ],
        "summary": "Get Job Results",
        "description": "Get job results with TRUE STREAMING (no buffering)",
        "operationId": "get_job_results_api_v1_jobs__job_id__results_get",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Job Id"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ],
              "description": "Page number (starts from 1)",
              "title": "Page"
            },
            "description": "Page number (starts from 1)"
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 1000,
              "minimum": 1,
              "description": "Items per page (max 1000)",
              "default": 100,
              "title": "Per Page"
            },
            "description": "Items per page (max 1000)"
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Skip"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 10000,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "success_only",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Success Only"
            }
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Filters"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^(json|csv)$",
              "default": "json",
              "title": "Format"
            }
          },
          {
            "name": "view",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^(full|table)$",
              "description": "'table' omits reference data not needed to render a results table (the static 'Countries' list, ~90% of each result). Default 'full' is unchanged.",
              "default": "full",
              "title": "View"
            },
            "description": "'table' omits reference data not needed to render a results table (the static 'Countries' list, ~90% of each result). Default 'full' is unchanged."
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "description": "Optional column key: results sorted by it over the whole job (dashboard jobs, JSON, no filters). Without it the answer is unchanged.",
              "title": "Sort"
            },
            "description": "Optional column key: results sorted by it over the whole job (dashboard jobs, JSON, no filters). Without it the answer is unchanged."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 4,
              "description": "'asc' or 'desc' (default), used with 'sort'",
              "default": "desc",
              "title": "Order"
            },
            "description": "'asc' or 'desc' (default), used with 'sort'"
          },
          {
            "name": "paged",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "Dashboard table: one page (skip/limit) in the job's order, read from the prepared values, plus 'columns'. Without it (and without 'sort') the answer is unchanged.",
              "default": false,
              "title": "Paged"
            },
            "description": "Dashboard table: one page (skip/limit) in the job's order, read from the prepared values, plus 'columns'. Without it (and without 'sort') the answer is unchanged."
          },
          {
            "name": "failed_only",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "With 'sort' or 'paged': only the failed domains",
              "default": false,
              "title": "Failed Only"
            },
            "description": "With 'sort' or 'paged': only the failed domains"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Job Results Api V1 Jobs  Job Id  Results Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/lookup/{domain}": {
      "get": {
        "tags": [
          "lookup"
        ],
        "summary": "Lookup Single Domain",
        "description": "Get metrics for a single domain.\nAlways returns a Job object (Async-First approach).",
        "operationId": "lookup_single_domain_api_v1_lookup__domain__get",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Domain"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Lookup Single Domain Api V1 Lookup  Domain  Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/lookup/batch": {
      "post": {
        "tags": [
          "lookup"
        ],
        "summary": "Create Batch Lookup",
        "description": "Batch lookup domains. Creates a job.\nAlias for POST /jobs but with simplified payload.",
        "operationId": "create_batch_lookup_api_v1_lookup_batch_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Body_create_batch_lookup_api_v1_lookup_batch_post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Batch Lookup Api V1 Lookup Batch Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/usage": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "Get Usage Stats",
        "description": "Return current plan, quota usage, and rate limits.",
        "operationId": "get_usage_stats_api_v1_usage_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Usage Stats Api V1 Usage Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Body_create_batch_lookup_api_v1_lookup_batch_post": {
        "properties": {
          "domains": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Domains"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "webhook_secret": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Secret"
          }
        },
        "type": "object",
        "required": [
          "domains"
        ],
        "title": "Body_create_batch_lookup_api_v1_lookup_batch_post"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "JobChunkUpload": {
        "properties": {
          "domains": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Domains"
          }
        },
        "type": "object",
        "required": [
          "domains"
        ],
        "title": "JobChunkUpload"
      },
      "JobCreate": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name"
          },
          "domains": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Domains"
          },
          "column_preferences": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ],
            "title": "Column Preferences"
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "webhook_secret": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Secret"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "JobCreate"
      },
      "JobResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "user_id": {
            "type": "string",
            "title": "User Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "total_domains": {
            "type": "integer",
            "title": "Total Domains"
          },
          "processed_domains": {
            "type": "integer",
            "title": "Processed Domains"
          },
          "successful_domains": {
            "type": "integer",
            "title": "Successful Domains"
          },
          "failed_domains": {
            "type": "integer",
            "title": "Failed Domains"
          },
          "dropped_domain_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Dropped Domain Count",
            "default": 0
          },
          "warning_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Warning Message"
          },
          "column_preferences": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ],
            "title": "Column Preferences"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source",
            "default": "dashboard"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "user": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UserSummary"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "id",
          "user_id",
          "name",
          "status",
          "total_domains",
          "processed_domains",
          "successful_domains",
          "failed_domains",
          "created_at",
          "updated_at"
        ],
        "title": "JobResponse"
      },
      "UserSummary": {
        "properties": {
          "email": {
            "type": "string",
            "title": "Email"
          }
        },
        "type": "object",
        "required": [
          "email"
        ],
        "title": "UserSummary"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  }
}
