CatFee.IO
Buy Tron EnergyDashboard
English
English
  • Introduction
  • Getting started
    • Quick Start Guide
    • Buy Energy via Direct TRX Transfer
    • Buy Energy via DApp
    • Buy Energy via API
      • API Overview
      • Java Example for Calling API
      • Python Example for Calling API
      • PHP Example for Calling API
      • Node.js Example for Calling API
      • Go Example for Calling API
    • API Supports Idempotency
    • Energy Subleasing Service
    • 💎Telegram Premium Reselling
    • Blockchain Monitoring Service
    • TRON Node Connection Guide
    • Frequently Asked Questions (FAQ)
    • Terms of Service
  • API Reference
    • Account Information
    • Buy Energy
    • Get Order Detail
    • Estimated Order Amount
    • Buy Telegram Premium
  • knowledge base
    • What is TRON Energy?
    • Why Rent Energy on the TRON Network?
    • How to fix “OUT OF ENERGY” error on TRON Transfers?
    • Why Can’t You Use a Centralized Exchange (CEX) Wallet to Buy TRON Energy?
    • What is a Centralized Exchange (CEX)?
    • How Much Energy and Bandwidth Does a USDT Transfer Consume?
    • Why Does the Transfer Fail Even After Renting Energy on TRON?
    • Why Are Some Energy Rentals So Cheap?
  • Telegram Bot
    • How to Create a Telegram Bot and Host It on CatFee?
Powered by GitBook
On this page
  • 1. Introduction
  • 2. Apply for API
  • 3. Base URL
  • 4. Signature Mechanism
  • 5. How to Generate a Signature
  • 6. Required HTTP Headers
  • 7. Request Examples
  • 8. Response Format

Was this helpful?

  1. Getting started
  2. Buy Energy via API

API Overview

Buy energy via API on TRON network.

1. Introduction

CatFee.IO offers a secure and standardized API for efficient access to its resources. With this API, users can perform various operations such as creating orders, querying accounts, and more. All requests must be signed to ensure their authenticity and security.

📢 Subscribe to the CatFee Telegram Channel for updates https://t.me/CatFeeOfficial


2. Apply for API

After registering and logging in to CatFee, go to the User Center, click on the "API" menu on the right, and select "API Settings". On this page, you can:

  • View your API Key and API Secret

  • Set an IP Whitelist to restrict access to your API, enhancing security and preventing potential losses due to API key leakage

Please keep your API credentials secure and enable IP whitelisting to protect your account and assets.


3. Base URL

  • Production Environment: https://api.catfee.io

  • Test Environment: https://nile.catfee.io

To obtain TRON test tokens (for the Nile testnet), visit: https://nileex.io/join/getJoinPage (You can claim 2,000 TRX daily.)

You can then verify your test tokens on the TRON Nile explorer: https://nile.tronscan.org

Select the appropriate environment based on your needs.


4. Signature Mechanism

To ensure secure API access, CatFee.IO uses HMAC-SHA256 signatures for authentication. Each request must include a valid signature to confirm it has not been tampered with and is authorized.


5. How to Generate a Signature

5.1 Signature String Concatenation

The signature string is constructed by concatenating the following:

sign = timestamp + method + requestPath
  • timestamp: The current ISO 8601 UTC time, e.g., 2023-08-26T12:34:56.789Z

  • method: The HTTP method, such as GET, POST, PUT, or DELETE

  • requestPath: The API endpoint path, including query parameters if present. Example: /v1/order?quantity=65000&receiver=TRON_ADDRESS&duration=1h

⚠️ Note: Query parameters must be included in the requestPath.

5.2 Signature Generation Steps

  1. Concatenate timestamp + method + requestPath

  2. Use HMAC-SHA256 to encrypt the string with your API Secret as the key

  3. Encode the result using Base64 to produce the final signature

5.3 Example

Given:

timestamp = 2023-08-26T12:34:56.789Z
method = POST
requestPath = /v1/order?quantity=65000&receiver=TRON_ADDRESS&duration=1h

The string to sign is:

2023-08-26T12:34:56.789ZPOST/v1/order?quantity=65000&receiver=TRON_ADDRESS&duration=1h

Apply HMAC-SHA256 using your API Secret, then Base64 encode the result to generate the signature.


6. Required HTTP Headers

Each request must include the following headers:

Content-Type: application/json
CF-ACCESS-KEY: your_api_key
CF-ACCESS-SIGN: generated_signature
CF-ACCESS-TIMESTAMP: timestamp_in_ISO_8601

7. Request Examples

7.1 POST Request Example

Let’s say you want to buy energy by creating an order using the following parameters:

quantity = 65000
receiver = TRON_ADDRESS
duration = 1h

The request URL would be:

https://api.catfee.io/v1/order?quantity=65000&receiver=TRON_ADDRESS&duration=1h

Headers:

Content-Type: application/json
CF-ACCESS-KEY: your_api_key
CF-ACCESS-SIGN: generated_signature
CF-ACCESS-TIMESTAMP: 2023-08-26T12:34:56.789Z

7.2 GET Request Example

If you want to query configuration information (no parameters), the request URL is:

https://api.catfee.io/v1/config

Headers:

Content-Type: application/json
CF-ACCESS-KEY: your_api_key
CF-ACCESS-SIGN: generated_signature
CF-ACCESS-TIMESTAMP: 2023-08-26T12:34:56.789Z

8. Response Format

All responses follow a standard structure:

{
  "code": "0",
  "msg": "",
  "data": {
    "key": "value"
  }
}
  • code: "0" means the request was successful

  • msg: Message or error description

  • data: Actual result payload (typically a JSON object with key-value pairs)

PreviousBuy Energy via APINextJava Example for Calling API

Last updated 18 days ago

Was this helpful?

Java API Example

Python Example

PHP Example

Node.js Example

Go Example