Skip to content

На этой странице

API Адресов

API адресов предоставляет функциональность для управления криптовалютными адресами и сервисными кошельками.

Интерактивное тестирование

Тестируйте API в реальном времени! Введите ваш API ключ и нажимайте кнопки "Тест" для отправки запросов на https://cp-merch-dev.wsdemo.online/api.

Обзор

API адресов позволяет:

  • Создавать новые адреса для конкретных сетей и монет
  • Получать информацию об адресах и балансах
  • Управлять сервисными кошельками
POST

Создать адрес

POST /v1/addresses

Создает новый адрес для определенной сети и монеты.

Параметры

ПараметрТипОбязательныйОписание
networkstringДаСлаг сети (например, bitcoin, ethereum, tron)
coinstringНетСлаг монеты (опционально)

Ответы

201 Created

Адрес успешно создан

GET

Получить адрес

GET /v1/addresses/{address}

Возвращает информацию об адресе с балансом.

Параметры

ПараметрТипОбязательныйОписание
addressstringДаКриптовалютный адрес

Ответы

200 OK

Информация об адресе получена

Конфигурация API

Создать адрес

bash
curl -X POST "https://cp-merch-dev.wsdemo.online/api/v1/addresses" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "network": "ethereum"
  }'

Go HTTP Client

go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    payload := map[string]string{
        "network": "ethereum",
    }
    
    jsonData, _ := json.Marshal(payload)
    
    req, _ := http.NewRequest("POST", "https://cp-merch-dev.wsdemo.online/api/v1/addresses", bytes.NewBuffer(jsonData))
    req.Header.Set("X-Api-Key", "YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")
    
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := io.ReadAll(resp.Body)
    fmt.Printf("Ответ: %s\n", body)
}

JavaScript Fetch

javascript
const createAddress = async () => {
  const response = await fetch('https://cp-merch-dev.wsdemo.online/api/v1/addresses', {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      network: 'ethereum'
    })
  });
  
  const address = await response.json();
  console.log('Создан адрес:', address);
};

createAddress();

Python Requests

python
import requests
import json

headers = {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
}

payload = {'network': 'ethereum'}

response = requests.post('https://cp-merch-dev.wsdemo.online/api/v1/addresses', 
                        headers=headers, 
                        json=payload)

if response.status_code == 201:
    address = response.json()
    print(f"Создан адрес: {address['address']}")
else:
    print(f"Ошибка: {response.status_code}")

PHP cURL

php
<?php
$apiKey = 'YOUR_API_KEY';
$payload = json_encode(['network' => 'ethereum']);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://cp-merch-dev.wsdemo.online/api/v1/addresses');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-Api-Key: ' . $apiKey,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 201) {
    $address = json_decode($response, true);
    echo "Создан адрес: " . $address['address'] . "\n";
}
?>

Released under the MIT License.