Skip to content

Kimlik Doğrulama

TronZap API'sine yapılan tüm API istekleri Bearer token ve imza kullanılarak kimlik doğrulaması gerektirir. Bu, API isteklerinizin güvenliğini ve bütünlüğünü sağlar.

API Kimlik Bilgilerini Edinme

TronZap API'si ile başlamak için kontrol panelinden API kimlik bilgilerinizi edinmeniz gerekir:

  1. TronZap Kontrol Paneli'ne giriş yapın
  2. API bölümüne gidin
  3. API token ve gizli anahtarınızı kopyalayın

API Anahtarları Konumu

TIP

API kimlik bilgilerinizi güvenli tutun ve asla herkese açık şekilde paylaşmayın. API gizli anahtarınız bir şifre gibi ele alınmalıdır.

Gerekli Başlıklar

BaşlıkAçıklama
Authorization: Bearer YOUR_API_TOKENAPI token'ınız
X-Signature: YOUR_SIGNATUREİstek imzası
Content-Type: application/jsonİçerik türü JSON olmalıdır

İmza Hesaplama

İmza, istek gövdesi ile API gizli anahtarınızın birleştirilmesiyle SHA256 hash'i kullanılarak hesaplanır.

bash
signature=$(echo -n "$requestBody$apiSecret" | sha256sum | cut -d' ' -f1)

Farklı Dillerde Örnekler

bash
#!/bin/bash
API_TOKEN="your_api_token"
API_SECRET="your_api_secret"
REQUEST_BODY='{"service":"energy","params":{"address":"TRX_ADDRESS","energy_amount":65000,"duration":1}}'

# İmzayı hesapla
SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1)

# API isteği yap
curl -X POST "https://api.tronzap.com/v1/transaction/new" \
  -H "Authorization: Bearer ${API_TOKEN}" \
  -H "X-Signature: ${SIGNATURE}" \
  -H "Content-Type: application/json" \
  -d "${REQUEST_BODY}"
javascript
const crypto = require('crypto');
const axios = require('axios');

const apiToken = 'your_api_token';
const apiSecret = 'your_api_secret';
const requestBody = JSON.stringify({
  service: 'energy',
  params: {
    address: 'TRX_ADDRESS',
    energy_amount: 65000,
    duration: 1
  }
});

// İmzayı hesapla
const signature = crypto
  .createHash('sha256')
  .update(requestBody + apiSecret)
  .digest('hex');

// API isteği yap
axios({
  method: 'post',
  url: 'https://api.tronzap.com/v1/transaction/new',
  headers: {
    'Authorization': `Bearer ${apiToken}`,
    'X-Signature': signature,
    'Content-Type': 'application/json'
  },
  data: requestBody
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
php
<?php
$apiToken = 'your_api_token';
$apiSecret = 'your_api_secret';
$requestBody = json_encode([
  'service' => 'energy',
  'params' => [
    'address' => 'TRX_ADDRESS',
    'energy_amount' => 65000,
    'duration' => 1
  ]
]);

// İmzayı hesapla
$signature = hash('sha256', $requestBody . $apiSecret);

// API isteği yap
$ch = curl_init('https://api.tronzap.com/v1/transaction/new');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer ' . $apiToken,
  'X-Signature: ' . $signature,
  'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
python
import hashlib
import json
import requests

api_token = 'your_api_token'
api_secret = 'your_api_secret'
request_body = json.dumps({
  'service': 'energy',
  'params': {
    'address': 'TRX_ADDRESS',
    'energy_amount': 3206500000,
    'duration': 1
  }
})

# İmzayı hesapla
signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest()

# API isteği yap
headers = {
  'Authorization': f'Bearer {api_token}',
  'X-Signature': signature,
  'Content-Type': 'application/json'
}

response = requests.post(
  'https://api.tronzap.com/v1/transaction/new',
  headers=headers,
  data=request_body
)

print(response.json())

Tron Energy API Documentation