> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wetrocloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Endpoints

> Explore the available WetroCloud API endpoints for data extraction and AI-powered operations.

### Endpoints

| Endpoint           | Method | Description                                                                                    |
| :----------------- | :----- | :--------------------------------------------------------------------------------------------- |
| **`/v1/extract/`** | POST   | Extract structured data from any website using AI-powered extraction with custom JSON schemas. |

## Data Extraction Endpoint

### POST `/v1/extract/`

Extract specific information from any web page and receive it in a structured JSON format that matches your requirements.

**Request Parameters:**

| Parameter     | Type    | Required | Description                                                                            |
| ------------- | ------- | -------- | -------------------------------------------------------------------------------------- |
| `link`        | String  | Yes      | The URL of the website to extract data from                                            |
| `prompt`      | String  | Yes      | Instructions describing what data to extract                                           |
| `json_schema` | Array   | No       | The structure defining your desired output format. If not provided, returns plain text |
| `delay`       | Integer | No       | Delay in seconds before extraction (useful for dynamic content). Default: 0            |

**Example Request:**

<CodeGroup>
  ```python Python theme={null}
  import requests
  import json

  url = "https://api.wetrocloud.com/v1/extract/"

  headers = {
      "Content-Type": "application/json",
      "Authorization": "Token <api_key>"
  }

  payload = {
      "link": "https://theweek.com/news/people/954994/billionaires-richest-person-in-the-world",
      "prompt": "Extract the names and networth of Billionares in the article",
      "json_schema": [
          {"name": "string"},
          {"networth": "number"}
      ],
      "delay": 2
  }

  response = requests.post(url, headers=headers, data=json.dumps(payload))
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.wetrocloud.com/v1/extract/";

  const headers = {
    "Content-Type": "application/json",
    "Authorization": "Token <api_key>"
  };

  const payload = {
    link: "https://theweek.com/news/people/954994/billionaires-richest-person-in-the-world",
    prompt: "Extract the names and networth of Billionares in the article",
    json_schema: [
      { name: "string" },
      { networth: "number" }
    ],
    delay: 2
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error("Error:", error));
  ```

  ```bash cURL theme={null}
  curl --location 'https://api.wetrocloud.com/v1/extract/' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Token <api_key>' \
    --data '{
      "link": "https://theweek.com/news/people/954994/billionaires-richest-person-in-the-world",
      "prompt": "Extract the names and networth of Billionares in the article",
      "json_schema": [
        {"name": "string"},
        {"networth": "number"}
      ],
      "delay": 2
    }'
  ```
</CodeGroup>

**Response Format (Structured Output):**

```json theme={null}
{
  "response": [
    {
      "name": "Elon Musk",
      "networth": "$462 billion"
    },
    {
      "name": "Larry Ellison",
      "networth": "$340 billion"
    }
    // ... more results
  ],
  "success": true
}
```

**Response Format (Plain Text - when json\_schema is omitted):**

```json theme={null}
{
  "response": "Here are the names and net worths of the billionaires listed in the article:\n\n1. **Elon Musk:** $462 billion\n2. **Larry Ellison:** $340 billion...",
  "success": true
}
```

| Field      | Type            | Description                                                                                   |
| ---------- | --------------- | --------------------------------------------------------------------------------------------- |
| `response` | Array or String | Extracted data matching your JSON schema (array) or plain text (string) if no schema provided |
| `success`  | Boolean         | Indicates whether the extraction was successful                                               |

**Status Codes:**

* `200 OK` - Request successful
* `400 Bad Request` - Invalid parameters or malformed JSON schema
* `401 Unauthorized` - Invalid or missing API key
* `404 Not Found` - URL not accessible

**Error Response:**

```json theme={null}
{
  "error": "Error message describing what went wrong",
  "success": false
}
```
