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

Installation

Install the axios HTTP client library:
Or if you’re using Yarn:

Quick start

1

Import axios

Import the axios library at the top of your file.
2

Configure your request payload

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

Make the API request

Send a POST request to the API endpoint and handle the response.

Complete examples

Request parameters

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:
Access specific fields from the response:

Async/await pattern

Use async/await for cleaner, more readable code when working with promises.

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, implement a retry mechanism instead of relying solely on timeouts, as the cloro system retries automatically.

Error handling best practices

Implement robust error handling to manage different failure scenarios:

Promise vs async/await

You can use either promises or async/await depending on your preference:
Always verify the status field in the response is "success" before accessing the result data.

Next steps