Skip to main content

Documentation Index

Fetch the complete documentation index at: https://nexus.gerowallet.io/docs/llms.txt

Use this file to discover all available pages before exploring further.

The Gero Nexus API uses standard HTTP status codes and returns detailed error information to help you diagnose and handle issues gracefully.

Error Response Format

All errors return a consistent JSON structure:
{
  "error": "Error Type",
  "message": "Human-readable error description",
  "code": "ERROR_CODE",
  "details": {
    // Additional context (optional)
  }
}
FieldTypeDescription
errorstringHTTP error type (e.g., “Bad Request”, “Not Found”)
messagestringHuman-readable description of what went wrong
codestringMachine-readable error code for programmatic handling
detailsobjectAdditional context about the error (optional)

HTTP Status Codes

Success Codes

CodeStatusDescription
200OKRequest successful
201CreatedResource created successfully
202AcceptedRequest accepted for processing
204No ContentRequest successful, no content to return

Client Error Codes (4xx)

The request was malformed or contains invalid parameters.
{
  "error": "Bad Request",
  "message": "Invalid address format",
  "code": "INVALID_ADDRESS",
  "details": {
    "field": "address",
    "value": "invalid_addr",
    "expected": "Bech32 address starting with addr1 or stake1"
  }
}
Common causes:
  • Missing required parameters
  • Invalid parameter format
  • Invalid JSON in request body
  • Value out of allowed range
Solution: Check the request parameters against the API documentation.
Authentication failed or was not provided.
{
  "error": "Unauthorized",
  "message": "Invalid or expired access token",
  "code": "INVALID_TOKEN"
}
Common causes:
  • Missing Authorization header
  • Invalid or malformed JWT token
  • Expired access token
Solution: Refresh your token or re-authenticate.
The authenticated user lacks permission for this action.
{
  "error": "Forbidden",
  "message": "Insufficient permissions for this resource",
  "code": "PERMISSION_DENIED"
}
Common causes:
  • Account lacks required role
  • Endpoint restricted to specific plans
  • Attempting to access another user’s resources
Solution: Check your account permissions or upgrade your plan.
The requested resource does not exist.
{
  "error": "Not Found",
  "message": "Transaction not found",
  "code": "RESOURCE_NOT_FOUND",
  "details": {
    "resource": "transaction",
    "id": "abc123..."
  }
}
Common causes:
  • Invalid resource ID or hash
  • Resource has been deleted
  • Typo in the endpoint URL
  • Transaction not yet confirmed on-chain
Solution: Verify the resource ID and endpoint path.
The request was valid but cannot be processed.
{
  "error": "Unprocessable Entity",
  "message": "Transaction submission failed",
  "code": "TX_SUBMIT_FAILED",
  "details": {
    "reason": "Insufficient funds",
    "required": "10000000",
    "available": "5000000"
  }
}
Common causes:
  • Transaction validation failed
  • Insufficient funds for transaction
  • UTXO already spent
  • Invalid transaction structure
Solution: Check the error details for specific validation failures.
Rate limit exceeded.
{
  "error": "Too Many Requests",
  "message": "Rate limit exceeded",
  "code": "RATE_LIMIT_EXCEEDED",
  "details": {
    "limit": 100,
    "window": "1s",
    "retry_after": 1
  }
}
Solution: Implement rate limit handling and retry with exponential backoff.

Server Error Codes (5xx)

An unexpected error occurred on the server.
{
  "error": "Internal Server Error",
  "message": "An unexpected error occurred",
  "code": "INTERNAL_ERROR",
  "request_id": "req_abc123..."
}
Solution: Retry the request. If the problem persists, contact support with the request_id.
Error communicating with upstream service.
{
  "error": "Bad Gateway",
  "message": "Provider temporarily unavailable",
  "code": "PROVIDER_ERROR"
}
Solution: Check provider health and retry after a brief delay.
Service is temporarily unavailable.
{
  "error": "Service Unavailable",
  "message": "Service under maintenance",
  "code": "SERVICE_UNAVAILABLE",
  "details": {
    "retry_after": 300
  }
}
Solution: Wait and retry. Check status page for maintenance updates.
Request timed out waiting for upstream service.
{
  "error": "Gateway Timeout",
  "message": "Request timed out",
  "code": "TIMEOUT"
}
Solution: Retry the request. Consider using pagination for large queries.

Common Error Codes

