SELF Chain Testnet API Gateway
This API gateway is planned but not yet active. The endpoints shown below are specifications only and will not work until deployment is complete.
Expected Deployment: Q3-Q4 2025 (Watch GitHub Releases for updates)
Once deployed, this API gateway will provide testnet access only:
- Do not send real assets or deploy production applications
- Testnet tokens have ZERO monetary value
- Network may reset at any time without notice
Status: Planning Phaseâ
Current State:
- â Specification complete
- â Documentation ready
- â Infrastructure setup pending
- â Deployment pending
- â Testing pending
When Will This Be Available?â
Once the API Gateway is deployed:
- This documentation will be updated to remove all "NOT ACTIVE" warnings
- The endpoints will become functional
- Announcements will be made across multiple channels:
- GitHub Releases
- Project website and social media
- The testnet connection guide will be updated with working examples
In the meantime:
- Review this specification to understand the planned API
- Prepare your applications for future integration
- Join our Discord for deployment updates
- Consider running a local node for immediate testing needs
Overviewâ
The SELF Chain Testnet API Gateway provides secure, reliable access to our testnet blockchain network. Built on enterprise-grade infrastructure, it offers developers a production-like environment for testing and development.
Key Featuresâ
- đ HTTPS/TLS - All connections secured with SSL certificates
- ⥠Rate Limiting - Fair usage policies to ensure availability
- đ CORS Support - Enable web application development
- đ Health Monitoring - Real-time status and availability checks
- đ High Performance - Optimized for developer productivity
Endpoint Informationâ
Primary Endpoint (Planned)â
https://testnet-api.self.app (NOT ACTIVE YET)
Backup Endpoints (Planned)â
During the beta phase, we may provide additional endpoints for redundancy:
https://testnet-api-us.self.app (US Region - NOT ACTIVE)
https://testnet-api-eu.self.app (EU Region - NOT ACTIVE)
https://testnet-api-ap.self.app (Asia Pacific - NOT ACTIVE)
IMPORTANT: These endpoints are not yet deployed. Attempting to connect will result in connection errors.
Rate Limitingâ
To ensure fair access for all developers, the following rate limits apply:
Tier | Requests/Minute | Burst Capacity | Daily Limit |
---|---|---|---|
Default | 100 | 200 | 100,000 |
Authenticated | 500 | 1,000 | 500,000 |
Partner | 2,000 | 4,000 | Unlimited |
Rate Limit Headersâ
All responses include rate limit information:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200
X-RateLimit-Burst-Capacity: 200
Handling Rate Limitsâ
When rate limited, you'll receive:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 60
{
"error": "rate_limit_exceeded",
"message": "Too many requests. Please retry after 60 seconds.",
"retry_after": 60
}
CORS Configurationâ
The API gateway supports Cross-Origin Resource Sharing (CORS) for web applications:
Allowed Originsâ
http://localhost:*
(Development)https://*.self.app
(SELF domains)https://*.vercel.app
(Vercel deployments)https://*.netlify.app
(Netlify deployments)
Allowed Methodsâ
GET, POST, OPTIONS, PUT, DELETE
Allowed Headersâ
Origin, X-Requested-With, Content-Type, Accept, Authorization
Preflight Requestsâ
The gateway automatically handles CORS preflight requests:
curl -X OPTIONS https://testnet-api.self.app/v1/status \
-H "Origin: http://localhost:3000" \
-H "Access-Control-Request-Method: POST"
API Endpoints (Specification)â
Note: The following endpoints are planned specifications. They are not yet operational.
Health & Statusâ
Gateway Health Checkâ
GET /health (NOT ACTIVE)
Response:
{
"status": "healthy",
"timestamp": "2024-01-15T10:30:00Z",
"version": "1.0.0"
}
Network Statusâ
GET /v1/status
Response:
{
"network": "testnet",
"status": "operational",
"chain_id": "self-testnet-1",
"latest_block": {
"height": 123456,
"hash": "0x...",
"timestamp": "2024-01-15T10:29:30Z"
},
"node_info": {
"version": "0.1.0",
"peer_count": 8,
"syncing": false
},
"warning": "This is a test network - do not use real assets"
}
Blockchain Queriesâ
Get Blockâ
GET /v1/blocks/{height}
GET /v1/blocks/hash/{hash}
GET /v1/blocks/latest
Get Transactionâ
GET /v1/transactions/{hash}
Get Accountâ
GET /v1/accounts/{address}
GET /v1/accounts/{address}/balance
GET /v1/accounts/{address}/transactions
Transaction Submissionâ
Submit Transactionâ
POST /v1/transactions
Content-Type: application/json
{
"tx": "base64_encoded_signed_transaction"
}
Response:
{
"hash": "0x...",
"status": "pending",
"estimated_confirmation": 5
}
WebSocket Supportâ
For real-time updates, connect to our WebSocket endpoint:
const ws = new WebSocket('wss://testnet-api.self.app/v1/ws');
ws.on('open', () => {
// Subscribe to new blocks
ws.send(JSON.stringify({
type: 'subscribe',
channel: 'blocks'
}));
});
ws.on('message', (data) => {
const event = JSON.parse(data);
console.log('New block:', event);
});
Available Channelsâ
blocks
- New block eventstransactions
- Transaction confirmationsvalidators
- Validator set changes
Authentication (Optional)â
While the testnet is open for public use, authenticated requests receive higher rate limits:
Authorization: Bearer YOUR_API_KEY
To obtain an API key:
- Join our Discord
- Use the
/api-key
command in #testnet-help - Follow the bot's instructions
Error Handlingâ
Error Response Formatâ
{
"error": "error_code",
"message": "Human readable error message",
"details": {
"field": "additional_context"
}
}
Common Error Codesâ
Code | Description |
---|---|
invalid_request | Malformed request |
not_found | Resource not found |
rate_limit_exceeded | Too many requests |
internal_error | Server error |
network_error | Blockchain network issue |
SDK Integration Examplesâ
IMPORTANT: These are example implementations for when the API gateway is deployed. They will not work until the service is active.
JavaScript/TypeScript (Future Implementation)â
// This code will work once the API is deployed
// Currently it will throw a connection error
// Using fetch
const response = await fetch('https://testnet-api.self.app/v1/status');
const status = await response.json();
// Using axios with interceptors
const client = axios.create({
baseURL: 'https://testnet-api.self.app/v1',
timeout: 30000,
headers: {
'Content-Type': 'application/json'
}
});
// Add retry logic for rate limits
client.interceptors.response.use(
response => response,
async error => {
if (error.response?.status === 429) {
const retryAfter = error.response.headers['retry-after'] || 60;
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
return client.request(error.config);
}
return Promise.reject(error);
}
);
Pythonâ
import requests
from time import sleep
class SELFTestnetClient:
def __init__(self):
self.base_url = "https://testnet-api.self.app/v1"
self.session = requests.Session()
def get_status(self):
response = self.session.get(f"{self.base_url}/status")
if response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', 60))
sleep(retry_after)
return self.get_status()
response.raise_for_status()
return response.json()
cURLâ
# Get network status
curl -X GET https://testnet-api.self.app/v1/status \
-H "Accept: application/json"
# Submit transaction
curl -X POST https://testnet-api.self.app/v1/transactions \
-H "Content-Type: application/json" \
-d '{"tx": "base64_encoded_transaction"}'
Monitoring & Observabilityâ
Service Status Pageâ
Check real-time API gateway status:
https://status.self.app
Metrics Endpointâ
For developers building monitoring dashboards:
GET /metrics
Provides Prometheus-compatible metrics including:
- Request counts and latencies
- Error rates
- Active connections
- Rate limit statistics
Best Practicesâ
1. Implement Retry Logicâ
Always implement exponential backoff for failed requests:
async function retryRequest(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
const delay = Math.pow(2, i) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
}
}
}
2. Cache Responsesâ
Cache immutable data to reduce API calls:
const blockCache = new Map();
async function getBlock(height) {
if (blockCache.has(height)) {
return blockCache.get(height);
}
const block = await fetchBlock(height);
blockCache.set(height, block);
return block;
}
3. Use Compressionâ
Enable gzip compression for responses:
fetch('https://testnet-api.self.app/v1/blocks/latest', {
headers: {
'Accept-Encoding': 'gzip, deflate'
}
});
4. Handle Network Errorsâ
Always handle network failures gracefully:
try {
const data = await client.get('/status');
// Process data
} catch (error) {
if (error.code === 'ECONNREFUSED') {
console.error('API gateway is unreachable');
// Fallback logic
}
}
Security Considerationsâ
TLS/SSLâ
- All connections must use HTTPS
- Minimum TLS version: 1.2
- Certificate pinning recommended for production apps
API Keysâ
- Store API keys securely (never in code)
- Rotate keys regularly
- Use environment variables
Request Validationâ
- Validate all inputs client-side
- Never trust data from the testnet
- Implement request signing for sensitive operations
Troubleshootingâ
Common Issuesâ
Connection Timeoutâ
Error: ETIMEDOUT
Solution: Increase timeout settings or check network connectivity
Certificate Errorâ
Error: unable to verify the first certificate
Solution: Update your system's CA certificates
CORS Errorâ
Access to fetch at 'https://testnet-api.self.app' from origin 'http://localhost:3000' has been blocked by CORS policy
Solution: Ensure your origin is allowed or use a proxy during development
Migration Guideâ
From Direct Node Connectionâ
If you're currently connecting directly to testnet nodes:
// Old way
const node = new SELFNode('http://testnet-node.self.app:26657');
// New way (via API Gateway)
const client = new SELFClient('https://testnet-api.self.app');
Benefits of Migrationâ
- â Automatic load balancing
- â Built-in rate limiting
- â HTTPS encryption
- â Better reliability
- â Monitoring and metrics
Support & Feedbackâ
Getting Helpâ
- GitHub Issues: Report bugs
- Email: devs@self.app
Providing Feedbackâ
We value your feedback! Please report:
- Performance issues
- API inconsistencies
- Documentation improvements
- Feature requests
Roadmapâ
Current (Q3 2025)â
- đ API gateway development
- đ Rate limiting implementation
- đ WebSocket support
- đ Monitoring dashboard
Next (Q4 2025)â
- GraphQL endpoint
- Advanced query capabilities
- Batch transaction support
- Enhanced caching
Future (2026)â
- Multi-region deployment
- Custom rate limit tiers
- Advanced analytics
- SLA guarantees
Remember: This is a testnet. Expect changes, improvements, and occasional downtime as we prepare for mainnet.