Batch Operations

The MNEE SDK provides a powerful batch processing system for handling multiple operations efficiently. It includes automatic chunking, rate limiting, error recovery, and progress tracking.

Setup

import Mnee from '@mnee/ts-sdk';

// Initialize MNEE SDK
const mnee = new Mnee({
    environment: 'sandbox', 
    apiKey: 'your-api-key'
});

// For examples below, assume mnee is already set up

Getting Started

Access batch operations through the batch() method:

const batch = mnee.batch();

Available Methods

Get UTXOs for Multiple Addresses

Retrieve UTXOs for multiple addresses with automatic chunking and error handling.

Get Balances for Multiple Addresses

Efficiently retrieve balances for multiple addresses.

Get Transaction Histories

Retrieve transaction histories for multiple addresses with custom parameters.

Parse Multiple Transactions

Parse multiple transactions with optional extended data.

Configuration Options

All batch methods support the following options:

Response Structure

All batch operations return a BatchResult:

Common Use Cases

Portfolio Balance Check

UTXO Collection

Transaction Analysis

Error Recovery

High-Performance Processing

Progress Monitoring

Batch History Export

Best Practices

Chunk Size Optimization

  • Small operations: Use default chunk size (20)

  • Large datasets: Increase to 50-100 for better performance

  • Rate-limited APIs: Reduce chunk size to avoid hitting limits

Error Handling

  • Use continueOnError: true for resilient processing

  • Check the errors array in the response

  • Implement custom retry logic for critical operations

Performance Tips

  • Adjust requestsPerSecond based on your API limits

  • Use progress callbacks for long-running operations

  • Process results as they complete rather than waiting for all

Memory Management

  • For very large datasets, process results incrementally

  • Clear processed data from memory when no longer needed

  • Consider streaming results to disk for massive operations

Rate Limiting

The batch system includes intelligent rate limiting:

  • Respects the configured requestsPerSecond limit

  • Automatically handles concurrent request management

  • Ensures minimum delay between API calls

  • Works efficiently even with fractional rates (e.g., 0.5 requests/second)

Error Types

Common errors you might encounter:

  1. Invalid Input: Empty or malformed addresses/txids

  2. API Errors: Network issues or service unavailability

  3. Rate Limit: Exceeded API rate limits

  4. Validation Errors: Invalid Bitcoin addresses or transaction IDs

See Also

Last updated