CodeDescription
INVALID_TOKENJWT token is invalid or expired
INVALID_ADDRESSCardano address format is invalid
INVALID_HASHTransaction or block hash is invalid
RESOURCE_NOT_FOUNDRequested resource does not exist
RATE_LIMIT_EXCEEDEDToo many requests
TX_SUBMIT_FAILEDTransaction submission failed
PROVIDER_ERRORUpstream data provider error
VALIDATION_ERRORRequest validation failed

Error Handling Examples

JavaScript/TypeScript

class GeroNexusError extends Error {
  constructor(response) {
    super(response.message);
    this.name = 'GeroNexusError';
    this.status = response.status;
    this.code = response.code;
    this.details = response.details;
  }
}

async function apiRequest(endpoint, options = {}) {
  const response = await fetch(`https://nexus-dev.gerowallet.io${endpoint}`, {
    ...options,
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json',
      ...options.headers
    }
  });

  const data = await response.json();

  if (!response.ok) {
    throw new GeroNexusError({
      status: response.status,
      ...data
    });
  }

  return data;
}

// Usage with error handling
try {
  const block = await apiRequest('/api/blocks/latest');
  console.log(block);
} catch (error) {
  if (error instanceof GeroNexusError) {
    switch (error.code) {
      case 'INVALID_TOKEN':
        await refreshToken();
        // Retry request
        break;
      case 'RATE_LIMIT_EXCEEDED':
        await delay(error.details?.retry_after || 1000);
        // Retry request
        break;
      case 'RESOURCE_NOT_FOUND':
        console.log('Resource not found:', error.message);
        break;
      default:
        console.error('API Error:', error.message);
    }
  } else {
    console.error('Network error:', error);
  }
}

Python

import requests
from typing import Optional

class GeroNexusError(Exception):
    """Custom exception for Gero Nexus API errors"""

    def __init__(self, status: int, error: str, message: str,
                 code: str, details: Optional[dict] = None):
        super().__init__(message)
        self.status = status
        self.error = error
        self.code = code
        self.details = details or {}

    def __str__(self):
        return f"[{self.code}] {self.args[0]}"


def api_request(endpoint: str, method: str = 'GET', **kwargs) -> dict:
    """Make API request with error handling"""
    response = requests.request(
        method,
        f'https://nexus-dev.gerowallet.io{endpoint}',
        headers={
            'Authorization': f'Bearer {access_token}',
            'Content-Type': 'application/json'
        },
        **kwargs
    )

    data = response.json()

    if not response.ok:
        raise GeroNexusError(
            status=response.status_code,
            error=data.get('error', 'Unknown'),
            message=data.get('message', 'An error occurred'),
            code=data.get('code', 'UNKNOWN_ERROR'),
            details=data.get('details')
        )

    return data


# Usage with error handling
try:
    block = api_request('/api/blocks/latest')
    print(block)
except GeroNexusError as e:
    if e.code == 'INVALID_TOKEN':
        refresh_token()
        # Retry request
    elif e.code == 'RATE_LIMIT_EXCEEDED':
        time.sleep(e.details.get('retry_after', 1))
        # Retry request
    elif e.code == 'RESOURCE_NOT_FOUND':
        print(f'Resource not found: {e}')
    else:
        print(f'API Error: {e}')
except requests.RequestException as e:
    print(f'Network error: {e}')

Best Practices

Always Check Status

Never assume a request succeeded. Always check the HTTP status code and handle errors appropriately.

Use Error Codes

Use the code field for programmatic error handling rather than parsing error messages.

Implement Retry Logic

For transient errors (5xx, 429), implement retry with exponential backoff.

Log Request IDs

Log the request_id from error responses to help support diagnose issues.

Retry Strategy

Implement exponential backoff for retryable errors:
async function fetchWithRetry(fn, maxRetries = 3) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await fn();
    } catch (error) {
      const isRetryable =
        error.status >= 500 ||
        error.code === 'RATE_LIMIT_EXCEEDED' ||
        error.code === 'TIMEOUT';

      if (!isRetryable || attempt === maxRetries) {
        throw error;
      }

      const delay = Math.min(1000 * Math.pow(2, attempt), 30000);
      console.log(`Retry ${attempt + 1}/${maxRetries} after ${delay}ms`);
      await new Promise(r => setTimeout(r, delay));
    }
  }
}

Next Steps

Rate Limits

Understand rate limiting and quotas

Pagination

Working with paginated responses

Authentication

Learn about API authentication

API Reference

Explore all available endpoints