Skip to content

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

Networks API

The networks API provides functionality for managing blockchain networks, their configurations, and Tron-specific operations.

Interactive Testing

Test the API in real time! Enter your API key and click "Test" buttons to send requests to https://cp-merch-dev.wsdemo.online/api.

Overview

The networks API allows you to:

  • Get information about supported blockchain networks
  • Configure network parameters (admin only)
  • Monitor last processed block numbers
  • Manage Tron staking and resources
GET

Get Networks

GET /v1/networks

Returns list of all supported blockchain networks with their configurations.

Ответы

200 OK

Networks list retrieved

GET

Get Network

GET /v1/networks/{network}

Returns information about a specific blockchain network.

Параметры

ПараметрТипОбязательныйОписание
networkstringДаNetwork slug (e.g., bitcoin, ethereum, tron, bsc)

Ответы

200 OK

Network information retrieved

400 Bad Request

Invalid network slug

GET

Get Last Block Number

GET /v1/networks/last-number-block/{network}

Returns the last processed block number for specified network.

Параметры

ПараметрТипОбязательныйОписание
networkstringДаNetwork slug

Ответы

200 OK

Last block number retrieved

POST

Stake TRX

POST /v1/networks/tron/stake

Stakes provided amount of TRX to obtain bandwidth or energy. Admin access only.

Параметры

ПараметрТипОбязательныйОписание
amountstringДаAmount of TRX to stake
resourcestringДаResource type: BANDWIDTH or ENERGY

Ответы

201 Created

TRX staked successfully

API Configuration

Get Networks

bash
curl -X GET "https://cp-merch-dev.wsdemo.online/api/v1/networks" \
  -H "X-Api-Key: YOUR_API_KEY"

Go HTTP Client

go
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://cp-merch-dev.wsdemo.online/api/v1/networks", nil)
    req.Header.Set("X-Api-Key", "YOUR_API_KEY")
    
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := io.ReadAll(resp.Body)
    fmt.Printf("Response: %s\n", body)
}

JavaScript Fetch

javascript
const getNetworks = async () => {
  const response = await fetch('https://cp-merch-dev.wsdemo.online/api/v1/networks', {
    headers: {
      'X-Api-Key': 'YOUR_API_KEY'
    }
  });
  
  const networks = await response.json();
  console.log('Networks:', networks);
};

getNetworks();

Python Requests

python
import requests

headers = {
    'X-Api-Key': 'YOUR_API_KEY'
}

response = requests.get('https://cp-merch-dev.wsdemo.online/api/v1/networks', 
                       headers=headers)

if response.status_code == 200:
    networks = response.json()
    print(f"Found {len(networks)} networks")
else:
    print(f"Error: {response.status_code}")

PHP cURL

php
<?php
$apiKey = 'YOUR_API_KEY';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://cp-merch-dev.wsdemo.online/api/v1/networks');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-Api-Key: ' . $apiKey
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

if ($httpCode === 200) {
    $networks = json_decode($response, true);
    echo "Found " . count($networks) . " networks\n";
}
?>

Released under the MIT License.