### Install Plisio Python SDK Source: https://github.com/plisio/plisio-python/blob/main/README.md Instructions for installing the Plisio SDK using pip. This is the primary method for adding the SDK to your Python project. ```sh pip install plisio ``` -------------------------------- ### Get Currencies Source: https://context7.com/plisio/plisio-python/llms.txt Fetch the list of supported cryptocurrencies with their current exchange rates against a specified fiat currency. Defaults to USD. ```APIDOC ## Get Currencies Fetch the list of supported cryptocurrencies with their current exchange rates against a specified fiat currency. Defaults to USD if no fiat currency is specified. ### Method `client.get_currencies(fiat_currency: FiatCurrency = FiatCurrency.USD)` ### Endpoint N/A (Handled by SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Get rates in USD (default) currencies = client.get_currencies() # Get rates in Australian Dollar currencies = client.get_currencies(plisio.FiatCurrency.AUD) for currency in currencies: print(f"{currency.currency.name}: {currency.fiat_rate} {currency.fiat.name}") print(f" USD Rate: {currency.rate_usd}") print(f" Min Amount: {currency.min_sum_in}") print(f" Invoice Commission: {currency.invoice_commission_percentage}%") ``` ### Response #### Success Response (200) - **currency** (CryptoCurrency) - The cryptocurrency symbol. - **fiat** (FiatCurrency) - The fiat currency symbol. - **fiat_rate** (str) - The exchange rate against the specified fiat currency. - **rate_usd** (str) - The exchange rate against USD. - **min_sum_in** (str) - The minimum amount for incoming transactions. - **invoice_commission_percentage** (str) - The commission percentage for invoices. #### Response Example ```json [ { "currency": "BTC", "fiat": "USD", "fiat_rate": "60000.00", "rate_usd": "60000.00", "min_sum_in": "0.0001", "invoice_commission_percentage": "0.5" } ] ``` ``` -------------------------------- ### Get Fee Plans Source: https://context7.com/plisio/plisio-python/llms.txt Retrieve available fee plans for a specific cryptocurrency with their current rates and confirmation targets. ```APIDOC ## Get Fee Plans Retrieve available fee plans for a specific cryptocurrency with their current rates and confirmation targets. ### Method GET ### Endpoint /get_fee_plan ### Parameters #### Query Parameters - **currency** (CryptoCurrency) - Required - The cryptocurrency for which to retrieve fee plans. ### Response #### Success Response (200) - **currency** (CryptoCurrency) - The cryptocurrency for which the fee plans are provided. - **economy** (object) - Details for the economy fee plan. - **conf_target** (int) - The confirmation target in blocks. - **fee_rate** (float) - The fee rate for this plan. - **normal** (object) - Details for the normal fee plan. - **conf_target** (int) - The confirmation target in blocks. - **fee_rate** (float) - The fee rate for this plan. - **priority** (object) - Details for the priority fee plan. - **conf_target** (int) - The confirmation target in blocks. - **fee_rate** (float) - The fee rate for this plan. ### Response Example ```json { "currency": "BTC", "economy": {"conf_target": 6, "fee_rate": 10.5}, "normal": {"conf_target": 3, "fee_rate": 20.2}, "priority": {"conf_target": 1, "fee_rate": 35.0} } ``` ``` -------------------------------- ### Get Operations Source: https://context7.com/plisio/plisio-python/llms.txt List all transactions with optional filtering by type, status, currency, and pagination. ```APIDOC ## Get Operations List all transactions with optional filtering by type, status, currency, and pagination. ### Method GET ### Endpoint /get_operations ### Parameters #### Query Parameters - **page** (int) - Optional - The page number for pagination. Defaults to 1. - **limit** (int) - Optional - The number of operations per page. Defaults to 20. - **type_** (OperationType) - Optional - Filter by operation type (e.g., `invoice`, `cash_out`). - **status** (OperationStatus) - Optional - Filter by operation status (e.g., `completed`, `pending`). - **currency** (CryptoCurrency) - Optional - Filter by cryptocurrency. - **search** (str) - Optional - Search term for transaction ID or order number. ### Response #### Success Response (200) - **meta** (object) - Metadata about the operations list (e.g., total count). - **operations** (list[object]) - A list of operation objects. - **id** (str) - The unique operation ID. - **type** (str) - The type of operation. - **status** (str) - The status of the operation. - **currency** (str) - The cryptocurrency used. - **amount** (float) - The amount of the operation. - **fee** (float) - The fee charged for the operation. - **created_at_utc** (str) - The timestamp when the operation was created. ### Response Example ```json { "meta": {"total": 100, "page": 1, "limit": 20}, "operations": [ { "id": "64d1df01224bd682be0c12c4", "type": "invoice", "status": "completed", "currency": "BTC", "amount": 0.01, "fee": 0.00005, "created_at_utc": "2023-08-15T10:00:00Z" } ] } ``` ``` -------------------------------- ### Get Supported Currencies and Rates (Python) Source: https://context7.com/plisio/plisio-python/llms.txt Fetch a list of supported cryptocurrencies, including their current exchange rates against a specified fiat currency (defaults to USD). Provides details like minimum amounts and commission percentages. ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Get rates in USD (default) currencies = client.get_currencies() # Get rates in Australian Dollar currencies = client.get_currencies(plisio.FiatCurrency.AUD) for currency in currencies: print(f"{currency.currency.name}: {currency.fiat_rate} {currency.fiat.name}") print(f" USD Rate: {currency.rate_usd}") print(f" Min Amount: {currency.min_sum_in}") print(f" Invoice Commission: {currency.invoice_commission_percentage}%") # Get rates in Euro eur_rates = client.get_currencies(plisio.FiatCurrency.EUR) ``` -------------------------------- ### Create Plisio Invoice with Amount and Email (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md This example shows how to create a Plisio invoice specifying the cryptocurrency, order details, a specific amount, and an email address for notifications. It utilizes the 'amount' and 'email' optional parameters. ```python import plisio # Example: using cryptocurrency second_invoice = plisio.invoice( plisio.CryptoCurrency.TRX, 'order2', 20230903182402, amount=100, email='test@plisio.net' ) ``` -------------------------------- ### Get Currency Exchange Rates Source: https://github.com/plisio/plisio-python/blob/main/README.md Illustrates how to fetch current exchange rates for supported cryptocurrencies against a specified fiat currency. Defaults to USD if no fiat currency is provided. ```python currencies = client.get_currencies(plisio.FiatCurrency.AUD) ``` -------------------------------- ### Get Commission Source: https://context7.com/plisio/plisio-python/llms.txt Estimate the cryptocurrency network fee and Plisio commission for a withdrawal operation before executing it. ```APIDOC ## Get Commission Estimate the cryptocurrency network fee and Plisio commission for a withdrawal operation before executing it. ### Method GET ### Endpoint /get_commission ### Parameters #### Query Parameters - **crypto_currency** (CryptoCurrency) - Required - The cryptocurrency for which to estimate the commission. - **addresses** (list[str]) - Optional - A list of recipient addresses for batch operations. - **amounts** (list[float]) - Optional - A list of amounts corresponding to the addresses for batch operations. - **type_** (OperationType) - Optional - The type of operation (e.g., `cash_out`, `mass_cash_out`). Defaults to `cash_out`. - **fee_plan** (PlanName) - Optional - The desired fee plan (e.g., `economy`, `normal`, `priority`). Defaults to `normal`. ### Response #### Success Response (200) - **commission** (float) - The Plisio commission amount. - **fee** (float) - The estimated network transaction fee. - **max_amount** (float) - The maximum amount that can be withdrawn. - **plan** (str) - The name of the fee plan used for the estimate. - **plans** (object) - An object containing available fee plan details if requested. - **economy** (object) - Details for the economy fee plan. - **normal** (object) - Details for the normal fee plan. - **priority** (object) - Details for the priority fee plan. ### Response Example ```json { "commission": 0.0001, "fee": 0.0005, "max_amount": 10.0, "plan": "normal", "plans": { "economy": {"conf_target": 6, "fee_rate": 10}, "normal": {"conf_target": 3, "fee_rate": 20}, "priority": {"conf_target": 1, "fee_rate": 30} } } ``` ``` -------------------------------- ### Get Cryptocurrency Balance Source: https://github.com/plisio/plisio-python/blob/main/README.md Shows how to retrieve the balance for a specific cryptocurrency using the PlisioClient. Supports multiple cryptocurrencies as listed in Plisio documentation. ```python balance = client.get_balance(plisio.CryptoCurrency.ETH) ``` -------------------------------- ### Create Plisio Invoice with Fiat Currency Details (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md This example illustrates creating a Plisio invoice using fiat currency details. It includes source currency, source rate, and a list of allowed cryptocurrencies for payment, omitting direct cryptocurrency amount. ```python import plisio # Example: using fiat currency third_invoice = plisio.invoice( plisio.CryptoCurrency.TRX, 'order3', 20230903182403, source_currency=plisio.FiatCurrency.USD, source_rate=10.2, allowed_currencies=[plisio.CryptoCurrency.TRX,plisio.CryptoCurrency.USDT_TRX] ) ``` -------------------------------- ### Create Plisio Invoice with Required Fields (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md This example demonstrates how to create a new Plisio invoice using only the mandatory parameters: currency, order name, and order number. It assumes the Plisio library and necessary enums like CryptoCurrency are imported. ```python import plisio # Example: using required fields only first_invoice = plisio.invoice(plisio.CryptoCurrency.BTC, 'order1', 20230903182401, 0.00001) ``` -------------------------------- ### Get Balance Source: https://context7.com/plisio/plisio-python/llms.txt Retrieve the balance for a specific cryptocurrency in your Plisio wallet. Returns a Balance model containing the available and locked balance. ```APIDOC ## Get Balance Retrieve the balance for a specific cryptocurrency in your Plisio wallet. Returns a Balance model containing the available balance and any locked balance. ### Method `client.get_balance(currency: CryptoCurrency)` `await async_client.get_balance(currency: CryptoCurrency)` ### Endpoint N/A (Handled by SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Get Bitcoin balance balance = client.get_balance(plisio.CryptoCurrency.BTC) print(f"Currency: {balance.currency}") print(f"Available: {balance.balance}") print(f"Locked: {balance.locked_balance}") # Async version async def get_balance_async(): async_client = plisio.PlisioAioClient(api_key='your_secret_key') balance = await async_client.get_balance(plisio.CryptoCurrency.ETH) return balance ``` ### Response #### Success Response (200) - **currency** (CryptoCurrency) - The cryptocurrency symbol. - **balance** (str) - The available balance. - **locked_balance** (str) - The locked balance. #### Response Example ```json { "currency": "BTC", "balance": "0.05", "locked_balance": "0.01" } ``` ``` -------------------------------- ### Get All Transactions (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md Fetches a list of all transactions with optional filtering and pagination parameters. It returns an Operations model containing transaction data and pagination links. ```python operations = plisio.get_operations( page=1, limit=10, shop_id='your_shop_id', type_='cash_in', status='completed', currency='ETH', search='txid_or_order_or_email' ) ``` -------------------------------- ### Get Currencies Asynchronously (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md Asynchronously retrieves a list of supported currencies for a given fiat currency. This method is part of the PlisioAioClient for use in async functions. ```python import plisio client = plisio.PlisioAioClient('your_secret_key') currencies = await client.get_currencies(plisio.FiatCurrency.AUD) ``` -------------------------------- ### Get Operation by ID Source: https://context7.com/plisio/plisio-python/llms.txt Retrieve detailed information about a specific transaction by its internal Plisio operation ID. ```APIDOC ## Get Operation by ID Retrieve detailed information about a specific transaction by its internal Plisio operation ID. ### Method GET ### Endpoint /get_operation/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The unique Plisio operation ID. ### Response #### Success Response (200) - **id** (str) - The unique operation ID. - **type** (str) - The type of operation. - **status** (str) - The status of the operation. - **currency** (str) - The cryptocurrency used. - **amount** (float) - The amount of the operation. - **fee** (float) - The fee charged for the operation. - **created_at_utc** (str) - The timestamp when the operation was created. ### Response Example ```json { "id": "64d1df01224bd682be0c12c4", "type": "invoice", "status": "completed", "currency": "BTC", "amount": 0.01, "fee": 0.00005, "created_at_utc": "2023-08-15T10:00:00Z" } ``` ``` -------------------------------- ### Validate Plisio Callback Data (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md This example demonstrates how to validate incoming callback data from Plisio using the PlisioClient. It requires an API key and the raw request body. Ensure 'json=true' is appended to your callback URL for JSON data. ```python import plisio # Assuming 'request.body' contains the raw callback data client = plisio.PlisioClient(api_key='your_secret_key') isValid = client.validate_callback(request.body) ``` -------------------------------- ### Get Fee Plan by Cryptocurrency (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md Retrieves the fee plan for a specified cryptocurrency. This function requires the plisio library and a valid cryptocurrency enum value. ```python import plisio fee = plisio.get_fee_plan( plisio.CryptoCurrency.ETH ) ``` -------------------------------- ### Get Cryptocurrency Balance (Python) Source: https://context7.com/plisio/plisio-python/llms.txt Retrieve the available and locked balance for a specified cryptocurrency in your Plisio wallet. Supports both synchronous and asynchronous client methods. ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Get Bitcoin balance balance = client.get_balance(plisio.CryptoCurrency.BTC) print(f"Currency: {balance.currency}") print(f"Available: {balance.balance}") print(f"Locked: {balance.locked_balance}") # Get Ethereum balance eth_balance = client.get_balance(plisio.CryptoCurrency.ETH) # Async version async def get_balance_async(): async_client = plisio.PlisioAioClient(api_key='your_secret_key') balance = await async_client.get_balance(plisio.CryptoCurrency.ETH) return balance ``` -------------------------------- ### Get Specific Transaction by ID (Python) Source: https://github.com/plisio/plisio-python/blob/main/README.md Retrieves details for a single transaction using its unique ID. This function returns an Operation model with comprehensive information about the transaction. ```python operation = plisio.get_operation('operation_id') ``` -------------------------------- ### Initialize Plisio Client Connection Source: https://github.com/plisio/plisio-python/blob/main/README.md Demonstrates how to create an instance of the PlisioClient class, which is necessary for making API calls. Requires your personal Plisio API key. ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') ``` -------------------------------- ### Initialize Plisio Client (Python) Source: https://context7.com/plisio/plisio-python/llms.txt Instantiate the PlisioClient for synchronous API calls or PlisioAioClient for asynchronous operations using your API key. The client handles authentication and data parsing. ```python import plisio # Synchronous client client = plisio.PlisioClient(api_key='your_secret_key') # Async client for use with asyncioasync_client = plisio.PlisioAioClient(api_key='your_secret_key') ``` -------------------------------- ### Client Initialization Source: https://context7.com/plisio/plisio-python/llms.txt Initialize the PlisioClient or PlisioAioClient with your API key to authenticate requests. The client handles signing and parsing automatically. ```APIDOC ## Client Initialization Create a PlisioClient instance with your API key to authenticate all subsequent API requests. The client handles request signing and response parsing automatically. ### Method `PlisioClient(api_key='your_secret_key')` for synchronous operations. `PlisioAioClient(api_key='your_secret_key')` for asynchronous operations using `asyncio`. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import plisio # Synchronous client client = plisio.PlisioClient(api_key='your_secret_key') # Async client for use with asyncio async_client = plisio.PlisioAioClient(api_key='your_secret_key') ``` ### Response No direct response from initialization, but the client object is ready for use. #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Asynchronous Invoice Creation and Balance Check in Python Source: https://context7.com/plisio/plisio-python/llms.txt This asynchronous Python code snippet uses the PlisioAioClient to create an invoice and check a cryptocurrency balance. It's designed for integration with asyncio-based applications, demonstrating non-blocking operations. ```python import asyncio import plisio async def process_payment(): client = plisio.PlisioAioClient(api_key='your_secret_key') # Create invoice asynchronously invoice = await client.invoice( currency=plisio.CryptoCurrency.ETH, order_name='Async Order', order_number=99999, amount=0.01 ) print(f"Invoice created: {invoice.invoice_url}") # Check balance asynchronously balance = await client.get_balance(plisio.CryptoCurrency.ETH) print(f"Balance: {balance.balance}") # Get operations asynchronously operations = await client.get_operations(limit=10) for op in operations.operations: print(f"{op.id}: {op.status}") return invoice # Run async function invoice = asyncio.run(process_payment()) ``` -------------------------------- ### Create Invoice Source: https://context7.com/plisio/plisio-python/llms.txt Create a new payment invoice for accepting cryptocurrency payments. Supports specifying amounts in either cryptocurrency or fiat currency with automatic conversion. ```APIDOC ## Create Invoice Create a new payment invoice for accepting cryptocurrency payments. Supports specifying amounts in either cryptocurrency or fiat currency with automatic conversion. ### Method `client.create_invoice(...)` ### Endpoint N/A (Handled by SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **currency** (CryptoCurrency) - Required - The cryptocurrency to receive payment in. - **order_name** (str) - Required - A name for the order. - **order_number** (int or str) - Required - A unique order number. - **amount** (float) - Optional - The amount in the specified `currency`. - **source_currency** (FiatCurrency) - Optional - The fiat currency of the `source_amount`. - **source_amount** (float) - Optional - The amount in the specified `source_currency`. - **callback_url** (str) - Optional - URL for receiving payment status updates. - **email** (str) - Optional - Customer's email address. - **expire_min** (int) - Optional - Invoice expiration time in minutes. - **allowed_currencies** (list[CryptoCurrency]) - Optional - List of cryptocurrencies accepted for this invoice. - **description** (str) - Optional - A description for the invoice. ### Request Example ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Basic invoice with cryptocurrency amount invoice = client.create_invoice( currency=plisio.CryptoCurrency.BTC, order_name='Premium Subscription', order_number=12345, amount=0.001 ) print(f"Invoice URL: {invoice.invoice_url}") print(f"Transaction ID: {invoice.txn_id}") # Invoice with fiat currency conversion (10 USD) invoice = client.create_invoice( currency=plisio.CryptoCurrency.ETH, order_name='Product Purchase', order_number=12346, source_currency=plisio.FiatCurrency.USD, source_amount=10.00, callback_url='https://yoursite.com/callback?json=true', email='customer@example.com', expire_min=60 # Invoice expires in 60 minutes ) print(f"Amount in ETH: {invoice.amount}") print(f"QR Code: {invoice.qr_code}") # Invoice with multiple allowed cryptocurrencies invoice = client.create_invoice( currency=plisio.CryptoCurrency.TRX, order_name='Donation', order_number=12347, source_currency=plisio.FiatCurrency.USD, source_amount=25.00, allowed_currencies=[ plisio.CryptoCurrency.TRX, plisio.CryptoCurrency.USDT_TRX, plisio.CryptoCurrency.ETH ], description='Thank you for your support!' ) ``` ### Response #### Success Response (200) - **invoice_url** (str) - The URL to the payment invoice. - **txn_id** (str) - The unique transaction ID for the invoice. - **amount** (str) - The final amount in the specified cryptocurrency. - **currency** (CryptoCurrency) - The cryptocurrency for the payment. - **qr_code** (str) - A QR code for the payment address and amount. #### Response Example ```json { "status": "success", "data": { "invoice_url": "https://pay.plisio.net/invoice/abc123xyz", "txn_id": "inv_abc123xyz", "amount": "0.00005", "currency": "BTC", "qr_code": "bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?amount=0.00005" } } ``` ``` -------------------------------- ### Creating a New Invoice Source: https://github.com/plisio/plisio-python/blob/main/README.md This endpoint allows merchants to create new invoices for cryptocurrency payments. It supports both direct cryptocurrency amounts and fiat currency conversions. ```APIDOC ## POST /api/v1/invoice ### Description Creates a new invoice for a cryptocurrency payment. Supports direct crypto amounts or conversion from fiat currency. ### Method POST ### Endpoint /api/v1/invoice ### Parameters #### Query Parameters - **currency** (string) - Required - The name of the cryptocurrency (e.g., BTC, ETH). - **order_name** (string) - Required - Merchant's internal order name. - **order_number** (string) - Required - Merchant's internal order number. - **amount** (float) - Optional - The amount in the specified cryptocurrency. If converting from fiat, skip this and use `source_currency` and `source_amount`. - **source_currency** (string) - Optional - The name of the fiat currency (e.g., USD, EUR). - **source_amount** (float) - Optional - The amount in the source fiat currency. - **allowed_psys_cids** (string) - Optional - Comma-separated list of allowed cryptocurrency IDs for payment (e.g., 'BTC,ETH,TZEC'). - **description** (string) - Optional - A description for the invoice. - **callback_url** (string) - Optional - The merchant's URL to receive invoice updates via POST request. If not provided, uses the 'Status URL' from profile settings. Append '?json=true' for JSON data. - **email** (string) - Optional - An email address for invoice notifications. - **language** (string) - Optional - The language for the invoice (e.g., 'en_US'). Currently supports English only. - **plugin** (string) - Optional - Plisio's internal field to determine the integration plugin. - **version** (string) - Optional - Plisio's internal field to determine the integration plugin version. - **redirect_to_invoice** (boolean) - Optional - If true, redirects the user to the Plisio invoice page instead of returning a JSON response (not applicable for white-label shops). - **expire_min** (integer) - Optional - The interval in minutes after which the invoice will expire. ### Request Example ```json { "currency": "BTC", "order_name": "Example Order", "order_number": "ORD12345", "amount": 0.0001, "description": "Test invoice", "callback_url": "https://yourdomain.com/callback?json=true", "email": "test@example.com" } ``` ### Response #### Success Response (200) - **txn_id** (string) - Plisio's internal transaction ID. - **invoice_url** (string) - The URL of the created invoice. - **amount** (float) - Invoice amount in the selected cryptocurrency (if not white-label). - **pending_amount** (float) - Remaining amount to be paid (if not white-label). - **wallet_hash** (string) - Invoice wallet hash (if not white-label). - **psys_cid** (string) - Cryptocurrency ID (if not white-label). - **currency** (string) - Cryptocurrency code (if not white-label). - **source_currency** (string) - Fiat currency used (if applicable, if not white-label). - **source_rate** (float) - Exchange rate at the time of transfer (if not white-label). - **expected_confirmations** (integer) - Number of confirmations needed (if not white-label). - **qr_code** (string) - QR code image in base64 format (if not white-label). - **verify_hash** (string) - Hash to verify POST data signed with API_KEY (if not white-label). - **invoice_commission** (float) - Plisio commission (if not white-label). - **invoice_sum** (float) - Invoice amount minus commission (if shop pays) or invoice amount (if client pays) (if not white-label). - **invoice_total_sum** (float) - Invoice amount (if shop pays) or commission + invoice sum (if client pays) (if not white-label). #### Response Example (White-label) ```json { "txn_id": "plisio_txn_12345", "invoice_url": "https://plisio.net/invoice/xyz789" } ``` #### Response Example (Standard) ```json { "txn_id": "plisio_txn_12345", "invoice_url": "https://plisio.net/invoice/xyz789", "amount": 0.0001, "pending_amount": 0.0001, "wallet_hash": "1A2b3C4d5E6f7G8h9I0jK1lM2nO3pQ4r", "psys_cid": "1", "currency": "BTC", "source_currency": "USD", "source_rate": 30000.00, "expected_confirmations": 3, "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", "verify_hash": "abcdef1234567890", "invoice_commission": 0.000001, "invoice_sum": 0.000099, "invoice_total_sum": 0.0001 } ``` ``` -------------------------------- ### Retrieve Available Fee Plans - Python Source: https://context7.com/plisio/plisio-python/llms.txt Retrieves the available fee plans for a specific cryptocurrency, including their current rates and confirmation targets. It allows users to check options like 'economy', 'normal', and 'priority' for different cryptocurrencies. ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Get fee plans for Bitcoin fee_plan = client.get_fee_plan(plisio.CryptoCurrency.BTC) print(f"Currency: {fee_plan.currency}") if fee_plan.economy: print(f"Economy - Conf Target: {fee_plan.economy.conf_target} blocks") print(f"Economy - Fee Rate: {fee_plan.economy.fee_rate}") if fee_plan.normal: print(f"Normal - Conf Target: {fee_plan.normal.conf_target} blocks") if fee_plan.priority: print(f"Priority - Conf Target: {fee_plan.priority.conf_target} blocks") # Get fee plans for Ethereum eth_plans = client.get_fee_plan(plisio.CryptoCurrency.ETH) ``` -------------------------------- ### Estimate Fee using Plisio Python SDK Source: https://github.com/plisio/plisio-python/blob/main/README.md The `get_fee` method estimates transaction fees for cryptocurrencies. It requires the cryptocurrency symbol and optionally accepts addresses, amounts, and a fee plan. The response includes the estimated fee, currency, and the fee plan used. ```python fee = plisio.get_fee( plisio.CryptoCurrency.ETH, 'wallet_address', 'amount', 'normal', ) ``` -------------------------------- ### Estimate Commission using Plisio Python SDK Source: https://github.com/plisio/plisio-python/blob/main/README.md The `get_commission` method estimates cryptocurrency fees and Plisio commissions. It requires the cryptocurrency symbol and accepts optional parameters for addresses, amounts, operation type, fee plan, and custom fee rate. It returns a Commission model with details on commission, fee, max amount, plan, and more. ```python commission = plisio.get_commission( plisio.CryptoCurrency.ETH ) ``` -------------------------------- ### Create Payment Invoice (Python) Source: https://context7.com/plisio/plisio-python/llms.txt Generate a new payment invoice for accepting cryptocurrency. Supports specifying amounts in either crypto or fiat currency, with options for callback URLs, expiration times, and multiple allowed cryptocurrencies. ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Basic invoice with cryptocurrency amount invoice = client.create_invoice( currency=plisio.CryptoCurrency.BTC, order_name='Premium Subscription', order_number=12345, amount=0.001 ) print(f"Invoice URL: {invoice.invoice_url}") print(f"Transaction ID: {invoice.txn_id}") # Invoice with fiat currency conversion (10 USD) invoice = client.create_invoice( currency=plisio.CryptoCurrency.ETH, order_name='Product Purchase', order_number=12346, source_currency=plisio.FiatCurrency.USD, source_amount=10.00, callback_url='https://yoursite.com/callback?json=true', email='customer@example.com', expire_min=60 # Invoice expires in 60 minutes ) print(f"Amount in ETH: {invoice.amount}") print(f"QR Code: {invoice.qr_code}") # Invoice with multiple allowed cryptocurrencies invoice = client.create_invoice( currency=plisio.CryptoCurrency.TRX, order_name='Donation', order_number=12347, source_currency=plisio.FiatCurrency.USD, source_amount=25.00, allowed_currencies=[ plisio.CryptoCurrency.TRX, plisio.CryptoCurrency.USDT_TRX, plisio.CryptoCurrency.ETH ], description='Thank you for your support!' ) ``` -------------------------------- ### Fee Plan API Source: https://github.com/plisio/plisio-python/blob/main/README.md Retrieve fee plans for a selected cryptocurrency. The returned model includes additional fields specific to the fee plan. ```APIDOC ## GET /fee-plans ### Description Retrieves the fee plan model for a given cryptocurrency. ### Method GET ### Endpoint /fee-plans ### Parameters #### Query Parameters - **cryptocurrency** (string) - Required - The cryptocurrency for which to retrieve the fee plan. ### Request Example ``` GET /fee-plans?cryptocurrency=ETH ``` ### Response #### Success Response (200) - **fee_plan** (object) - The fee plan details. - **additional_fields** (object) - Additional fields specific to the fee plan. #### Response Example ```json { "fee_plan": { "name": "Standard", "fee_percentage": 0.5, "fixed_fee": 0.0001 }, "additional_fields": { "withdrawal_limit": 10000 } } ``` ``` -------------------------------- ### List All Transactions with Filtering - Python Source: https://context7.com/plisio/plisio-python/llms.txt Lists all transactions recorded in Plisio, with support for filtering by operation type, status, currency, and search terms. It also includes pagination parameters (page and limit) to manage large result sets. The output provides metadata about the total results and details for each operation. ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') # Get all operations with pagination operations = client.get_operations(page=1, limit=20) print(f"Total: {operations.meta}") for op in operations.operations: print(f"ID: {op.id}") print(f"Type: {op.type}") print(f"Status: {op.status}") print(f"Amount: {op.amount} {op.currency}") print("---") # Filter by status and type completed_invoices = client.get_operations( type_=plisio.OperationType.invoice, status=plisio.OperationStatus.completed, limit=50 ) # Filter by cryptocurrency btc_operations = client.get_operations( currency=plisio.CryptoCurrency.BTC ) # Search by transaction ID or order number search_results = client.get_operations( search='order_12345' ) ``` -------------------------------- ### Withdrawal API Source: https://github.com/plisio/plisio-python/blob/main/README.md Initiates a cryptocurrency withdrawal. Supports single or mass cash-out operations. ```APIDOC ## POST /api/withdraw ### Description Initiates a cryptocurrency withdrawal. This method supports both single and mass cash-out operations. ### Method POST ### Endpoint /api/withdraw ### Parameters #### Request Body - **crypto_currency** (string) - Required - The name of the cryptocurrency (e.g., LTC). - **to** (string) - Required - Destination wallet address or comma-separated hashes for mass withdrawal. - **amount** (number) - Required - The amount to withdraw. For mass withdrawal, comma-separated float values in the order of `to` parameter. - **fee_plan** (string) - Required - The name of one of the available fee plans. - **fee_rate** (number) - Optional - Custom fee rate. For BTC, this is the confirmation target (blocks). For ETH-based cryptocurrencies, it's the gas price in GWEI. - **type_** (string) - Optional - Operation type (e.g., `cash_out`, `mass_cash_out`). Defaults to `cash_out` if not specified. ### Response #### Success Response (200) - **type_** (string) - Operation type specified in the request. - **status** (string) - Status of the operation (*completed*, *error*). - **currency** (string) - Name of the cryptocurrency being withdrawn. - **source_currency** (string) - Name of the fiat currency (only USD is available). - **source_rate** (number) - Exchange rate from the `currency` to `source_currency` at the time of transfer. - **fee** (number) - Transaction fee in the transferred cryptocurrency. - **wallet_hash** (string) - Destination wallet hash (if `type_` is `cash_out`). - **sendmany** (object) - Dictionary of hashes and values (if `type_` is `mass_cash_out`). - **params** (object) - Withdrawal parameters model. - **created_at_utc** (integer) - Timestamp in UTC (may need division by 1000). - **amount** (number) - The withdrawn amount in cryptocurrency. - **tx_url** (string) - Link to the cryptocurrency block explorer. - **tx_id** (string) - Transaction ID(s). - **id** (string) - Internal Plisio operation ID. #### Response Example ```json { "type_": "cash_out", "status": "completed", "currency": "LTC", "source_currency": "USD", "source_rate": 150.50, "fee": 0.0001, "wallet_hash": "recipient_wallet_address", "sendmany": null, "params": {}, "created_at_utc": 1678886400000, "amount": 0.01, "tx_url": "https://blockexplorer.com/tx/example_tx_id", "tx_id": "example_tx_id", "id": "plisio_op_id_123" } ``` ``` -------------------------------- ### Async Operations API Source: https://github.com/plisio/plisio-python/blob/main/README.md Asynchronous analogues of the operations API methods, designed for use in async functions. ```APIDOC ## Async Usage ### Description Provides asynchronous versions of API methods for use in non-blocking applications. ### Method Asynchronous function calls ### Endpoint N/A (Client-side implementation) ### Parameters N/A ### Request Example ```python import plisio client = plisio.PlisioAioClient('your_secret_key') # Example: Get fee plan asynchronously fee_plan = await client.get_fee_plan(plisio.CryptoCurrency.ETH) # Example: Get currencies asynchronously currencies = await client.get_currencies(plisio.FiatCurrency.AUD) # Example: Get a specific operation asynchronously operation = await client.get_operation('op_xyz789') # Example: Get all operations asynchronously with filters operations = await client.get_operations(page=2, limit=20, currency='BTC') ``` ### Response #### Success Response (200) Responses mirror their synchronous counterparts but are returned as awaitable objects. #### Response Example ```json { "fee_plan": { "name": "Standard", "fee_percentage": 0.5, "fixed_fee": 0.0001 } } ``` ``` -------------------------------- ### Commission Estimation API Source: https://github.com/plisio/plisio-python/blob/main/README.md Estimates cryptocurrency fees and Plisio commission for transactions. Supports single or mass withdrawals. ```APIDOC ## GET /api/commission ### Description Estimates the cryptocurrency fee and Plisio commission for a given transaction. This method can be used for single or mass withdrawals. ### Method GET ### Endpoint /api/commission ### Parameters #### Query Parameters - **crypto_currency** (string) - Required - The name of the cryptocurrency (e.g., ETH). - **addresses** (string) - Optional - Wallet address or comma-separated addresses for mass withdrawal estimation. - **amounts** (string) - Optional - Amount or comma-separated amounts for mass withdrawal estimation. - **type_** (string) - Optional - Operation type (e.g., `cash_out`, `mass_cash_out`). - **fee_plan** (string) - Optional - The name of the fee plan. - **custom_fee_rate** (string) - Optional - Custom fee plan value. ### Response #### Success Response (200) - **commission** (number) - Plisio commission value. - **fee** (number) - Cryptocurrency fee value. - **max_amount** (number) - Maximum allowed amount for withdrawal. - **plan** (string) - Plisio's cryptocurrency fee estimation plan. - **use_wallet** (boolean) - Indicates if the fee should be paid from the wallet. - **use_wallet_balance** (number) - Balance of the wallet to be used for fee payment. - **plans** (object) - Details of available fee plans. - **custom** (object) - Details for custom fee plans. - **errors** (integer) - The number of errors encountered. - **custom_fee_rate** (string) - Custom fee plan value. #### Response Example ```json { "commission": 0.0001, "fee": 0.0005, "max_amount": 1000000.00, "plan": "normal", "use_wallet": true, "use_wallet_balance": 500.00, "plans": {}, "custom": {}, "errors": 0, "custom_fee_rate": "" } ``` ``` -------------------------------- ### Access Invoice and Transaction Details in Python Source: https://context7.com/plisio/plisio-python/llms.txt This snippet demonstrates how to access parameters of an invoice and details of associated transactions using the Plisio Python SDK. It checks for the presence of parameters and transaction data before printing relevant information. ```python if operation.params: print(f"Order Number: {operation.params.order_number}") print(f"Order Name: {operation.params.order_name}") print(f"Customer Email: {operation.params.email}") if operation.tx: for tx in operation.tx: print(f"TX ID: {tx.txid}") print(f"Confirmations: {tx.confirmations}") print(f"Block Explorer: {tx.url}") ``` -------------------------------- ### Error Handling for Plisio API in Python Source: https://context7.com/plisio/plisio-python/llms.txt This Python code demonstrates comprehensive error handling for Plisio API interactions. It catches specific PlisioError exceptions, allowing for tailored responses to different API error conditions like unauthorized access, rate limits, or server errors. ```python import plisio client = plisio.PlisioClient(api_key='your_secret_key') try: balance = client.get_balance(plisio.CryptoCurrency.BTC) except plisio.UnauthorizedError: print("Invalid API key - check your credentials") except plisio.ForbiddenError: print("Insufficient permissions for this operation") except plisio.NotFoundError: print("Resource not found") except plisio.RateLimitReachedError: print("Too many requests - implement backoff") except plisio.BadRequestError as e: print(f"Invalid request: {e}") except plisio.InternalServerError: print("Plisio server error - try again later") except plisio.ServiceUnavailableError: print("Service temporarily unavailable") except plisio.PlisioError as e: print(f"General API error: {e}") ``` -------------------------------- ### Fee Estimation API Source: https://github.com/plisio/plisio-python/blob/main/README.md Estimates the transaction fee for a cryptocurrency. Can be used for single or mass withdrawals. ```APIDOC ## GET /api/fee ### Description Estimates the transaction fee for a cryptocurrency. This method can be applied for single or mass withdrawal fee estimations. ### Method GET ### Endpoint /api/fee ### Parameters #### Query Parameters - **crypto_currency** (string) - Required - The name of the cryptocurrency (e.g., ETH). - **addresses** (string) - Optional - Wallet address or comma-separated addresses for mass withdrawal fee estimation. - **amounts** (string) - Optional - Amount or comma-separated amounts for mass withdrawal fee estimation. - **fee_plan** (string) - Optional - The name of one of the available fee plans. ### Response #### Success Response (200) - **fee** (number) - The estimated transaction fee. - **currency** (string) - The name of the cryptocurrency. - **plan** (string) - The name of the fee plan used for estimation. #### Response Example ```json { "fee": 0.0005, "currency": "ETH", "plan": "normal" } ``` ``` -------------------------------- ### Callback Data Validation Source: https://github.com/plisio/plisio-python/blob/main/README.md This section explains how to validate the data received from Plisio's callback URL to ensure its authenticity. ```APIDOC ## POST /callback ### Description Validates the authenticity of data received from Plisio's callback URL. ### Method POST ### Endpoint /callback (or your configured callback URL) ### Parameters #### Request Body - **request.body** (string) - Required - The raw request body received from the callback. ### Request Example (The request body content will be the data sent by Plisio) ### Response #### Success Response (200) - **isValid** (boolean) - True if the callback data is valid, false otherwise. #### Response Example ```python # Assuming 'request.body' contains the callback data import plisio client = plisio.PlisioClient(api_key='your_secret_key') isValid = client.validate_callback(request.body) if isValid: print("Callback data is valid.") else: print("Callback data is invalid.") ``` ### Notes Ensure that `?json=true` is appended to your `callback_url` for JSON data validation. ``` -------------------------------- ### Perform Withdrawal using Plisio Python SDK Source: https://github.com/plisio/plisio-python/blob/main/README.md The `withdraw` method facilitates cryptocurrency withdrawals. It requires the cryptocurrency symbol, destination address(es), and amount(s). Optional parameters include fee plan and operation type. It returns a Withdraw model detailing the transaction status, currency, fee, destination, and transaction URL. ```python withdraw = plisio.withdraw( crypto_currency = plisio.CryptoCurrency.LTC, to = 'wallet_address', amount = float(0.01), type_ = plisio.OperationType.cash_out ) ```