API Reference

Complete API documentation for developers building applications on HP Swarm infrastructure.

Quick Start

Base URL

https://api.hpswarm.io/v1

Authentication

All API requests require an API key in the header:

Authorization: Bearer YOUR_API_KEY

Core Endpoints

Wallet Management

GET/wallet/balance

Get wallet balance for HP tokens

Parameters:

  • address (string, required) - Wallet address
{ "address": "0x742d35Cc6634C0532925a3b8D4C0C2f2", "balance": "1000.50", "symbol": "HP", "decimals": 18 }
POST/wallet/transfer

Transfer HP tokens between wallets

Request Body:

{ "from": "0x742d35Cc6634C0532925a3b8D4C0C2f2", "to": "0x8ba1f109551bD432803012645Hac136c", "amount": "100.0", "gas_limit": "21000" }

Transactions

GET/transactions/{hash}

Get transaction details by hash

{ "hash": "0xabc123...", "status": "confirmed", "from": "0x742d35Cc6634C0532925a3b8D4C0C2f2", "to": "0x8ba1f109551bD432803012645Hac136c", "amount": "100.0", "gas_used": "21000", "block_number": 12345678, "timestamp": "2024-01-15T10:30:00Z" }
GET/transactions/history

Get transaction history for an address

Parameters:

  • address (string, required) - Wallet address
  • limit (integer, optional) - Number of transactions (default: 50)
  • offset (integer, optional) - Pagination offset

Presale

GET/presale/status

Get current presale status and stage information

{ "current_stage": 3, "stage_price": "0.002", "bonus_percentage": 15, "total_raised": "2500000", "tokens_sold": "75", "presale_end": "2024-12-31T23:59:59Z", "is_active": true }
POST/presale/purchase

Purchase tokens during presale

Request Body:

{ "wallet_address": "0x742d35Cc6634C0532925a3b8D4C0C2f2", "eth_amount": "1.0", "signature": "0x..." }

Error Codes

400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
403Forbidden - Insufficient permissions
404Not Found - Resource not found
429Rate Limited - Too many requests
500Internal Server Error

Rate Limits

Standard Plan

  • • 1,000 requests per hour
  • • 10,000 requests per day
  • • Burst limit: 100 requests per minute

Enterprise Plan

  • • 10,000 requests per hour
  • • 100,000 requests per day
  • • Burst limit: 1,000 requests per minute

SDKs & Libraries

JavaScript/Node.js

npm install @hpswarm/sdk
View Documentation →

Python

pip install hpswarm-python
View Documentation →

Go

go get github.com/hpswarm/go-sdk
View Documentation →

Code Examples

Get Wallet Balance

// JavaScript/Node.js
const hpswarm = require('@hpswarm/sdk');
const client = new hpswarm.Client('YOUR_API_KEY');

const balance = await client.wallet.getBalance({
  address: '0x742d35Cc6634C0532925a3b8D0F3e3e1a0e1e8C8'
});
console.log(balance);

Purchase Tokens

// JavaScript/Node.js
const transaction = await client.presale.purchase({
  amount: '0.1', // ETH amount
  wallet: '0x742d35Cc6634C0532925a3b8D0F3e3e1a0e1e8C8'
});
console.log('Transaction hash:', transaction.hash);