Skip to content

coinmate-io/coinmate-api-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Coinmate API Examples

Complete API client implementations for the Coinmate.io cryptocurrency exchange in Java, TypeScript, Python, and PHP.

Java 21 TypeScript Python 3.11+ PHP 8.2+

All four implementations provide:

  • βœ… Complete API Coverage - All 55+ Coinmate API endpoints
  • βœ… Type Safety - Full type checking (compile-time for Java/TS, runtime hints for Python/PHP)
  • βœ… HMAC-SHA256 Authentication - Automatic signature generation
  • βœ… Production Ready - Error handling, proper decimal precision
  • βœ… Well Documented - Examples and detailed documentation

Choose Your Language

Language Best For Async Precision Documentation
Java Enterprise, trading bots Blocking BigDecimal πŸ“– Java Docs
TypeScript Web apps, Node.js services Non-blocking number πŸ“– TS Docs
Python Scripts, data analysis Non-blocking Decimal πŸ“– Python Docs
PHP Web backends, APIs Blocking string πŸ“– PHP Docs

Quick Start

All four implementations share the same .env file for credentials!

1. Setup Credentials (Once)

# Copy the example file
cp .env.example .env

# Edit .env and add your Coinmate API credentials
# COINMATE_CLIENT_ID=your_client_id
# COINMATE_PUBLIC_KEY=your_public_key
# COINMATE_PRIVATE_KEY=your_private_key

Get your credentials from Coinmate Account Settings.

2. Run Your Preferred Implementation

Java

mvn exec:java \
  -Dexec.mainClass="org.example.Main"

TypeScript

cd typescript
npm install
npm start

Python

cd python
pip install -r requirements.txt
python -m src.main

PHP

cd php
composer install
composer start

Code Examples

Get Ticker (All Languages)

Java TypeScript Python
CoinmateTypedClient client =
  new CoinmateTypedClient(config);

CoinmateResponse<Ticker> response =
  client.getTicker("BTC_EUR");

if (response.isSuccess()) {
  Ticker ticker = response.getData();
  System.out.println(ticker.getLast());
}
const client = new CoinmateClient(config);

const response =
  await client.getTicker('BTC_EUR');

if (!response.error) {
  const ticker = response.data;
  console.log(ticker.last);
}
async with CoinmateClient(config) as client:
  response = await client.get_ticker('BTC_EUR')

  if not response.error:
    ticker = response.data
    print(ticker.last)

Place Buy Order (All Languages)

Java TypeScript Python
CoinmateResponse<OrderResult> order =
  client.buyLimit(
    "BTC_EUR",
    "0.001",
    "50000"
  );

if (order.isSuccess()) {
  System.out.println(
    order.getData().getOrderId()
  );
}
const order = await client.buyLimit({
  currencyPair: 'BTC_EUR',
  amount: '0.001',
  price: '50000'
});

if (!order.error) {
  console.log(order.data.orderId);
}
order = await client.buy_limit(
  currency_pair='BTC_EUR',
  amount='0.001',
  price='50000'
)

if not order.error:
  print(order.data.order_id)

Supported Endpoints

All four implementations support the same complete set of endpoints:

Public Endpoints (No Authentication)

  • πŸͺ™ Currencies and trading pairs
  • πŸ“Š Order book and ticker data
  • πŸ“ˆ Recent transactions
  • ⏰ Server time

Account Management (Authentication Required)

  • πŸ’° Account balances
  • πŸ’΅ Trading fees
  • πŸ“œ Transaction history
  • πŸ“Š Trade history
  • πŸ”„ Transfer history

Trading (Authentication Required)

  • πŸ“ˆ Buy/Sell limit orders
  • ⚑ Buy/Sell instant (market) orders
  • πŸ”„ Replace orders
  • ❌ Cancel orders
  • πŸ“‹ Order history

Deposits & Withdrawals (Authentication Required)

  • β‚Ώ Bitcoin (BTC) - including Lightning Network
  • Ξ Ethereum (ETH)
  • Ł Litecoin (LTC)
  • βœ• Ripple (XRP)
  • β‚³ Cardano (ADA)
  • β—Ž Solana (SOL)
  • πŸ’³ Bank wire withdrawals

Total: 55+ endpoints fully implemented

Project Structure

