# brightdata/chatgpt-scraper architecture

> Architecture diagram of the GitHub repository brightdata/chatgpt-scraper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brightdata/chatgpt-scraper
- Repository: https://github.com/brightdata/chatgpt-scraper

## Overview

This is a small Python client for Bright Data’s ChatGPT Scraper API. The main workflow accepts prompts and options, submits an asynchronous job, polls for completion, fetches answer rows, and returns them to a Python caller or writes them to JSON through the CLI. The API supports country, web search, citations, and follow-up prompts. The sampled source shows the HTTP and CLI paths; README statements support the documented result capabilities. Unsampled tests and peripheral files are omitted.

Main entry points: [`src/chatgpt_scraper/__main__.py`](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/__main__.py) (Bulk CLI), [`src/chatgpt_scraper/scrape.py`](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py) (HTTP transport), [`src/chatgpt_scraper/__init__.py`](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/__init__.py) (Python API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_public_api["Python API<br/>[__init__.py]"]
  node_cli["Bulk CLI<br/>[__main__.py]"]
  node_answer_rows["Answer rows"]
end

subgraph group_client["Scraper client"]
  node_prompt_builder["Prompt options<br/>[scrape.py]"]
  node_job_lifecycle["Job lifecycle<br/>[scrape.py]"]
  node_http_transport["HTTP transport<br/>[scrape.py]"]
  node_credentials["Credential lookup<br/>[scrape.py]"]
  node_outcome_handling["Outcome handling<br/>[scrape.py]"]
  node_json_output["JSON writer<br/>[scrape.py]"]
end

subgraph group_service["External service"]
  node_brightdata_api["Bright Data API"]
end

node_python_user(("Python caller"))
node_cli_user(("CLI user"))
node_json_file["JSON file"]

node_python_user -->|"calls"| node_public_api
node_cli_user -->|"runs"| node_cli
node_public_api -->|"exposes"| node_prompt_builder
node_cli -->|"asks prompts"| node_outcome_handling
node_cli -->|"checks token"| node_credentials
node_cli -->|"writes results"| node_json_output
node_prompt_builder -->|"submits inputs"| node_job_lifecycle
node_job_lifecycle -->|"sends requests"| node_http_transport
node_http_transport -->|"gets token"| node_credentials
node_http_transport -->|"calls endpoints"| node_brightdata_api
node_brightdata_api -->|"returns job data"| node_http_transport
node_job_lifecycle -->|"fetches rows"| node_answer_rows
node_prompt_builder -->|"normalizes results"| node_outcome_handling
node_outcome_handling -->|"returns outcomes"| node_answer_rows
node_json_output -->|"writes JSON"| node_json_file

click node_public_api "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/__init__.py"
click node_cli "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/__main__.py"
click node_prompt_builder "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py"
click node_job_lifecycle "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py"
click node_http_transport "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py"
click node_credentials "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py"
click node_outcome_handling "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py"
click node_json_output "https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_cli,node_answer_rows,node_cli_user toneBlue
class node_prompt_builder,node_job_lifecycle,node_http_transport,node_credentials,node_outcome_handling,node_json_output toneAmber
class node_brightdata_api toneMint
class node_python_user,node_json_file toneIndigo
```

## Components

### User interfaces

- [Python API](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/__init__.py): `src/chatgpt_scraper/__init__.py`
- [Bulk CLI](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/__main__.py): `src/chatgpt_scraper/__main__.py`
- **Answer rows**

### Scraper client

- [Prompt options](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py): `src/chatgpt_scraper/scrape.py`
- [Job lifecycle](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py): `src/chatgpt_scraper/scrape.py`
- [HTTP transport](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py): `src/chatgpt_scraper/scrape.py`
- [Credential lookup](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py): `src/chatgpt_scraper/scrape.py`
- [Outcome handling](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py): `src/chatgpt_scraper/scrape.py`
- [JSON writer](https://github.com/brightdata/chatgpt-scraper/blob/main/src/chatgpt_scraper/scrape.py): `src/chatgpt_scraper/scrape.py`

### External service

- **Bright Data API**

### Other components

- **Python caller**
- **CLI user**
- **JSON file**

## Connections

- Python caller → Python API: calls (evidence: `README.md`)
- CLI user → Bulk CLI: runs (evidence: `README.md`)
- Python API → Prompt options: exposes (evidence: `src/chatgpt_scraper/__init__.py`)
- Bulk CLI → Outcome handling: asks prompts (evidence: `src/chatgpt_scraper/__main__.py`)
- Bulk CLI → Credential lookup: checks token (evidence: `src/chatgpt_scraper/__main__.py`)
- Bulk CLI → JSON writer: writes results (evidence: `src/chatgpt_scraper/__main__.py`)
- Prompt options → Job lifecycle: submits inputs (evidence: `src/chatgpt_scraper/scrape.py`)
- Job lifecycle → HTTP transport: sends requests (evidence: `src/chatgpt_scraper/scrape.py`)
- HTTP transport → Credential lookup: gets token (evidence: `src/chatgpt_scraper/scrape.py`)
- HTTP transport → Bright Data API: calls endpoints (evidence: `src/chatgpt_scraper/scrape.py`)
- Bright Data API → HTTP transport: returns job data (evidence: `src/chatgpt_scraper/scrape.py`)
- Job lifecycle → Answer rows: fetches rows (evidence: `src/chatgpt_scraper/scrape.py`)
- Prompt options → Outcome handling: normalizes results (evidence: `src/chatgpt_scraper/scrape.py`)
- Outcome handling → Answer rows: returns outcomes (evidence: `README.md`)
- JSON writer → JSON file: writes JSON (evidence: `src/chatgpt_scraper/scrape.py`)
