SDKs overview

VALR provides Software Development Kits (SDKs) and client libraries designed to simplify interaction with its cryptocurrency exchange platform. These SDKs abstract the complexities of direct API calls, handling authentication, request formatting, and response parsing for both REST and WebSocket interfaces. Developers can utilize these tools to build automated trading bots, integrate VALR's market data into custom applications, or manage their VALR accounts programmatically.

The official VALR API documentation provides detailed endpoints for various functionalities, including:

  • Spot Trading: Placing and managing orders, checking balances, and retrieving trade history for various cryptocurrency pairs.
  • Derivatives Trading: Accessing perpetual futures contracts, managing positions, and retrieving funding rates.
  • Market Data: Fetching real-time market data, order books, and historical candles.
  • Account Management: Managing API keys, retrieving account details, and handling withdrawals/deposits.

VALR's API supports both public endpoints, which do not require authentication, and private endpoints, which require API key authentication for secure operations such as placing orders or accessing account balances. The official SDKs are designed to facilitate this authentication process securely.

Official SDKs by language

VALR offers official SDKs for popular programming languages, ensuring robust and supported integration points for developers. These SDKs are maintained by VALR and are the recommended method for interacting with the platform's API. The primary languages supported include Python, Node.js, and Java.

Language Package Name Installation Command Maturity
Python valr-api-client pip install valr-api-client Stable
Node.js valr-api npm install valr-api Stable
Java valr-api-client (Maven/Gradle dependency) Stable

Each SDK provides idiomatic interfaces for the respective language, allowing developers to interact with the VALR API using familiar programming constructs. For detailed usage and specific class methods, developers should refer to the official VALR API documentation.

Installation

Installing the VALR SDKs follows standard package management practices for each respective language. Below are the common installation steps for the official SDKs.

Python SDK

The Python SDK can be installed using pip, the Python package installer. It is recommended to use a virtual environment to manage dependencies.

pip install valr-api-client

After installation, you can import the client and begin interacting with the API:

from valr_api_client import VALRClient

# Initialize client (public endpoints)
client = VALRClient()

# For authenticated endpoints, provide API key and secret
# client = VALRClient(api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET")

Node.js SDK

The Node.js SDK is available via npm, the Node.js package manager.

npm install valr-api

To use the SDK in your Node.js project:

const VALR = require('valr-api');

// Initialize client (public endpoints)
const client = new VALR.Client();

// For authenticated endpoints
// const client = new VALR.Client('YOUR_API_KEY', 'YOUR_API_SECRET');

Java SDK

For Java projects, the VALR SDK is typically integrated using build tools like Maven or Gradle. You will need to add the appropriate dependency to your pom.xml (Maven) or build.gradle (Gradle) file.

Maven Dependency

<dependency>
    <groupId>com.valr</groupId>
    <artifactId>valr-api-client</artifactId>
    <version>1.0.0</version> <!-- Use the latest version -->
</dependency>

Gradle Dependency

implementation 'com.valr:valr-api-client:1.0.0' <!-- Use the latest version -->

Once the dependency is added and your project is built, you can instantiate the client:

import com.valr.client.VALRClient;

public class ValrApiExample {
    public static void main(String[] args) {
        // Initialize client (public endpoints)
        VALRClient client = new VALRClient();

        // For authenticated endpoints
        // VALRClient authenticatedClient = new VALRClient("YOUR_API_KEY", "YOUR_API_SECRET");
    }
}

Always refer to the most current VALR API documentation for the latest version numbers and detailed setup instructions.

Quickstart example

This quickstart example demonstrates how to fetch the current order book for a specific currency pair using the Python SDK. This involves initializing the client and making a public API call.

Python Quickstart: Get BTC/ZAR Order Book

This example retrieves the full order book for the BTC/ZAR trading pair. Note that for private endpoints (e.g., placing an order), you would need to initialize VALRClient with your API key and secret.

from valr_api_client import VALRClient

def get_btc_zar_order_book():
    """Fetches and prints the BTC/ZAR order book."""
    try:
        client = VALRClient()
        currency_pair = "BTCZAR"
        order_book = client.get_order_book(currency_pair=currency_pair)

        print(f"Order Book for {currency_pair}:")
        print("Bids:")
        for bid in order_book['Bids']:
            print(f"  Price: {bid['price']}, Quantity: {bid['quantity']}")
        print("\nAsks:")
        for ask in order_book['Asks']:
            print(f"  Price: {ask['price']}, Quantity: {ask['quantity']}")

    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    get_btc_zar_order_book()

This script will output the current bids and asks for the BTC/ZAR pair, demonstrating a basic interaction with VALR's public market data API. For more complex operations, such as placing trades or managing accounts, refer to the VALR API reference documentation.

Community libraries

While VALR provides official SDKs, the developer community often contributes additional libraries and tools that can extend functionality or offer alternative implementations. These community-driven projects are not officially supported by VALR but can be valuable for specific use cases or preferred programming styles.

Community libraries often emerge in languages not officially supported, or provide wrappers with additional features like advanced error handling, rate limiting, or specific trading strategies. Developers looking for community contributions should typically search platforms like GitHub or package repositories (e.g., PyPI for Python, npm for Node.js) using keywords such as valr api or valr client.

When considering a community library, it is important to:

  • Check Maintenance Status: Ensure the library is actively maintained and compatible with the latest VALR API versions.
  • Review Security: Especially for libraries handling API keys and secrets, verify the code for any potential security vulnerabilities.
  • Examine Documentation: Good documentation helps in understanding the library's features and usage.
  • Look at Community Activity: A vibrant community and active issue tracker can indicate a reliable library.

For instance, developers building on platforms like AWS might find community examples integrating VALR with serverless functions, as explored in general patterns for AWS Lambda and API Gateway integrations. Always prioritize official SDKs for critical applications due to direct vendor support and guaranteed compatibility.

For specific community projects, developers should consult developer forums, community Discord channels, or GitHub repositories related to VALR. The VALR official documentation may also sometimes link to popular community resources, but the primary recommendation remains the official SDKs for stability and support.