### Install luno-go SDK Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go This command installs the Luno Go SDK, enabling integration with the Luno API in Go projects. It requires the Go toolchain to be installed. ```go go get github.com/luno/luno-go ``` -------------------------------- ### Define Luno Get Balances Request Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Represents the request to get account balances, specifying which assets to include. ```go type GetBalancesRequest struct Assets []string ``` -------------------------------- ### Streaming API Client Example Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0.0.35/streaming Demonstrates how to establish a connection to the Luno Streaming API, retrieve order book snapshots, and process them in a loop. Requires API keys and market pair. ```go c, err := streaming.Dial(keyID, keySecret, "XBTZAR") if err != nil { log.Fatal(err) } def ``` -------------------------------- ### Authenticate and Get Order Book with Luno Go SDK Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Demonstrates how to initialize the Luno client, set API credentials, and fetch the order book for a given trading pair. It requires the 'luno-go' package and standard Go libraries for context and logging. ```go package main import ( "log" "context" "time" "github.com/luno/luno-go" ) func main() { lunoClient := luno.NewClient() err := lunoClient.SetAuth("", "") if err != nil { log.Fatal(err) } req := luno.GetOrderBookRequest{Pair: "XBTZAR"} ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(10*time.Second)) defer cancel() res, err := lunoClient.GetOrderBook(ctx, &req) if err != nil { log.Fatal(err) } log.Println(res) } ``` -------------------------------- ### GET /api/1/fee_info Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves fee information and 30-day trading volume for a specified currency pair. Requires Perm_R_Orders permission. ```APIDOC ## GET /api/1/fee_info ### Description Returns the fees and 30 day trading volume (as of midnight) for a given currency pair. ### Method GET ### Endpoint /api/1/fee_info ### Parameters #### Query Parameters - **pair** (string) - Required - The currency pair for which to retrieve fee information. ### Request Example ```json { "pair": "XBT/MYR" } ``` ### Response #### Success Response (200) - **delivery_fee_base** (string) - The base fee for delivery. - **delivery_fee_counter** (string) - The counter fee for delivery. - **delivery_fee_total** (string) - The total fee for delivery. - **fee_decimal** (integer) - The number of decimal places for fees. - **maker_fee** (string) - The maker fee rate. - **taker_fee** (string) - The taker fee rate. - **thirty_day_volume** (string) - The trading volume for the last 30 days. #### Response Example ```json { "delivery_fee_base": "0.00015 XBT", "delivery_fee_counter": "0.75 MYR", "delivery_fee_total": "0.00015 XBT", "fee_decimal": 8, "maker_fee": "0.00100000", "taker_fee": "0.00100000", "thirty_day_volume": "15000000000" } ``` ``` -------------------------------- ### GET /api/exchange/1/markets Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Lists all supported markets and their parameter information, such as price scale, minimum and maximum order volumes, and market IDs. ```APIDOC ## GET /api/exchange/1/markets ### Description Lists all supported markets and their parameter information. ### Method GET ### Endpoint /api/exchange/1/markets ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **markets** (array) - An array of market objects. - **market_currency** (string) - The trading pair currency. - **base_currency** (string) - The base currency. - **counter_currency** (string) - The counter currency. - **minimum_volume** (string) - The minimum order volume. - **maximum_volume** (string) - The maximum order volume. - **minimum_price** (string) - The minimum price for an order. - **maximum_price** (string) - The maximum price for an order. - **lot_size** (string) - The minimum tradable quantity. - **price_scale** (integer) - The number of decimal places for price. - **amount_scale** (integer) - The number of decimal places for amount. #### Response Example { "success": true, "markets": [ { "market_currency": "XBT/IDR", "base_currency": "XBT", "counter_currency": "IDR", "minimum_volume": "0.00010000", "maximum_volume": "100.00000000", "minimum_price": "100000", "maximum_price": "10000000000", "lot_size": "0.00000001", "price_scale": 2, "amount_scale": 8 } ] } ``` -------------------------------- ### Define Luno Get Balances Response Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Represents the response containing account balances for the requested assets. ```go type GetBalancesResponse struct Balance []AccountBalance ``` -------------------------------- ### Get Balances Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves the list of all Accounts and their respective balances for the requesting user. Requires Perm_R_Balance permission. ```APIDOC ## GET /api/1/balance ### Description The list of all Accounts and their respective balances for the requesting user. ### Method GET ### Endpoint `/api/1/balance` ### Parameters This endpoint does not require any parameters. ### Response #### Success Response (200) - **balance** (array) - An array of balance objects. - **asset** (string) - The currency of the balance. - **balance** (string) - The available balance in the smallest unit of the currency. - **reserved** (string) - The reserved balance in the smallest unit of the currency. - **total** (string) - The total balance (available + reserved) in the smallest unit of the currency. - **unavailable** (string) - The unavailable balance in the smallest unit of the currency. #### Response Example ```json { "balance": [ { "asset": "XBT", "balance": "1.23456789", "reserved": "0.00000000", "total": "1.23456789", "unavailable": "0.00000000" }, { "asset": "ZAR", "balance": "50000.00", "reserved": "1000.00", "total": "51000.00", "unavailable": "1000.00" } ] } ``` ``` -------------------------------- ### Define Luno Get Fee Info Response Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Represents the response containing fee information, including maker fee, taker fee, and 30-day volume. ```go type GetFeeInfoResponse struct MakerFee string TakerFee string ThirtyDayVolume string ``` -------------------------------- ### Get Fee Information - Go Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves fee information and 30-day trading volume for a specified currency pair using the Luno API. Requires Perm_R_Orders permission. ```go func (cl *Client) GetFeeInfo(ctx context.Context, req *GetFeeInfoRequest) (*GetFeeInfoResponse, error) { // Makes a call to GET /api/1/fee_info // Returns the fees and 30 day trading volume (as of midnight) for a given currency pair. // Permissions required: Perm_R_Orders return nil, nil } ``` -------------------------------- ### Client Initialization and Configuration Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Provides details on how to initialize and configure the Luno client, including setting authentication, base URL, timeouts, and debug modes. ```APIDOC ## Client Initialization and Configuration ### Description This section covers the essential methods for initializing and configuring the Luno client, enabling secure and customized interactions with the Luno API. ### Methods - **NewClient()** - **Description**: Creates a new instance of the Luno client. - **Endpoint**: N/A (Constructor) - **Request Body**: None - **Success Response**: Returns a pointer to a new `Client` object. - **SetAuth(apiKeyID, apiKeySecret string)** - **Description**: Sets the API key ID and secret for authentication. - **Endpoint**: N/A (Configuration) - **Parameters**: - **apiKeyID** (string) - Required - Your Luno API key ID. - **apiKeySecret** (string) - Required - Your Luno API key secret. - **Request Body**: None - **Success Response**: `nil` on success, or an error if authentication fails. - **SetBaseURL(baseURL string)** - **Description**: Sets the base URL for the Luno API. - **Endpoint**: N/A (Configuration) - **Parameters**: - **baseURL** (string) - Required - The base URL of the Luno API (e.g., "https://api.luno.com"). - **Request Body**: None - **Success Response**: None - **SetHTTPClient(httpClient *http.Client)** - **Description**: Sets a custom HTTP client for making requests. - **Endpoint**: N/A (Configuration) - **Parameters**: - **httpClient** (*http.Client) - Required - A custom `http.Client` instance. - **Request Body**: None - **Success Response**: None - **SetRateLimiter(rateLimiter Limiter)** - **Description**: Sets a custom rate limiter for controlling request frequency. - **Endpoint**: N/A (Configuration) - **Parameters**: - **rateLimiter** (Limiter) - Required - An implementation of the `Limiter` interface. - **Request Body**: None - **Success Response**: None - **SetTimeout(timeout time.Duration)** - **Description**: Sets the request timeout duration. - **Endpoint**: N/A (Configuration) - **Parameters**: - **timeout** (time.Duration) - Required - The duration after which requests will time out. - **Request Body**: None - **Success Response**: None - **SetDebug(debug bool)** - **Description**: Enables or disables debug logging. - **Endpoint**: N/A (Configuration) - **Parameters**: - **debug** (bool) - Required - Set to `true` to enable debug logging, `false` otherwise. - **Request Body**: None - **Success Response**: None ``` -------------------------------- ### Client Initialization and Withdrawal Methods (Go) Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Provides the constructor for creating a new Luno client and methods for canceling withdrawals. ```go func NewClient() *Client func (cl *Client) CancelWithdrawal(ctx context.Context, req *CancelWithdrawalRequest) (*CancelWithdrawalResponse, error) ``` -------------------------------- ### Define Luno Get Fee Info Request Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Represents the request to get fee information for a specific trading pair. ```go type GetFeeInfoRequest struct Pair string ``` -------------------------------- ### Define Luno Get Funding Address Request Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Represents the request to get a funding address, specifying the asset and optionally an address for association. ```go type GetFundingAddressRequest struct Address string Asset string ``` -------------------------------- ### Create Account Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Creates an Account for the specified currency. The balances for the Account will be displayed based on the `asset` value. Requires Perm_W_Addresses permission. ```APIDOC ## POST /api/1/accounts ### Description Creates an Account for the specified currency. Please note that the balances for the Account will be displayed based on the `asset` value, which is the currency the Account is based on. ### Method POST ### Endpoint `/api/1/accounts` ### Parameters #### Request Body - **asset** (string) - Required - The currency the account should be based on. ### Request Example ```json { "asset": "XBT" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the account. - **name** (string) - The name of the account. #### Response Example ```json { "id": "1234567890", "name": "My Bitcoin Account" } ``` ``` -------------------------------- ### Get Markets Information (Go) Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves information about all supported markets, including price scale and order volumes. It calls the GET /api/exchange/1/markets endpoint. Added in v0.0.16. ```go func (cl *Client) Markets(ctx context.Context, req *MarketsRequest) (*MarketsResponse, error) ``` -------------------------------- ### Get Candles API Call (Go) Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Makes a GET request to retrieve candlestick market data from Luno for a specified period. Requires GetCandlesRequest and has no specific permissions. ```go func (cl *Client) GetCandles(ctx context.Context, req *GetCandlesRequest) (*GetCandlesResponse, error) ``` -------------------------------- ### Get Withdrawal Information Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves details of a specific withdrawal using its ID. ```APIDOC ## GET /withdrawals/{id} ### Description Retrieves the details of a specific withdrawal request. ### Method GET ### Endpoint /withdrawals/{id} ### Parameters #### Path Parameters - **id** (int64) - Required - The ID of the withdrawal to retrieve. ### Response #### Success Response (200) - **amount** (decimal.Decimal) - The amount withdrawn. - **createdAt** (Time) - The Unix timestamp (in milliseconds) when the withdrawal was initiated. - **currency** (string) - The currency of the withdrawal. - **externalId** (string) - The external ID provided during the withdrawal request. - **fee** (decimal.Decimal) - The fee charged for the withdrawal. - **id** (string) - The unique identifier for the withdrawal. - **status** (Status) - The current status of the withdrawal. - **transferId** (string) - The identifier for the withdrawal's transfer upon completion. - **type** (string) - The type of withdrawal method used. #### Response Example ```json { "amount": "1.234", "createdAt": 1678886400000, "currency": "XBT", "externalId": "abc-123", "fee": "0.001", "id": "wd_12345", "status": "COMPLETED", "transferId": "tr_67890", "type": "BANK" } ``` ``` -------------------------------- ### Client Method: List Beneficiaries Response (Go) Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Handles the response from listing beneficiaries. It includes a slice of AddressMeta and a QrCodeUri. ```go type CreateFundingAddressResponse struct { AddressMeta []AddressMeta QrCodeUri string } type GetFundingAddressResponse struct { AddressMeta []AddressMeta QrCodeUri string } ``` -------------------------------- ### Create Luno API Client (Go) Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Initializes and returns a new Luno API client. This client is configured with the default base URL for the Luno API. ```go func NewClient() *Client ``` -------------------------------- ### GET /api/1/tickers Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves the latest ticker indicators from all active Luno exchanges. ```APIDOC ## GET /api/1/tickers ### Description Returns the latest ticker indicators from all active Luno exchanges. Please see the Currency list for the complete list of supported currency pairs. ### Method GET ### Endpoint /api/1/tickers ### Parameters #### Query Parameters - **currency** (string) - Optional - Filter tickers by a specific currency. ### Request Example ```json { "currency": "XBT" } ``` ### Response #### Success Response (200) - **tickers** (array) - An array of ticker information for active exchanges. - **pair** (string) - The currency pair. - **last_price** (string) - The last traded price. - **last_volume** (string) - The volume of the last trade. - **high** (string) - The highest price in the last 24 hours. - **low** (string) - The lowest price in the last 24 hours. - **currency** (string) - The currency of the ticker information. #### Response Example ```json { "tickers": [ { "pair": "XBT/ZAR", "last_price": "900000.00", "last_volume": "1.2", "high": "920000.00", "low": "880000.00", "currency": "ZAR" }, { "pair": "ETH/BTC", "last_price": "0.05", "last_volume": "10.5", "high": "0.052", "low": "0.048", "currency": "BTC" } ] } ``` ``` -------------------------------- ### GET /api/1/ticker Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves the latest ticker indicators for a specified currency pair. ```APIDOC ## GET /api/1/ticker ### Description Returns the latest ticker indicators for the specified currency pair. Please see the Currency list for the complete list of supported currency pairs. ### Method GET ### Endpoint /api/1/ticker ### Parameters #### Query Parameters - **pair** (string) - Required - The currency pair for which to retrieve ticker information. ### Request Example ```json { "pair": "ETH/MYR" } ``` ### Response #### Success Response (200) - **pair** (string) - The currency pair. - **last_price** (string) - The last traded price. - **last_volume** (string) - The volume of the last trade. - **high** (string) - The highest price in the last 24 hours. - **low** (string) - The lowest price in the last 24 hours. - **currency** (string) - The currency of the ticker information. #### Response Example ```json { "pair": "ETH/MYR", "last_price": "15000.00", "last_volume": "0.05", "high": "15500.00", "low": "14500.00", "currency": "MYR" } ``` ``` -------------------------------- ### Client: CreateAccount Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Creates a new account for the user. ```APIDOC ## POST /accounts ### Description Creates a new account for the user. ### Method POST ### Endpoint /accounts ### Parameters #### Request Body - **Name** (string) - Required - The name for the new account. - **Asset** (string) - Required - The asset type for the account (e.g., "XBT", "ZAR"). ### Request Example ```json { "Name": "Savings Account", "Asset": "XBT" } ``` ### Response #### Success Response (200) - **AccountId** (string) - The ID of the newly created account. - **Name** (string) - The name of the newly created account. - **Asset** (string) - The asset type of the account. - **Balance** (decimal.Decimal) - The initial balance of the account. - **Reserved** (decimal.Decimal) - The reserved balance for the account. - **Unconfirmed** (decimal.Decimal) - The unconfirmed balance for the account. #### Response Example ```json { "AccountId": "acc-12345", "Name": "Savings Account", "Asset": "XBT", "Balance": "0.00000000", "Reserved": "0.00000000", "Unconfirmed": "0.00000000" } ``` #### Error Handling - **400 Bad Request**: Invalid input, such as missing required fields or unsupported asset type. - **401 Unauthorized**: Authentication failed. - **409 Conflict**: An account with the same name and asset already exists. - **500 Internal Server Error**: Server-side error during account creation. ``` -------------------------------- ### Post Market Order API Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Places a market order on the Luno platform. A market order will be executed immediately at the best available market price. ```APIDOC ## POST /api/v2/orders/market ### Description Places a market order on the Luno platform. A market order will be executed immediately at the best available market price. ### Method POST ### Endpoint /api/v2/orders/market ### Parameters #### Request Body - **ClientOrderId** (string) - Optional - A unique identifier provided by the client for the order. - **Pair** (string) - Required - The trading pair (e.g., 'XBT/IDR'). - **Side** (Side) - Required - The side of the order ('BUY' or 'SELL'). - **Volume** (decimal.Decimal) - Required - The volume of the base currency to trade. - **Timestamp** (int64) - Required - Unix epoch time in milliseconds, used for request signing. - **Ttl** (int64) - Optional - Time To Live for the order in milliseconds. ### Request Example ```json { "ClientOrderId": "my-market-order-456", "Pair": "XBT/IDR", "Side": "SELL", "Volume": "0.0005", "Timestamp": 1678886400000, "Ttl": 3600000 } ``` ### Response #### Success Response (200) - **OrderId** (string) - The unique identifier of the placed order. - **Status** (Status) - The initial status of the order. #### Response Example ```json { "OrderId": "a0b1c2d3-e4f5-6789-0123-456789abcdef", "Status": "CREATED" } ``` ``` -------------------------------- ### Get Withdrawal API Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Retrieves details of a specific withdrawal using its ID. ```APIDOC ## GET /api/1/withdrawals ### Description Retrieves details of a specific withdrawal using its ID. ### Method GET ### Endpoint /api/1/withdrawals ### Parameters #### Query Parameters - **id** (string) - Required - The unique identifier of the withdrawal. ### Response #### Success Response (200) - **GetWithdrawalResponse** (GetWithdrawalResponse) - Details of the requested withdrawal. - **Amount** (decimal.Decimal) - The amount withdrawn. - **CreatedAt** (Time) - The timestamp when the withdrawal was created. - **Currency** (string) - The currency withdrawn. - **Fee** (decimal.Decimal) - The fee charged for the withdrawal. - **Id** (string) - The unique identifier of the withdrawal. - **Status** (string) - The current status of the withdrawal. - **Type** (string) - The type of withdrawal. #### Response Example ```json { "Amount": "0.50000000", "CreatedAt": "2018-05-10T11:00:00.000Z", "Currency": "XBT", "Fee": "0.00001000", "Id": "wd-12345", "Status": "COMPLETE", "Type": "STANDARD" } ``` ``` -------------------------------- ### Get Tickers API Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Retrieves ticker information for all available currency pairs. ```APIDOC ## GET /api/1/tickers ### Description Retrieves ticker information for all available currency pairs. ### Method GET ### Endpoint /api/1/tickers ### Response #### Success Response (200) - **GetTickersResponse** (GetTickersResponse) - A list of ticker information for all pairs. - **Tickers** ([]Ticker) - An array of ticker objects. #### Response Example ```json { "Tickers": [ { "Ask": "101.50000000", "Bid": "100.50000000", "LastTrade": "101.00000000", "Pair": "XBT/ZAR", "Rolling24HourVolume": "50.00000000", "Timestamp": 1525977000 }, { "Ask": "1200.00000000", "Bid": "1190.00000000", "LastTrade": "1195.00000000", "Pair": "ETH/XBT", "Rolling24HourVolume": "10.00000000", "Timestamp": 1525977000 } ] } ``` ``` -------------------------------- ### Decimal Constructors Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0.0.35/decimal Functions for creating new Decimal instances from various types. ```APIDOC ## Functions: Decimal Constructors ### Description Functions for creating new Decimal instances from various types. ### Functions - **New(i *big.Int, scale int) Decimal**: Creates a new Decimal from a big.Int and scale. - **NewFromFloat64(f float64, scale int) Decimal**: Creates a new Decimal from a float64 and scale. - **NewFromInt64(i int64) Decimal**: Creates a new Decimal from an int64. - **NewFromString(s string) (Decimal, error)**: Creates a new Decimal from a string. - **Zero() Decimal**: Returns a Decimal representing zero. ``` -------------------------------- ### Client: GetLightningReceive Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Generates a new Lightning Network receive request. ```APIDOC ## POST /lightning/receive ### Description Generates a new Lightning Network receive request. ### Method POST ### Endpoint /lightning/receive ### Parameters #### Request Body - **Amount** (decimal.Decimal) - Required - The amount to receive. - **Currency** (string) - Required - The currency of the amount. - **Description** (string) - Optional - A description for the payment. - **ExpiresAt** (Time) - Optional - The expiration time for the payment request. ### Request Example ```json { "Amount": "0.001", "Currency": "XBT", "Description": "Payment for service", "ExpiresAt": "2023-10-27T10:00:00Z" } ``` ### Response #### Success Response (200) - **PaymentRequest** (string) - The generated Lightning Network payment request. - **SettledAmount** (decimal.Decimal) - The amount that has been settled. - **Status** (string) - The status of the receive request. #### Response Example ```json { "PaymentRequest": "lnbc1pvjlz9hwv...", "SettledAmount": "0.001", "Status": "PENDING" } ``` #### Error Handling - **400 Bad Request**: Invalid input parameters. - **401 Unauthorized**: Authentication failed. - **500 Internal Server Error**: Server-side error during receive request generation. ``` -------------------------------- ### Get Order API Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Retrieves details of a specific order using its ID. ```APIDOC ## GET /api/1/orders ### Description Retrieves details of a specific order using its ID. ### Method GET ### Endpoint /api/1/orders ### Parameters #### Query Parameters - **id** (string) - Required - The unique identifier of the order. ### Response #### Success Response (200) - **Order** (Order) - Information about the requested order. #### Response Example ```json { "Order": { "Base": "1.00000000", "CompletedTimestamp": "2018-05-10T10:00:00.000Z", "Counter": "100.00000000", "CreationTimestamp": "2018-05-10T09:55:00.000Z", "ExpirationTimestamp": "2018-05-10T09:55:00.000Z", "FeeBase": "0.00010000", "FeeCounter": "0.10000000", "LimitPrice": "100.00000000", "LimitVolume": "1.00000000", "OrderId": "12345", "Pair": "XBT/ZAR", "State": "COMPLETE", "Type": "BUY" } } ``` ``` -------------------------------- ### Create Beneficiary Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Creates a new beneficiary. Requires Perm_W_Beneficiaries permission. ```APIDOC ## POST /api/1/beneficiaries ### Description Create a new beneficiary. ### Method POST ### Endpoint `/api/1/beneficiaries` ### Parameters #### Request Body - **name** (string) - Required - Name of the beneficiary. - **type** (string) - Required - Type of beneficiary (e.g., "EMAIL", "BITCOIN", "BANK"). - **account_number** (string) - Required for BANK type - Bank account number. - **bank_name** (string) - Required for BANK type - Name of the bank. - **bank_country** (string) - Required for BANK type - Country of the bank. - **swift_code** (string) - Optional for BANK type - SWIFT code. - **email** (string) - Required for EMAIL type - Email address of the beneficiary. - **bitcoin_address** (string) - Required for BITCOIN type - Bitcoin address of the beneficiary. ### Request Example ```json { "name": "John Doe", "type": "EMAIL", "email": "john.doe@example.com" } ``` ### Response #### Success Response (200) - **beneficiary_id** (string) - The unique identifier for the created beneficiary. #### Response Example ```json { "beneficiary_id": "b_xyz789" } ``` ``` -------------------------------- ### GET /api/1/orders/{id} Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves the details of an order by its ID. Requires Perm_R_Orders permission. ```APIDOC ## GET /api/1/orders/{id} ### Description Get an Order's details by its ID. ### Method GET ### Endpoint /api/1/orders/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the order. ### Request Example ```json { "id": "12345" } ``` ### Response #### Success Response (200) - **order_id** (string) - The unique identifier of the order. - **created_timestamp** (integer) - The timestamp when the order was created. - **state** (string) - The current state of the order. - **limit_price** (string) - The limit price of the order. - **limit_volume** (string) - The limit volume of the order. - **type** (string) - The type of the order (e.g., BID, ASK). - **price** (string) - The current price of the order. - **volume** (string) - The volume of the order. - **base** (string) - The base currency of the order. - **counter** (string) - The counter currency of the order. - **fee_base** (string) - The fee in the base currency. - **fee_counter** (string) - The fee in the counter currency. #### Response Example ```json { "order_id": "12345", "created_timestamp": 1678886400, "state": "COMPLETE", "limit_price": "10000.00", "limit_volume": "0.001", "type": "BID", "price": "10000.00", "volume": "0.001", "base": "BTC", "counter": "USD", "fee_base": "0.000001", "fee_counter": "0.01" } ``` ``` -------------------------------- ### Get Ticker API Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Retrieves the latest ticker information for a specified currency pair. ```APIDOC ## GET /api/1/ticker ### Description Retrieves the latest ticker information for a specified currency pair. ### Method GET ### Endpoint /api/1/ticker ### Parameters #### Query Parameters - **pair** (string) - Required - The currency pair (e.g., "XBT/ZAR"). ### Response #### Success Response (200) - **GetTickerResponse** (GetTickerResponse) - The latest ticker information. - **Ask** (decimal.Decimal) - The current ask price. - **Bid** (decimal.Decimal) - The current bid price. - **LastTrade** (decimal.Decimal) - The price of the last trade. - **Pair** (string) - The currency pair. - **Rolling24HourVolume** (decimal.Decimal) - The trading volume over the last 24 hours. - **Timestamp** (int64) - The Unix timestamp of the ticker data. #### Response Example ```json { "Ask": "101.50000000", "Bid": "100.50000000", "LastTrade": "101.00000000", "Pair": "XBT/ZAR", "Rolling24HourVolume": "50.00000000", "Timestamp": 1525977000 } ``` ``` -------------------------------- ### Client Account and Funding Operations (Go) Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Methods for managing Luno accounts, including creating accounts, funding addresses, quotes, and withdrawals. ```go func (cl *Client) CreateAccount(ctx context.Context, req *CreateAccountRequest) (*CreateAccountResponse, error) func (cl *Client) CreateFundingAddress(ctx context.Context, req *CreateFundingAddressRequest) (*CreateFundingAddressResponse, error) func (cl *Client) CreateQuote(ctx context.Context, req *CreateQuoteRequest) (*CreateQuoteResponse, error) func (cl *Client) CreateWithdrawal(ctx context.Context, req *CreateWithdrawalRequest) (*CreateWithdrawalResponse, error) ``` -------------------------------- ### GET /api/1/withdrawals Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves a list of withdrawal requests made by the user. Requires `Perm_R_Withdrawals` permission. ```APIDOC ## GET /api/1/withdrawals ### Description Retrieves a list of withdrawal requests. Requires `Perm_R_Withdrawals` permission. ### Method GET ### Endpoint /api/1/withdrawals ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **withdrawals** (array) - An array of withdrawal objects. - **withdrawal_id** (string) - Unique identifier for the withdrawal. - **currency** (string) - The currency being withdrawn. - **amount** (object) - The amount withdrawn. - **amount** (string) - The numeric amount. - **currency** (string) - The currency of the amount. - **fee** (object) - The fee charged for the withdrawal. - **amount** (string) - The numeric fee amount. - **currency** (string) - The currency of the fee. - **state** (string) - The current state of the withdrawal (e.g., 'pending', 'completed', 'failed'). - **created_at** (string) - Timestamp when the withdrawal was created. - **funds_moved** (boolean) - Indicates if the funds have been moved. #### Response Example { "success": true, "withdrawals": [ { "withdrawal_id": "wd-12345", "currency": "XBT", "amount": { "amount": "0.001", "currency": "XBT" }, "fee": { "amount": "0.00001", "currency": "XBT" }, "state": "completed", "created_at": "2022-01-01T11:00:00Z", "funds_moved": true } ] } ``` -------------------------------- ### Define Luno Account Creation Request Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Represents the request structure for creating a new Luno account. It includes fields for the account name and currency. ```go type CreateAccountRequest struct Currency string Name string ``` -------------------------------- ### GET /api/exchange/2/orders/{id} Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go Retrieves the details for an order using its ID. Requires Perm_R_Orders permission. ```APIDOC ## GET /api/exchange/2/orders/{id} ### Description Get the details for an order. ### Method GET ### Endpoint /api/exchange/2/orders/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the order. ### Request Example ```json { "id": "order_abc" } ``` ### Response #### Success Response (200) - **order_id** (string) - The unique identifier of the order. - **status** (string) - The status of the order. - **currency_pair** (string) - The currency pair of the order. - **limit_price** (string) - The limit price of the order. - **limit_volume** (string) - The limit volume of the order. - **base** (string) - The base currency. - **counter** (string) - The counter currency. #### Response Example ```json { "order_id": "order_abc", "status": "PENDING", "currency_pair": "BTC/EUR", "limit_price": "40000.00", "limit_volume": "0.002", "base": "BTC", "counter": "EUR" } ``` ``` -------------------------------- ### Client: CreateQuote Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Creates a currency exchange quote. ```APIDOC ## POST /quotes ### Description Creates a currency exchange quote. ### Method POST ### Endpoint /quotes ### Parameters #### Request Body - **Base** (string) - Required - The base currency for the quote (e.g., "XBT"). - **Counter** (string) - Required - The counter currency for the quote (e.g., "ZAR"). - **Limit_price** (string) - Optional - The limit price for the quote. - **Volume** (string) - Optional - The volume for the quote. ### Request Example ```json { "Base": "XBT", "Counter": "ZAR", "Limit_price": "50000.00", "Volume": "0.01" } ``` ### Response #### Success Response (200) (The response structure for `CreateQuoteResponse` is not detailed in the provided documentation. Typically, it would include quote details like rate, expiry, etc.) #### Response Example ```json { "QuoteId": "quote-abc-789", "Rate": "50000.00", "ExpiresAt": "2023-10-27T14:00:00Z" } ``` #### Error Handling - **400 Bad Request**: Invalid currency pair or parameters. - **401 Unauthorized**: Authentication failed. - **500 Internal Server Error**: Server-side error during quote creation. ``` -------------------------------- ### Client: CreateWithdrawal Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Initiates a withdrawal of funds. ```APIDOC ## POST /withdrawals ### Description Initiates a withdrawal of funds. ### Method POST ### Endpoint /withdrawals ### Parameters #### Request Body - **Amount** (decimal.Decimal) - Required - The amount to withdraw. - **Currency** (string) - Required - The currency of the amount. - **Withdrawal_type** (string) - Required - The type of withdrawal (e.g., "BANK", "EXTERNAL"). - **ExternalId** (string) - Optional - An external identifier for the withdrawal. - **BeneficiaryId** (string) - Optional - The ID of the beneficiary for bank transfers. - **Address** (string) - Optional - The external address for crypto withdrawals. - **DestinationTag** (int64) - Optional - The destination tag for certain crypto withdrawals. - **HasDestinationTag** (bool) - Optional - Indicates if a destination tag is provided. ### Request Example ```json { "Amount": "0.05", "Currency": "XBT", "Withdrawal_type": "EXTERNAL", "Address": "some-external-btc-address", "ExternalId": "my-withdrawal-ref" } ``` ### Response #### Success Response (200) - **ExternalId** (string) - The external ID of the withdrawal request. - **Id** (string) - The unique ID of the withdrawal. - **Amount** (decimal.Decimal) - The withdrawn amount. - **Currency** (string) - The currency of the withdrawal. - **Fee** (decimal.Decimal) - The fee charged for the withdrawal. - **CreatedAt** (Time) - The timestamp when the withdrawal was created. - **Status** (string) - The status of the withdrawal. - **Type** (string) - The type of withdrawal. #### Response Example ```json { "ExternalId": "my-withdrawal-ref", "Id": "wdrl-12345", "Amount": "0.05", "Currency": "XBT", "Fee": "0.0001", "CreatedAt": "2023-10-27T15:00:00Z", "Status": "PENDING", "Type": "EXTERNAL" } ``` #### Error Handling - **400 Bad Request**: Invalid input, insufficient balance, or invalid withdrawal type/details. - **401 Unauthorized**: Authentication failed. - **404 Not Found**: Beneficiary or other specified resource not found. - **500 Internal Server Error**: Server-side error during withdrawal initiation. ``` -------------------------------- ### Get Quote API Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Requests a quote for a currency pair, specifying the amount and type of transaction. ```APIDOC ## POST /api/1/get_quote ### Description Requests a quote for a currency pair, specifying the amount and type of transaction. ### Method POST ### Endpoint /api/1/get_quote ### Parameters #### Request Body - **GetQuoteRequest** (GetQuoteRequest) - Required - The quote request details. - **Id** (string) - Required - The unique identifier for the quote request. ### Response #### Success Response (200) - **GetQuoteResponse** (GetQuoteResponse) - Details of the requested quote. - **BaseAmount** (decimal.Decimal) - The amount of the base currency. - **CounterAmount** (decimal.Decimal) - The amount of the counter currency. - **CreatedAt** (Time) - The timestamp when the quote was created. - **Discarded** (bool) - Indicates if the quote has been discarded. - **Exercised** (bool) - Indicates if the quote has been exercised. - **ExpiresAt** (Time) - The timestamp when the quote expires. - **Id** (string) - The unique identifier of the quote. - **Pair** (string) - The currency pair for the quote. - **Type** (string) - The type of quote (e.g., BUY, SELL). #### Response Example ```json { "BaseAmount": "100.00000000", "CounterAmount": "0.01000000", "CreatedAt": "2018-05-10T10:05:00.000Z", "Discarded": false, "Exercised": false, "ExpiresAt": "2018-05-10T10:10:00.000Z", "Id": "quote-123", "Pair": "XBT/ZAR", "Type": "BUY" } ``` ``` -------------------------------- ### Define Luno Account Creation Response Source: https://pkg.go.dev/github.com/luno/luno-go@v0.0.35/github.com/luno/luno-go%40v0 Represents the response structure after successfully creating a Luno account. It includes account details, balances, and capabilities. ```go type CreateAccountResponse struct Balance AccountBalance Capabilities AccountCapabilities Currency string Icon string Id string IsDefault bool Name string Pending []Transaction ReceiveAddresses []ReceiveAddress Transactions []Transaction ```