Документация API

REST API v1, совместимый с DHRU.

Требуется вход

Войдите, чтобы увидеть данные API и управлять API ключом.

Настройки подключения DHRU

API URL:

https://3gsm.ru/api/v1

Method:

POST

Format:

JSON / DHRU Standard

To connect from another DHRU panel: use the API URL above, your username, and your API access key. Supports standard, PHP array parameters[FIELD], and XML string formats. Some panels append /api/index.php automatically — that path is supported. Classic alternative API URL: https://3gsm.ru (without /api/v1). Sync services via imeiservicelist — it returns IMEI and SERVER together (like classic panels).

API Endpoints

Get your account balance and information.

Request Example

curl -X POST https://3gsm.ru/api/v1 \
  -d "username=YOUR_USERNAME" \
  -d "apiaccesskey=YOUR_API_KEY" \
  -d "action=accountinfo"

Response Example

{
  "SUCCESS": [{
    "message": "Your Account Info",
    "AccountInfo": {
      "credit": "$25.50 USD",
      "creditraw": "25.50",
      "mail": "user@example.com",
      "currency": "USD",
      "scripttype": "dhru_fusion"
    }
  }],
  "apiversion": "8.1"
}

Error Response Format

{
  "ERROR": [
    { "MESSAGE": "Authentication failed. Check username and API access key." }
  ],
  "apiversion": "8.1"
}

Order Status Codes

Returned as strings in STATUS (e.g. "4"). Same mapping as classic DHRU Fusion.

0
Pending
1
Processing
3
Rejected
4
Completed

PHP Integration Example

<?php
class DhruApi {
    private $url;
    private $username;
    private $apiKey;
    
    public function __construct($url, $username, $apiKey) {
        $this->url = $url;
        $this->username = $username;
        $this->apiKey = $apiKey;
    }
    
    private function request($action, $params = []) {
        $data = array_merge([
            'username' => $this->username,
            'apiaccesskey' => $this->apiKey,
            'action' => $action,
        ], $params);
        
        $ch = curl_init($this->url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $response = curl_exec($ch);
        curl_close($ch);
        
        return json_decode($response, true);
    }
    
    public function getBalance() {
        return $this->request('accountinfo');
    }
    
    public function getServices() {
        return $this->request('imeiservicelist');
    }
    
    public function placeOrder($serviceId, $imei) {
        return $this->request('placeimeiorder', [
            'parameters[ID]' => $serviceId,
            'parameters[IMEI]' => $imei,
        ]);
    }
    
    public function getOrder($orderId) {
        return $this->request('getimeiorder', [
            'parameters[ID]' => $orderId,
        ]);
    }
}

// Usage:
$api = new DhruApi('https://3gsm.ru/api/v1', 'your_username', 'your_api_key');

// Check balance
$balance = $api->getBalance();
echo "Balance: " . $balance['SUCCESS'][0]['AccountInfo']['creditraw'] . " USD\n";

// Get services (IMEI + SERVER in one list)
$services = $api->getServices();

// Place order
$order = $api->placeOrder(101, '123456789012345');
$orderId = $order['SUCCESS'][0]['REFERENCEID'];

// Check order status (STATUS: 0 pending, 1 processing, 3 rejected, 4 completed)
$status = $api->getOrder($orderId);
echo "Status: " . $status['SUCCESS'][0]['STATUS'] . "\n";
echo "Result: " . $status['SUCCESS'][0]['CODE'] . "\n";
?>