Skip to main content
This guide shows you how to use the ChatGPT Scraper API with Python to programmatically collect AI-generated responses and structured metadata.

Installation

Before you begin, install the requests library if you haven’t already:

Quick start

1

Import required libraries

You’ll need the requests library for making HTTP requests and json for handling the response data.
2

Configure your API request

Set up your payload with the prompt and optional parameters. Replace YOUR_API_KEY with your actual API key from the cloro dashboard.
3

Handle the response

Process the API response by printing it to stdout or saving it to a file.

Complete example

Request parameters

You can customize your API request using these parameters:
The prompt parameter is mandatory. All other parameters are optional.

Handling the response

The API returns a JSON object with the following structure:
You can access specific fields like this:

Saving responses to files

To save the ChatGPT response to a JSON file:

Timeout configuration

Set an appropriate timeout (120-180 seconds) when making requests, as ChatGPT responses may take time to generate depending on complexity.
For production use, consider implementing a retry mechanism instead of relying solely on timeouts, as the cloro system retries automatically.

Error handling best practices

Implement comprehensive error handling to manage different failure scenarios:
Always check the status field in the response to verify successful execution before accessing the result data.

Next steps