Introduction to the API
Pact Swap API Reference
REST API Overview
The Pact Swap REST API provides a comprehensive set of endpoints for interacting with the decentralized exchange built on the Coinweb protocol. The API is organized into several contract modules, each serving specific functionality:
- SWAP: Core swap functionality for users and liquidity providers
- ECDSA: Wallet balance and UTXO management for ECDSA-based wallets
All endpoints follow RESTful conventions and return JSON responses. The API uses:
- GET requests for querying data (order information, swap status, balances, quotes)
- POST requests for creating UI commands that generate QR code strings for Coinweb L2 transactions
Transaction composition endpoints (both GET and POST) return unsigned transaction data that can be signed and broadcast by your wallet.
Base URL
The API base URL is typically:
https://cwap-api.coinhq.storeAuthentication
Most endpoints do not require authentication. However, when composing transactions, you'll need to sign them with your wallet before broadcasting to the blockchain.
Response Format
All endpoints return JSON responses. Error responses follow a standard format with appropriate HTTP status codes.
Transaction Composition
Endpoints that compose transactions (prefixed with compose) return unsigned
transaction data. For Bitcoin-like blockchains (BTC, LTC, DOGE), you'll need to
provide UTXO information and a public key. For EVM-compatible blockchains, the
response includes chain-specific fields like chainId, value, to, and
type.
This section provides an overview of the available API endpoints for interacting with the decentralized exchange.
SWAP
This contract module is for communicating with the Pact Swap contract. The API is divided into two main sections:
- Liquidity Provider API: Endpoints for liquidity providers to manage orders, check swap status, and finalize transactions
- User API: Endpoints for users to get swap quotes and compose swap transactions
The compose routes can create an unsigned transaction that can be signed by your wallet of choice and broadcasted to the desired network.
Liquidity Provider Endpoints
Get Swap Quotes By Amount To
Retrieves a swap quotes based on the desired output amount.
Get Swap Status
Fetches the current status of a swap transaction.
Compose Swap TX By Amount From
Composes a swap transaction based on a specified input amount.
Compose Swap TX By Amount To
Composes a swap transaction based on a specified output amount.
Get All C1 Orders
Fetches all C1 orders from the order book.
Get All C2 Orders
Fetches all C2 orders from the order book.
Get Reversed Orders
Retrieves orders that have been reversed.
Get Swap Quotes By Amount From
Composes a swap transaction based on the amount of destination tokens you want to receive. The transaction can be signed and broadcast to execute the swap. Retrieves a swap quotes based on the desired input amount.
ECDSA
The ECDSA contract module is for communication with the ECDSA User contract. The helper routes are for fetching balances and UTXOs for a given Coinweb wallet address identified by its public key. You can find out more about the ECDSA User contract here.
Get Wallet Balance CWEB
Retrieves the CWEB token balance for an ECDSA wallet identified by its public key, without detailed UTXO information.
Get Wallet Balance CWEB With UTXOs
Retrieves the CWEB token balance for an ECDSA wallet identified by its public key, including detailed information about all unspent transaction outputs (UTXOs).
Batch Get Wallet Balance CWEB
Retrieves CWEB token balances for multiple ECDSA wallets identified by their public keys, without detailed UTXO information.
Batch Get Wallet Balance CWEB With UTXOs
Retrieves CWEB token balances for multiple ECDSA wallets identified by their public keys, including detailed information about all UTXOs for each wallet.
Was this documentation helpful? Any suggestions?