# Making Requests

### Base URL

All API requests should be made to:

```
https://dashboard.plainproxies.com/api/user
```

### Request Format

#### Headers

Every request must include:

| Header         | Required     | Description                                                                                 |
| -------------- | ------------ | ------------------------------------------------------------------------------------------- |
| `X-API-KEY`    | Yes          | Your API key from [Dashboard Settings](https://dashboard.plainproxies.com/account/api-keys) |
| `Content-Type` | For POST/PUT | `application/json`                                                                          |
| `Accept`       | Recommended  | `application/json`                                                                          |

#### Example Request

```bash
curl -X GET "https://dashboard.plainproxies.com/api/user/profile" \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Accept: application/json"
```

### Response Format

All responses return JSON with a consistent structure.

#### Success Response

```json
{
  "success": true,
  "data": {
    // Response data here
  },
  "message": "Optional success message"
}
```

#### Success Response with Pagination

```json
{
  "success": true,
  "data": [
    // Array of items
  ],
  "meta": {
    "current_page": 1,
    "last_page": 5,
    "per_page": 15,
    "total": 75,
    "from": 1,
    "to": 15
  }
}
```

#### Error Response

```json
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message",
    "details": {
      // Additional error context (optional)
    }
  }
}
```

### HTTP Methods

| Method | Usage              |
| ------ | ------------------ |
| `GET`  | Retrieve resources |
| `POST` | Generate proxies   |

### Pagination

List endpoints support pagination with these parameters:

| Parameter  | Default | Description              |
| ---------- | ------- | ------------------------ |
| `page`     | 1       | Page number              |
| `per_page` | 15      | Items per page (max 100) |

Example:

```
GET /plans?page=2&per_page=25
```

### Filtering

Many endpoints support filtering:

```
GET /plans?filter[type]=residential&filter[status]=active
```

### Sorting

Use the `sort` parameter with optional `-` prefix for descending:

```bash
# Sort by created_at ascending
GET /plans?sort=created_at

# Sort by created_at descending
GET /plans?sort=-created_at
```

### Including Related Data

Use the `include` parameter to embed related resources:

```
GET /plans?include=subscription
```

Available includes vary by endpoint — check the API reference for each resource.

### Code Examples

#### Python

```python
import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://dashboard.plainproxies.com/api/user"

headers = {
    "X-API-KEY": API_KEY,
    "Accept": "application/json"
}

# Get current user
response = requests.get(f"{BASE_URL}/auth/me", headers=headers)
print(response.json())

# Get your plans
response = requests.get(f"{BASE_URL}/plans", headers=headers)
plans = response.json()
for plan in plans["data"]:
    print(f"{plan['product_name']} - expires {plan['expires_at']}")

# Generate proxies
data = {
    "format": "{ip}:{port}:{user}:{pass}",
    "country": "US",
    "quantity": 10
}
response = requests.post(f"{BASE_URL}/proxies/generate", headers=headers, json=data)
print(response.json())
```

#### JavaScript (Node.js)

```javascript
const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://dashboard.plainproxies.com/api/user";

// Get current user
const response = await fetch(`${BASE_URL}/auth/me`, {
  headers: {
    "X-API-KEY": API_KEY,
  },
});
const data = await response.json();
console.log(data);

// Get your plans
const plansResponse = await fetch(`${BASE_URL}/plans`, {
  headers: {
    "X-API-KEY": API_KEY,
  },
});
const plans = await plansResponse.json();
plans.data.forEach(plan => {
  console.log(`${plan.product_name} - expires ${plan.expires_at}`);
});

// Generate proxies
const proxyResponse = await fetch(`${BASE_URL}/proxies/generate`, {
  method: "POST",
  headers: {
    "X-API-KEY": API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    format: "{ip}:{port}:{user}:{pass}",
    country: "US",
    quantity: 10,
  }),
});
const proxyData = await proxyResponse.json();
console.log(proxyData);
```

#### PHP

```php
<?php
$apiKey = "YOUR_API_KEY";
$baseUrl = "https://dashboard.plainproxies.com/api/user";

// Get current user
$ch = curl_init("$baseUrl/auth/me");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "X-API-KEY: $apiKey",
    "Accept: application/json",
]);
$response = curl_exec($ch);
curl_close($ch);

print_r(json_decode($response, true));
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.plainproxies.com/getting-started/making-requests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