coinmateApiExamples/
β”œβ”€β”€ .env                    # Shared credentials (all languages)
β”œβ”€β”€ .env.example            # Template
β”œβ”€β”€ LICENSE                 # MIT License
β”œβ”€β”€ README.md              # This file (language-neutral)
β”‚
β”œβ”€β”€ java/                   # Java implementation
β”‚   β”œβ”€β”€ main/java/org/example/coinmate/
β”‚   β”‚   β”œβ”€β”€ auth/          # HMAC-SHA256 authentication
β”‚   β”‚   β”œβ”€β”€ client/        # API clients
β”‚   β”‚   β”œβ”€β”€ config/        # Configuration
β”‚   β”‚   └── model/         # Type-safe models
β”‚   β”œβ”€β”€ README.md          # Java documentation
β”‚   β”œβ”€β”€ API_METHODS.md     # Complete method reference
β”‚   └── TYPED_MODELS.md    # Typed models guide
β”‚
β”œβ”€β”€ typescript/             # TypeScript/Node.js implementation
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ auth/          # HMAC-SHA256 authentication
β”‚   β”‚   β”œβ”€β”€ client/        # API clients
β”‚   β”‚   β”œβ”€β”€ types/         # TypeScript type definitions
β”‚   β”‚   └── main.ts        # Example application
β”‚   └── README.md          # TypeScript documentation
β”‚
β”œβ”€β”€ python/                 # Python implementation
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ auth/          # HMAC-SHA256 authentication
β”‚   β”‚   β”œβ”€β”€ client/        # API clients
β”‚   β”‚   β”œβ”€β”€ types/         # Python type definitions (dataclasses)
β”‚   β”‚   └── main.py        # Example application
β”‚   └── README.md          # Python documentation
β”‚
└── php/                    # PHP implementation
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ Auth/          # HMAC-SHA256 authentication
    β”‚   β”œβ”€β”€ Client/        # API clients
    β”‚   β”œβ”€β”€ Types/         # PHP type definitions (readonly classes)
    β”‚   └── main.php       # Example application
    └── README.md          # PHP documentation

Authentication

All implementations use the same HMAC-SHA256 authentication mechanism:

  1. Nonce: Unix timestamp in milliseconds (must increase with each request)
  2. Message: Concatenate nonce + clientId + publicKey
  3. Signature: HMAC-SHA256 hash of message using private key
  4. Format: Convert signature to uppercase hexadecimal string

Authentication is handled automatically by each client.

Type Safety Comparison

Feature Java TypeScript Python PHP
Compile-time checks βœ… Yes βœ… Yes ⚠️ No (runtime hints) ⚠️ No (runtime)
IDE auto-completion βœ… Full βœ… Full βœ… Full βœ… Full
Decimal precision BigDecimal number (float) Decimal string
Refactoring support βœ… Full βœ… Full ⚠️ Limited ⚠️ Limited
Null safety βœ… Yes βœ… Yes ⚠️ Optional ⚠️ Optional

Language-Specific Features

Java

  • Two API styles: JsonObject (flexible) and Typed Models (recommended)
  • BigDecimal for precise financial calculations
  • Builder pattern for configuration
  • Try-with-resources for automatic cleanup
  • Maven for dependency management

See Java Documentation

TypeScript

  • Full TypeScript type definitions
  • Async/await with Promises
  • Zero external dependencies (only axios and dotenv)
  • npm scripts for development
  • Works in Node.js

See TypeScript Documentation

Python

  • Type hints with dataclasses
  • Async/await with asyncio and aiohttp
  • Decimal type for financial precision
  • Context managers for cleanup
  • pip for dependency management
  • Python 3.11+ required

See Python Documentation

PHP

  • Readonly classes for immutable types (PHP 8.2+)
  • Guzzle HTTP client for requests
  • phpdotenv for environment configuration
  • Composer for dependency management
  • PSR-4 autoloading

See PHP Documentation

Security Best Practices

πŸ”’ Never commit your API keys!

  • The .env file is in .gitignore and won't be committed
  • Use environment variables or the .env file for credentials
  • Consider using read-only API keys for non-trading operations
  • Rotate your keys regularly
  • Use different keys for development and production

Testing Without Credentials

All four implementations can run without credentials and will test only public endpoints:

# Java
mvn exec:java -Dexec.mainClass="org.example.Main"

# TypeScript
cd typescript && npm start

# Python
cd python && python -m src.main

# PHP
cd php && composer start

Error Handling

All implementations follow the same error handling pattern:

  1. Network errors: Caught as exceptions/errors at the call site
  2. API errors: Returned in the response object with error: true and errorMessage
  3. Check before use: Always check isSuccess() (Java) or !error (TS/Python) before accessing data

Building for Production

Java

mvn clean package
java -jar target/coinmate-api-example-1.0-SNAPSHOT.jar

TypeScript

cd typescript
npm run build
node dist/main.js

Python

cd python
python -m src.main  # Or deploy with your preferred method

PHP

cd php
composer install --no-dev
php src/main.php

Contributing

This is an example project demonstrating Coinmate API integration in multiple languages. Feel free to:

  • Fork and extend for your needs
  • Report issues
  • Suggest improvements
  • Add more language implementations

License

MIT License - See LICENSE for details.

Resources

Need Help?


Made with ❀️ for the Coinmate.io community

About

Coinmate API Clients (Java, TypeScript, PHP & Python)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published