### Run Get Info Example Source: https://github.com/elliottech/lighter-python/blob/main/README.md Execute the get_info.py script to retrieve information using the SDK. ```sh python examples/get_info.py ``` -------------------------------- ### Configure Setup Variables Source: https://github.com/elliottech/lighter-python/blob/main/examples/read-only-auth/README.md Constants to define in the setup.py script. ```python BASE_URL = "https://testnet.zklighter.elliot.ai" ETH_PRIVATE_KEY = "your_ethereum_private_key_here" API_KEY_INDEX = 253 # Using 253 as it's typically unused ``` -------------------------------- ### Getting Started with Lighter API Client Source: https://github.com/elliottech/lighter-python/blob/main/README.md Initialize the Lighter API client, fetch account information, and ensure the client connection is closed properly. ```python import lighter import asyncio async def main(): client = lighter.ApiClient() try: account_api = lighter.AccountApi(client) account = await account_api.account(by="index", value="1") print(account) finally: await client.close() # Make sure connection is cleanly closed if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Python Usage Example Source: https://github.com/elliottech/lighter-python/blob/main/docs/SubAccounts.md Example code demonstrating how to instantiate and convert the SubAccounts model. ```APIDOC ```python from lighter.models.sub_accounts import SubAccounts # create an instance of SubAccounts from a JSON string sub_accounts_instance = SubAccounts.from_json(json) # print the JSON string representation of the object print(SubAccounts.to_json()) # convert the object into a dict sub_accounts_dict = sub_accounts_instance.to_dict() # create an instance of SubAccounts from a dict sub_accounts_from_dict = SubAccounts.from_dict(sub_accounts_dict) ``` ``` -------------------------------- ### Run Setup Script Source: https://github.com/elliottech/lighter-python/blob/main/examples/read-only-auth/README.md Configures API key 253 for all accounts associated with the Ethereum private key. ```bash cd examples/read-only-auth python3 setup.py config.json ``` -------------------------------- ### Get Order Book Orders Source: https://github.com/elliottech/lighter-python/blob/main/docs/OrderApi.md Retrieves order book orders for a given market ID and limit. Ensure the lighter library is installed and configured with the correct host. ```python import lighter from lighter.models.order_book_orders import OrderBookOrders from lighter.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai # See configuration.py for a list of all supported configuration parameters. configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) # Enter a context with an instance of the API client async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.OrderApi(api_client) market_id = 56 # int | limit = 56 # int | try: # orderBookOrders api_response = await api_instance.order_book_orders(market_id, limit) print("The response of OrderApi->order_book_orders:\n") pprint(api_response) except Exception as e: print("Exception when calling OrderApi->order_book_orders: %s\n" % e) ``` -------------------------------- ### Get Partner Statistics Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Retrieves partner statistics for a given account index. Optional start and end timestamps can filter the data. Handles potential API exceptions. ```python import lighter from lighter.models.partner_stats import PartnerStats from lighter.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai # See configuration.py for a list of all supported configuration parameters. configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) # Enter a context with an instance of the API client async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.AccountApi(api_client) account_index = 56 # int | start_timestamp = 56 # int | (optional) end_timestamp = 56 # int | (optional) try: # partnerStats api_response = await api_instance.partner_stats(account_index, start_timestamp=start_timestamp, end_timestamp=end_timestamp) print("The response of AccountApi->partner_stats:\n") pprint(api_response) except Exception as e: print("Exception when calling AccountApi->partner_stats: %s\n" % e) ``` -------------------------------- ### Create and Use SystemConfig Instance Source: https://github.com/elliottech/lighter-python/blob/main/docs/SystemConfig.md Demonstrates how to create a SystemConfig instance from a JSON string and convert it to a dictionary. Ensure the JSON string is valid and contains the expected fields. ```python from lighter.models.system_config import SystemConfig # TODO update the JSON string below json = "{}" # create an instance of SystemConfig from a JSON string system_config_instance = SystemConfig.from_json(json) # print the JSON string representation of the object print(SystemConfig.to_json()) # convert the object into a dict system_config_dict = system_config_instance.to_dict() # create an instance of SystemConfig from a dict system_config_from_dict = SystemConfig.from_dict(system_config_dict) ``` -------------------------------- ### Get Public Pools Metadata Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Use this function to retrieve metadata for public pools. Ensure the 'lighter' library is installed and configure the API host if not using the default mainnet.zklighter.elliot.ai. ```python import lighter from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata from lighter.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai # See configuration.py for a list of all supported configuration parameters. configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) # Enter a context with an instance of the API client async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.AccountApi(api_client) index = 56 # int | limit = 56 # int | authorization = 'authorization_example' # str | make required after integ is done (optional) auth = 'auth_example' # str | made optional to support header auth clients (optional) filter = 'filter_example' # str | (optional) account_index = 56 # int | (optional) try: # publicPoolsMetadata api_response = await api_instance.public_pools_metadata(index, limit, authorization=authorization, auth=auth, filter=filter, account_index=account_index) print("The response of AccountApi->public_pools_metadata:\n") pprint(api_response) except Exception as e: print("Exception when calling AccountApi->public_pools_metadata: %s\n" % e) ``` -------------------------------- ### Quick Start: Initialize API Client and Fetch Account Data Source: https://context7.com/elliottech/lighter-python/llms.txt Initialize the API client and fetch account information using an async/await pattern. Defaults to the mainnet configuration. Ensure to close the client connection when done. ```python import lighter import asyncio async def main(): # Create API client (defaults to mainnet) client = lighter.ApiClient(configuration=lighter.Configuration( host="https://mainnet.zklighter.elliot.ai" )) try: # Fetch account by index account_api = lighter.AccountApi(client) account = await account_api.account(by="index", value="1") print(f"Account: {account}") # Fetch accounts by L1 address accounts = await account_api.accounts_by_l1_address( l1_address="0x8D7f03FdE1A626223364E592740a233b72395235" ) print(f"Sub-accounts: {accounts}") finally: await client.close() if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Run Create and Cancel Order Example Source: https://github.com/elliottech/lighter-python/blob/main/README.md Execute the create_cancel_order.py script to demonstrate creating and canceling orders. ```sh python examples/create_cancel_order.py ``` -------------------------------- ### Create LeaseOptionEntry from JSON and Dict Source: https://github.com/elliottech/lighter-python/blob/main/docs/LeaseOptionEntry.md Demonstrates creating a LeaseOptionEntry instance from a JSON string and a dictionary. Also shows how to convert the object back to JSON and a dictionary. ```python from lighter.models.lease_option_entry import LeaseOptionEntry # TODO update the JSON string below json = "{}" # create an instance of LeaseOptionEntry from a JSON string lease_option_entry_instance = LeaseOptionEntry.from_json(json) # print the JSON string representation of the object print(LeaseOptionEntry.to_json()) # convert the object into a dict lease_option_entry_dict = lease_option_entry_instance.to_dict() # create an instance of LeaseOptionEntry from a dict lease_option_entry_from_dict = LeaseOptionEntry.from_dict(lease_option_entry_dict) ``` -------------------------------- ### Install Lighter Python SDK Source: https://github.com/elliottech/lighter-python/blob/main/README.md Install the Lighter Python package directly from its GitHub repository using pip. ```sh pip install git+https://github.com/elliottech/lighter-python.git ``` -------------------------------- ### Run Websocket Sync Example Source: https://github.com/elliottech/lighter-python/blob/main/README.md Execute the ws.py script to demonstrate websocket synchronization for order books and accounts. ```sh python examples/ws.py ``` -------------------------------- ### GET /position_funding Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Retrieves account position fundings. ```APIDOC ## GET /position_funding ### Description Get accounts position fundings. ### Method GET ### Parameters #### Query Parameters - **account_index** (int) - Required - **limit** (int) - Required - **authorization** (str) - Optional - make required after integ is done - **auth** (str) - Optional - made optional to support header auth clients - **market_id** (int) - Optional - default to 255 - **cursor** (str) - Optional - **side** (str) - Optional - default to all ### Response #### Success Response (200) - **PositionFundings** (object) - A successful response. ``` -------------------------------- ### GET / Source: https://github.com/elliottech/lighter-python/blob/main/docs/RootApi.md Retrieves the current status of the ZkLighter service. ```APIDOC ## GET / ### Description Get status of zklighter. ### Method GET ### Endpoint https://mainnet.zklighter.elliot.ai/ ### Response #### Success Response (200) - **Status** (object) - A successful response containing service status. #### Error Response (400) - **Error** (string) - Bad request ``` -------------------------------- ### Initialize and Serialize RespGetLeaseOptions Source: https://github.com/elliottech/lighter-python/blob/main/docs/RespGetLeaseOptions.md Demonstrates how to instantiate the model from JSON or a dictionary and convert it back to these formats. ```python from lighter.models.resp_get_lease_options import RespGetLeaseOptions # TODO update the JSON string below json = "{}" # create an instance of RespGetLeaseOptions from a JSON string resp_get_lease_options_instance = RespGetLeaseOptions.from_json(json) # print the JSON string representation of the object print(RespGetLeaseOptions.to_json()) # convert the object into a dict resp_get_lease_options_dict = resp_get_lease_options_instance.to_dict() # create an instance of RespGetLeaseOptions from a dict resp_get_lease_options_from_dict = RespGetLeaseOptions.from_dict(resp_get_lease_options_dict) ``` -------------------------------- ### Initialize and Serialize LiqTrade Source: https://github.com/elliottech/lighter-python/blob/main/docs/LiqTrade.md Demonstrates creating a LiqTrade instance from JSON or a dictionary and converting it back to those formats. ```python from lighter.models.liq_trade import LiqTrade # TODO update the JSON string below json = "{}" # create an instance of LiqTrade from a JSON string liq_trade_instance = LiqTrade.from_json(json) # print the JSON string representation of the object print(LiqTrade.to_json()) # convert the object into a dict liq_trade_dict = liq_trade_instance.to_dict() # create an instance of LiqTrade from a dict liq_trade_from_dict = LiqTrade.from_dict(liq_trade_dict) ``` -------------------------------- ### GET /order_book_details Source: https://github.com/elliottech/lighter-python/blob/main/docs/OrderApi.md Retrieves metadata for order books. ```APIDOC ## GET /order_book_details ### Description Get order books metadata. ### Method GET ### Endpoint /order_book_details ### Parameters #### Query Parameters - **market_id** (int) - Optional - Market ID (default: 255). - **filter** (str) - Optional - Filter criteria (default: all). ### Response #### Success Response (200) - **OrderBookDetails** (object) - A successful response containing order book metadata. ``` -------------------------------- ### GET /exchangeStats Source: https://github.com/elliottech/lighter-python/blob/main/docs/OrderApi.md Retrieves general exchange statistics. ```APIDOC ## GET /exchangeStats ### Description Get exchange stats. ### Method GET ### Endpoint /exchangeStats ### Parameters This endpoint does not need any parameter. ### Request Example ```python import lighter async with lighter.ApiClient(configuration) as api_client: api_instance = lighter.OrderApi(api_client) api_response = await api_instance.exchange_stats() ``` ### Response #### Success Response (200) - **ExchangeStats** (object) - #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Initialize and Convert Funding Model Source: https://github.com/elliottech/lighter-python/blob/main/docs/Funding.md Demonstrates creating a Funding instance from JSON or a dictionary and converting it back to those formats. ```python from lighter.models.funding import Funding # TODO update the JSON string below json = "{}" # create an instance of Funding from a JSON string funding_instance = Funding.from_json(json) # print the JSON string representation of the object print(Funding.to_json()) # convert the object into a dict funding_dict = funding_instance.to_dict() # create an instance of Funding from a dict funding_from_dict = Funding.from_dict(funding_dict) ``` -------------------------------- ### Initialize and Convert ReqDoFaucet Model Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqDoFaucet.md Demonstrates creating a ReqDoFaucet instance from JSON, converting it to a dictionary, and recreating it from that dictionary. ```python from lighter.models.req_do_faucet import ReqDoFaucet # TODO update the JSON string below json = "{}" # create an instance of ReqDoFaucet from a JSON string req_do_faucet_instance = ReqDoFaucet.from_json(json) # print the JSON string representation of the object print(ReqDoFaucet.to_json()) # convert the object into a dict req_do_faucet_dict = req_do_faucet_instance.to_dict() # create an instance of ReqDoFaucet from a dict req_do_faucet_from_dict = ReqDoFaucet.from_dict(req_do_faucet_dict) ``` -------------------------------- ### GET /withdrawalDelay Source: https://github.com/elliottech/lighter-python/blob/main/docs/InfoApi.md Retrieves the withdrawal delay information. ```APIDOC ## GET /withdrawalDelay ### Description Retrieves the withdrawal delay information. ### Method GET ### Endpoint /withdrawalDelay ### Parameters This endpoint does not need any parameter. ### Return type [RespWithdrawalDelay](RespWithdrawalDelay.md) ### Authorization No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json ### Response #### Success Response (200) - **field** (type) - Description #### Response Example { "example": "response body" } ``` -------------------------------- ### Instantiate and Convert ReqGetPositionFunding Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetPositionFunding.md Demonstrates how to create an instance from JSON or a dictionary, and how to serialize the object back to JSON or a dictionary. ```python from lighter.models.req_get_position_funding import ReqGetPositionFunding # TODO update the JSON string below json = "{}" # create an instance of ReqGetPositionFunding from a JSON string req_get_position_funding_instance = ReqGetPositionFunding.from_json(json) # print the JSON string representation of the object print(ReqGetPositionFunding.to_json()) # convert the object into a dict req_get_position_funding_dict = req_get_position_funding_instance.to_dict() # create an instance of ReqGetPositionFunding from a dict req_get_position_funding_from_dict = ReqGetPositionFunding.from_dict(req_get_position_funding_dict) ``` -------------------------------- ### GET /api/v1/withdrawalDelay Source: https://github.com/elliottech/lighter-python/blob/main/docs/InfoApi.md Retrieves the withdrawal delay in seconds. ```APIDOC ## GET /api/v1/withdrawalDelay ### Description Withdrawal delay in seconds. ### Method GET ### Endpoint /api/v1/withdrawalDelay ### Parameters This endpoint does not need any parameters. ### Request Example ```python import lighter from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay from lighter.rest import ApiException from pprint import pprint configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) async with lighter.ApiClient(configuration) as api_client: api_instance = lighter.InfoApi(api_client) try: api_response = await api_instance.withdrawal_delay() pprint(api_response) except Exception as e: print("Exception when calling InfoApi->withdrawal_delay: %s\n" % e) ``` ### Response #### Success Response (200) - **RespWithdrawalDelay** (RespWithdrawalDelay) - Description of the withdrawal delay response model. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Initialize and Convert SpotMarketStats Source: https://github.com/elliottech/lighter-python/blob/main/docs/SpotMarketStats.md Demonstrates creating a SpotMarketStats instance from JSON or a dictionary and converting it back to those formats. ```python from lighter.models.spot_market_stats import SpotMarketStats # TODO update the JSON string below json = "{}" # create an instance of SpotMarketStats from a JSON string spot_market_stats_instance = SpotMarketStats.from_json(json) # print the JSON string representation of the object print(SpotMarketStats.to_json()) # convert the object into a dict spot_market_stats_dict = spot_market_stats_instance.to_dict() # create an instance of SpotMarketStats from a dict spot_market_stats_from_dict = SpotMarketStats.from_dict(spot_market_stats_dict) ``` -------------------------------- ### GET /api/v1/transferFeeInfo Source: https://github.com/elliottech/lighter-python/blob/main/docs/InfoApi.md Retrieves information about transfer fees. ```APIDOC ## GET /api/v1/transferFeeInfo ### Description Transfer fee info. ### Method GET ### Endpoint /api/v1/transferFeeInfo ### Parameters #### Query Parameters - **account_index** (int) - Required - The index of the account. - **authorization** (str) - Optional - Authorization token. (make required after integ is done) - **auth** (str) - Optional - Authentication details. (made optional to support header auth clients) - **to_account_index** (int) - Optional - The index of the destination account. (default to -1) ### Request Example ```python import lighter from lighter.models.transfer_fee_info import TransferFeeInfo from lighter.rest import ApiException from pprint import pprint configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) async with lighter.ApiClient(configuration) as api_client: api_instance = lighter.InfoApi(api_client) account_index = 56 authorization = 'authorization_example' auth = 'auth_example' to_account_index = -1 try: api_response = await api_instance.transfer_fee_info(account_index, authorization=authorization, auth=auth, to_account_index=to_account_index) pprint(api_response) except Exception as e: print("Exception when calling InfoApi->transfer_fee_info: %s\n" % e) ``` ### Response #### Success Response (200) - **TransferFeeInfo** (TransferFeeInfo) - Description of the transfer fee information model. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Create and Convert LiquidationInfos Instances Source: https://github.com/elliottech/lighter-python/blob/main/docs/LiquidationInfos.md Demonstrates how to create a LiquidationInfos instance from a JSON string and a dictionary, and how to convert an instance back to JSON and a dictionary. Ensure the JSON string is valid. ```python from lighter.models.liquidation_infos import LiquidationInfos # TODO update the JSON string below json = "{}" # create an instance of LiquidationInfos from a JSON string liquidation_infos_instance = LiquidationInfos.from_json(json) # print the JSON string representation of the object print(LiquidationInfos.to_json()) # convert the object into a dict liquidation_infos_dict = liquidation_infos_instance.to_dict() # create an instance of LiquidationInfos from a dict liquidation_infos_from_dict = LiquidationInfos.from_dict(liquidation_infos_dict) ``` -------------------------------- ### ReqGetBridgesByL1Addr Model Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetBridgesByL1Addr.md Definition and usage examples for the ReqGetBridgesByL1Addr model. ```APIDOC ## Model: ReqGetBridgesByL1Addr ### Description Represents a request object to retrieve bridges associated with a specific L1 address. ### Properties - **l1_address** (str) - The L1 address used to filter bridge results. ### Usage Example ```python from lighter.models.req_get_bridges_by_l1_addr import ReqGetBridgesByL1Addr # Create an instance from a JSON string json_data = "{\"l1_address\": \"0x123...\"}" instance = ReqGetBridgesByL1Addr.from_json(json_data) # Convert to dictionary instance_dict = instance.to_dict() ``` ``` -------------------------------- ### Initialize and Serialize ReqGetAssetDetails Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetAssetDetails.md Demonstrates creating an instance from JSON, converting to a dictionary, and back to an object. ```python from lighter.models.req_get_asset_details import ReqGetAssetDetails # TODO update the JSON string below json = "{}" # create an instance of ReqGetAssetDetails from a JSON string req_get_asset_details_instance = ReqGetAssetDetails.from_json(json) # print the JSON string representation of the object print(ReqGetAssetDetails.to_json()) # convert the object into a dict req_get_asset_details_dict = req_get_asset_details_instance.to_dict() # create an instance of ReqGetAssetDetails from a dict req_get_asset_details_from_dict = ReqGetAssetDetails.from_dict(req_get_asset_details_dict) ``` -------------------------------- ### GET /partner_stats Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Retrieve statistics for a specific partner account. ```APIDOC ## GET /partner_stats ### Description Get partner stats. ### Method GET ### Endpoint /partner_stats ### Parameters #### Query Parameters - **account_index** (int) - Required - The account index - **start_timestamp** (int) - Optional - Start time filter - **end_timestamp** (int) - Optional - End time filter ### Response #### Success Response (200) - **PartnerStats** (object) - A successful response containing partner statistics. #### Error Response (400) - Bad request ``` -------------------------------- ### GET /tx Source: https://github.com/elliottech/lighter-python/blob/main/docs/TransactionApi.md Retrieves a transaction by its hash or sequence index. ```APIDOC ## GET /tx ### Description Get transaction by hash or sequence index. ### Method GET ### Endpoint /tx ### Parameters #### Query Parameters - **by** (str) - Required - The field to search by (e.g., hash or sequence). - **value** (str) - Required - The value of the field to search for. ### Response #### Success Response (200) - **EnrichedTx** (object) - A successful response containing the enriched transaction details. ``` -------------------------------- ### Initialize and Convert ReqGetOrderBookDetails Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetOrderBookDetails.md Demonstrates creating an instance from JSON or a dictionary and converting it back to those formats. ```python from lighter.models.req_get_order_book_details import ReqGetOrderBookDetails # TODO update the JSON string below json = "{}" # create an instance of ReqGetOrderBookDetails from a JSON string req_get_order_book_details_instance = ReqGetOrderBookDetails.from_json(json) # print the JSON string representation of the object print(ReqGetOrderBookDetails.to_json()) # convert the object into a dict req_get_order_book_details_dict = req_get_order_book_details_instance.to_dict() # create an instance of ReqGetOrderBookDetails from a dict req_get_order_book_details_from_dict = ReqGetOrderBookDetails.from_dict(req_get_order_book_details_dict) ``` -------------------------------- ### GET /transfer_history Source: https://github.com/elliottech/lighter-python/blob/main/docs/TransactionApi.md Retrieves the transfer history for a specific account. ```APIDOC ## GET /transfer_history ### Description Get transfer history for a given account. ### Method GET ### Parameters #### Query Parameters - **account_index** (int) - Required - The index of the account. - **authorization** (str) - Optional - Authorization header. - **auth** (str) - Optional - Authentication token. - **cursor** (str) - Optional - Pagination cursor. - **type** (str) - Optional - Type of transfer history to filter. ### Response #### Success Response (200) - **TransferHistory** (object) - The transfer history data. ``` -------------------------------- ### Retrieve Account Details Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Demonstrates how to initialize the AccountApi client and fetch account information using the account method. ```python import lighter from lighter.models.detailed_accounts import DetailedAccounts from lighter.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai # See configuration.py for a list of all supported configuration parameters. configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) # Enter a context with an instance of the API client async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.AccountApi(api_client) by = 'by_example' # str | value = 'value_example' # str | active_only = False # bool | (optional) (default to False) cursor = 'cursor_example' # str | (optional) try: # account api_response = await api_instance.account(by, value, active_only=active_only, cursor=cursor) print("The response of AccountApi->account:\n") pprint(api_response) except Exception as e: print("Exception when calling AccountApi->account: %s\n" % e) ``` -------------------------------- ### Initialize and Convert ReqGetAccountTxs Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetAccountTxs.md Demonstrates how to instantiate the model from JSON or a dictionary and convert it back to those formats. ```python from lighter.models.req_get_account_txs import ReqGetAccountTxs # TODO update the JSON string below json = "{}" # create an instance of ReqGetAccountTxs from a JSON string req_get_account_txs_instance = ReqGetAccountTxs.from_json(json) # print the JSON string representation of the object print(ReqGetAccountTxs.to_json()) # convert the object into a dict req_get_account_txs_dict = req_get_account_txs_instance.to_dict() # create an instance of ReqGetAccountTxs from a dict req_get_account_txs_from_dict = ReqGetAccountTxs.from_dict(req_get_account_txs_dict) ``` -------------------------------- ### GET /info Source: https://github.com/elliottech/lighter-python/blob/main/docs/RootApi.md Retrieves general information about the ZkLighter system. ```APIDOC ## GET /info ### Description Get info of zklighter. ### Method GET ### Endpoint https://mainnet.zklighter.elliot.ai/info ### Response #### Success Response (200) - **ZkLighterInfo** (object) - A successful response containing system information. #### Error Response (400) - **Error** (string) - Bad request ``` -------------------------------- ### GET /executeStats Source: https://github.com/elliottech/lighter-python/blob/main/docs/OrderApi.md Retrieves execution statistics for a given period. ```APIDOC ## GET /executeStats ### Description Get execute stats. ### Method GET ### Endpoint /executeStats ### Parameters #### Query Parameters - **period** (str) - Required - ### Request Example ```python import lighter async with lighter.ApiClient(configuration) as api_client: api_instance = lighter.OrderApi(api_client) period = 'period_example' api_response = await api_instance.execute_stats(period) ``` ### Response #### Success Response (200) - **RespGetExecuteStats** (object) - #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Initialize and Serialize LiquidationInfo Source: https://github.com/elliottech/lighter-python/blob/main/docs/LiquidationInfo.md Demonstrates creating a LiquidationInfo instance from JSON or a dictionary and converting it back to these formats. ```python from lighter.models.liquidation_info import LiquidationInfo # TODO update the JSON string below json = "{}" # create an instance of LiquidationInfo from a JSON string liquidation_info_instance = LiquidationInfo.from_json(json) # print the JSON string representation of the object print(LiquidationInfo.to_json()) # convert the object into a dict liquidation_info_dict = liquidation_info_instance.to_dict() # create an instance of LiquidationInfo from a dict liquidation_info_from_dict = LiquidationInfo.from_dict(liquidation_info_dict) ``` -------------------------------- ### Instantiate and Convert ReqGetLiquidationInfos Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetLiquidationInfos.md Demonstrates creating an instance from JSON or a dictionary, and converting the instance back to JSON or a dictionary. ```python from lighter.models.req_get_liquidation_infos import ReqGetLiquidationInfos # TODO update the JSON string below json = "{}" # create an instance of ReqGetLiquidationInfos from a JSON string req_get_liquidation_infos_instance = ReqGetLiquidationInfos.from_json(json) # print the JSON string representation of the object print(ReqGetLiquidationInfos.to_json()) # convert the object into a dict req_get_liquidation_infos_dict = req_get_liquidation_infos_instance.to_dict() # create an instance of ReqGetLiquidationInfos from a dict req_get_liquidation_infos_from_dict = ReqGetLiquidationInfos.from_dict(req_get_liquidation_infos_dict) ``` -------------------------------- ### GET /fastbridge_info Source: https://github.com/elliottech/lighter-python/blob/main/docs/BridgeApi.md Retrieves information about the fast bridge service. ```APIDOC ## GET /fastbridge_info ### Description Retrieves general information about the fast bridge service. ### Method GET ### Endpoint /fastbridge_info ### Response #### Success Response (200) - **RespGetFastBridgeInfo** (object) - A successful response containing fast bridge information. #### Error Response (400) - Bad request ``` -------------------------------- ### Initialize and Serialize SpotOrderBookDetail Source: https://github.com/elliottech/lighter-python/blob/main/docs/SpotOrderBookDetail.md Demonstrates creating an instance from JSON or a dictionary and converting the object back to these formats. ```python from lighter.models.spot_order_book_detail import SpotOrderBookDetail # TODO update the JSON string below json = "{}" # create an instance of SpotOrderBookDetail from a JSON string spot_order_book_detail_instance = SpotOrderBookDetail.from_json(json) # print the JSON string representation of the object print(SpotOrderBookDetail.to_json()) # convert the object into a dict spot_order_book_detail_dict = spot_order_book_detail_instance.to_dict() # create an instance of SpotOrderBookDetail from a dict spot_order_book_detail_from_dict = SpotOrderBookDetail.from_dict(spot_order_book_detail_dict) ``` -------------------------------- ### PriceLevel Model Source: https://github.com/elliottech/lighter-python/blob/main/docs/PriceLevel.md Definition and usage examples for the PriceLevel data model. ```APIDOC ## PriceLevel Model ### Description The PriceLevel model is used to represent a price and its corresponding size. ### Properties - **price** (str) - The price value. - **size** (str) - The size associated with the price. ### Usage Example ```python from lighter.models.price_level import PriceLevel # Create an instance from a JSON string json_data = "{\"price\": \"100.00\", \"size\": \"10\"}" price_level_instance = PriceLevel.from_json(json_data) # Convert to dictionary price_level_dict = price_level_instance.to_dict() # Create an instance from a dictionary price_level_from_dict = PriceLevel.from_dict(price_level_dict) ``` ``` -------------------------------- ### Initialize and Convert RespChangeAccountTier Source: https://github.com/elliottech/lighter-python/blob/main/docs/RespChangeAccountTier.md Demonstrates creating an instance from JSON or a dictionary and converting it back to those formats. ```python from lighter.models.resp_change_account_tier import RespChangeAccountTier # TODO update the JSON string below json = "{}" # create an instance of RespChangeAccountTier from a JSON string resp_change_account_tier_instance = RespChangeAccountTier.from_json(json) # print the JSON string representation of the object print(RespChangeAccountTier.to_json()) # convert the object into a dict resp_change_account_tier_dict = resp_change_account_tier_instance.to_dict() # create an instance of RespChangeAccountTier from a dict resp_change_account_tier_from_dict = RespChangeAccountTier.from_dict(resp_change_account_tier_dict) ``` -------------------------------- ### Create and Use Auth Instance Source: https://github.com/elliottech/lighter-python/blob/main/docs/Auth.md Demonstrates how to create an Auth instance from a JSON string, convert it to a dictionary, and create another instance from a dictionary. The `auth` property is optional. ```python from lighter.models.auth import Auth # TODO update the JSON string below json = "{}" # create an instance of Auth from a JSON string auth_instance = Auth.from_json(json) # print the JSON string representation of the object print(Auth.to_json()) # convert the object into a dict auth_dict = auth_instance.to_dict() # create an instance of Auth from a dict auth_from_dict = Auth.from_dict(auth_dict) ``` -------------------------------- ### GET /tokens Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Retrieves the API tokens associated with a specific account. ```APIDOC ## GET /tokens ### Description Get api tokens of an account. ### Method GET ### Endpoint /tokens ### Parameters #### Query Parameters - **account_index** (int) - Required - The index of the account. - **authorization** (str) - Optional - Authorization token. ### Response #### Success Response (200) - **RespGetApiTokens** (object) - A successful response containing the account tokens. #### Error Response (400) - Bad request ``` -------------------------------- ### Initialize Lighter API Client Source: https://github.com/elliottech/lighter-python/blob/main/docs/InfoApi.md Configure and initialize the API client with the correct host. This setup is required before making any API calls. ```python configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) ``` -------------------------------- ### GET /liquidations Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Retrieves liquidation information for a specified account index. ```APIDOC ## GET /liquidations ### Description Get liquidation information for a given account. ### Parameters #### Query Parameters - **account_index** (int) - Required - The index of the account. - **limit** (int) - Required - Number of results to return. - **authorization** (str) - Optional - Authorization token. - **auth** (str) - Optional - Alternative authentication header. - **market_id** (int) - Optional - Market ID (default 255). - **cursor** (str) - Optional - Pagination cursor. ### Response #### Success Response (200) - **LiquidationInfos** (object) - A successful response containing liquidation data. ``` -------------------------------- ### GET /leases Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Retrieves lease information for a specified account index. ```APIDOC ## GET /leases ### Description Get lease information for a given account. ### Parameters #### Query Parameters - **account_index** (int) - Required - The index of the account. - **authorization** (str) - Optional - Authorization token. - **auth** (str) - Optional - Alternative authentication header. - **cursor** (str) - Optional - Pagination cursor. - **limit** (int) - Optional - Number of results to return (default 20). ### Response #### Success Response (200) - **RespGetLeases** (object) - A successful response containing lease data. ``` -------------------------------- ### Create and Convert FundingRates Instance Source: https://github.com/elliottech/lighter-python/blob/main/docs/FundingRates.md Demonstrates how to create a FundingRates instance from a JSON string and a dictionary, and how to convert it back to JSON and a dictionary. Ensure the JSON string is valid. ```python from lighter.models.funding_rates import FundingRates # TODO update the JSON string below json = "{}" # create an instance of FundingRates from a JSON string funding_rates_instance = FundingRates.from_json(json) # print the JSON string representation of the object print(FundingRates.to_json()) # convert the object into a dict funding_rates_dict = funding_rates_instance.to_dict() # create an instance of FundingRates from a dict funding_rates_from_dict = FundingRates.from_dict(funding_rates_dict) ``` -------------------------------- ### GET /accounts_by_l1_address Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountApi.md Retrieves accounts associated with a specific L1 address. ```APIDOC ## GET /accounts_by_l1_address ### Description Retrieves accounts associated with a specific L1 address. ### Method GET ### Endpoint /accounts_by_l1_address ### Parameters #### Query Parameters - **l1_address** (str) - Required - The L1 address to query. - **cursor** (str) - Optional - Cursor for pagination. ### Response #### Success Response (200) - **SubAccounts** (object) - A successful response. #### Response Example { "example": "SubAccounts object" } ``` -------------------------------- ### Initialize and Convert ReqGetByAccount Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetByAccount.md Demonstrates creating an instance from JSON or a dictionary and converting it back to those formats. ```python from lighter.models.req_get_by_account import ReqGetByAccount # TODO update the JSON string below json = "{}" # create an instance of ReqGetByAccount from a JSON string req_get_by_account_instance = ReqGetByAccount.from_json(json) # print the JSON string representation of the object print(ReqGetByAccount.to_json()) # convert the object into a dict req_get_by_account_dict = req_get_by_account_instance.to_dict() # create an instance of ReqGetByAccount from a dict req_get_by_account_from_dict = ReqGetByAccount.from_dict(req_get_by_account_dict) ``` -------------------------------- ### GET /withdraw_history Source: https://github.com/elliottech/lighter-python/blob/main/docs/TransactionApi.md Retrieves the withdrawal history for a specific account index. ```APIDOC ## GET /withdraw_history ### Description Fetches the withdrawal history for a given account index, with optional filtering and pagination support. ### Method GET ### Parameters #### Query Parameters - **account_index** (int) - Required - The index of the account. - **authorization** (str) - Optional - Authorization token. - **auth** (str) - Optional - Authentication header value. - **cursor** (str) - Optional - Pagination cursor. - **filter** (str) - Optional - Filter criteria. ### Response #### Success Response (200) - **WithdrawHistory** (object) - A successful response containing the withdrawal history. #### Error Response (400) - Bad request ``` -------------------------------- ### Instantiate and Convert RespGetMakerOnlyApiKeys Source: https://github.com/elliottech/lighter-python/blob/main/docs/RespGetMakerOnlyApiKeys.md Demonstrates how to create an instance from JSON or a dictionary, and how to serialize the object back to JSON or a dictionary. ```python from lighter.models.resp_get_maker_only_api_keys import RespGetMakerOnlyApiKeys # TODO update the JSON string below json = "{}" # create an instance of RespGetMakerOnlyApiKeys from a JSON string resp_get_maker_only_api_keys_instance = RespGetMakerOnlyApiKeys.from_json(json) # print the JSON string representation of the object print(RespGetMakerOnlyApiKeys.to_json()) # convert the object into a dict resp_get_maker_only_api_keys_dict = resp_get_maker_only_api_keys_instance.to_dict() # create an instance of RespGetMakerOnlyApiKeys from a dict resp_get_maker_only_api_keys_from_dict = RespGetMakerOnlyApiKeys.from_dict(resp_get_maker_only_api_keys_dict) ``` -------------------------------- ### Initialize and Convert AccountMarketStats Source: https://github.com/elliottech/lighter-python/blob/main/docs/AccountMarketStats.md Demonstrates creating an AccountMarketStats instance from JSON or a dictionary, and converting it back to these formats. ```python from lighter.models.account_market_stats import AccountMarketStats # TODO update the JSON string below json = "{}" # create an instance of AccountMarketStats from a JSON string account_market_stats_instance = AccountMarketStats.from_json(json) # print the JSON string representation of the object print(AccountMarketStats.to_json()) # convert the object into a dict account_market_stats_dict = account_market_stats_instance.to_dict() # create an instance of AccountMarketStats from a dict account_market_stats_from_dict = AccountMarketStats.from_dict(account_market_stats_dict) ``` -------------------------------- ### GET /tx_from_l1_tx_hash Source: https://github.com/elliottech/lighter-python/blob/main/docs/TransactionApi.md Retrieves an L1 transaction by its L1 transaction hash. ```APIDOC ## GET /tx_from_l1_tx_hash ### Description Get L1 transaction by L1 transaction hash. ### Method GET ### Endpoint /tx_from_l1_tx_hash ### Parameters #### Query Parameters - **hash** (str) - Required - The L1 transaction hash. ``` -------------------------------- ### GET /transfer_history Source: https://github.com/elliottech/lighter-python/blob/main/docs/TransactionApi.md Retrieves the transfer history for a specific account index. ```APIDOC ## GET /transfer_history ### Description Retrieves the transfer history for a given account index. ### Method GET ### Endpoint /transfer_history ### Parameters #### Query Parameters - **account_index** (int) - Required - The account index to query. - **authorization** (str) - Optional - Authorization header. - **auth** (str) - Optional - Alternative authentication header. - **cursor** (str) - Optional - Pagination cursor. - **type** (str) - Optional - Filter by transaction type. ### Response #### Success Response (200) - **TransferHistory** (object) - A successful response containing transfer history data. ``` -------------------------------- ### Initialize and Serialize Fundings Model Source: https://github.com/elliottech/lighter-python/blob/main/docs/Fundings.md Demonstrates how to instantiate the Fundings model from JSON or dictionary formats and convert it back to these formats. ```python from lighter.models.fundings import Fundings # TODO update the JSON string below json = "{}" # create an instance of Fundings from a JSON string fundings_instance = Fundings.from_json(json) # print the JSON string representation of the object print(Fundings.to_json()) # convert the object into a dict fundings_dict = fundings_instance.to_dict() # create an instance of Fundings from a dict fundings_from_dict = Fundings.from_dict(fundings_dict) ``` -------------------------------- ### Instantiate SpotAvgEntryPrice from JSON and Dict Source: https://github.com/elliottech/lighter-python/blob/main/docs/SpotAvgEntryPrice.md Demonstrates creating a SpotAvgEntryPrice object from a JSON string or a dictionary. Also shows how to convert the object back to JSON or a dictionary. ```python from lighter.models.spot_avg_entry_price import SpotAvgEntryPrice # TODO update the JSON string below json = "{}" # create an instance of SpotAvgEntryPrice from a JSON string spot_avg_entry_price_instance = SpotAvgEntryPrice.from_json(json) # print the JSON string representation of the object print(SpotAvgEntryPrice.to_json()) # convert the object into a dict spot_avg_entry_price_dict = spot_avg_entry_price_instance.to_dict() # create an instance of SpotAvgEntryPrice from a dict spot_avg_entry_price_from_dict = SpotAvgEntryPrice.from_dict(spot_avg_entry_price_dict) ``` -------------------------------- ### GET /recent_trades Source: https://github.com/elliottech/lighter-python/blob/main/docs/OrderApi.md Retrieves a list of recent trades for a specific market. ```APIDOC ## GET /recent_trades ### Description Retrieves recent trades for a specified market ID. ### Method GET ### Parameters #### Query Parameters - **market_id** (int) - Required - The ID of the market. - **limit** (int) - Required - The maximum number of trades to return. ### Response #### Success Response (200) - **Trades** (object) - A successful response containing trade data. #### Error Response (400) - Bad request ``` -------------------------------- ### GET /api/v1/accountInactiveOrders Source: https://github.com/elliottech/lighter-python/blob/main/docs/OrderApi.md Retrieves a list of inactive orders for a specific account. ```APIDOC ## GET /api/v1/accountInactiveOrders ### Description Get account inactive orders. ### Method GET ### Endpoint /api/v1/accountInactiveOrders ### Parameters #### Query Parameters - **account_index** (int) - Required - **limit** (int) - Required - **authorization** (str) - Optional - **auth** (str) - Optional - **market_id** (int) - Optional - **ask_filter** (str) - Optional - **between_timestamps** (str) - Optional - **cursor** (str) - Optional ### Response #### Success Response (200) - **Orders** (object) - A successful response containing inactive orders. ``` -------------------------------- ### Initialize and Serialize ReqGetFastWithdrawInfo Source: https://github.com/elliottech/lighter-python/blob/main/docs/ReqGetFastWithdrawInfo.md Demonstrates creating an instance from JSON or a dictionary and converting it back to those formats. ```python from lighter.models.req_get_fast_withdraw_info import ReqGetFastWithdrawInfo # TODO update the JSON string below json = "{}" # create an instance of ReqGetFastWithdrawInfo from a JSON string req_get_fast_withdraw_info_instance = ReqGetFastWithdrawInfo.from_json(json) # print the JSON string representation of the object print(ReqGetFastWithdrawInfo.to_json()) # convert the object into a dict req_get_fast_withdraw_info_dict = req_get_fast_withdraw_info_instance.to_dict() # create an instance of ReqGetFastWithdrawInfo from a dict req_get_fast_withdraw_info_from_dict = ReqGetFastWithdrawInfo.from_dict(req_get_fast_withdraw_info_dict) ``` -------------------------------- ### Perform Fast Withdraw with Lighter Python Source: https://github.com/elliottech/lighter-python/blob/main/docs/BridgeApi.md This example demonstrates how to initiate a fast withdrawal. It requires transaction information and a destination address. Optional authorization parameters can be provided. ```python import lighter from lighter.models.result_code import ResultCode from lighter.rest import ApiException from pprint import pprint configuration = lighter.Configuration( host = "https://mainnet.zklighter.elliot.ai" ) async with lighter.ApiClient(configuration) as api_client: api_instance = lighter.BridgeApi(api_client) tx_info = 'tx_info_example' to_address = 'to_address_example' authorization = 'authorization_example' auth = 'auth_example' try: api_response = await api_instance.fastwithdraw(tx_info, to_address, authorization=authorization, auth=auth) print("The response of BridgeApi->fastwithdraw:\n") pprint(api_response) except Exception as e: print("Exception when calling BridgeApi->fastwithdraw: %s\n" % e) ``` -------------------------------- ### GET /fastwithdraw_info Source: https://github.com/elliottech/lighter-python/blob/main/docs/BridgeApi.md Retrieves information regarding a specific fast withdrawal. ```APIDOC ## GET /fastwithdraw_info ### Description Fetches detailed information about a fast withdrawal based on the account index. ### Method GET ### Endpoint /fastwithdraw_info ### Parameters #### Query Parameters - **account_index** (int) - Required - The index of the account. - **authorization** (str) - Optional - Authorization token. - **auth** (str) - Optional - Authentication header value. ### Response #### Success Response (200) - **RespGetFastwithdrawalInfo** (object) - A successful response containing fast withdrawal details. ``` -------------------------------- ### Instantiate and Convert ZkLighterInfo Source: https://github.com/elliottech/lighter-python/blob/main/docs/ZkLighterInfo.md Demonstrates creating a ZkLighterInfo instance from JSON, converting it to a dictionary, and re-instantiating it from that dictionary. ```python from lighter.models.zk_lighter_info import ZkLighterInfo # TODO update the JSON string below json = "{}" # create an instance of ZkLighterInfo from a JSON string zk_lighter_info_instance = ZkLighterInfo.from_json(json) # print the JSON string representation of the object print(ZkLighterInfo.to_json()) # convert the object into a dict zk_lighter_info_dict = zk_lighter_info_instance.to_dict() # create an instance of ZkLighterInfo from a dict zk_lighter_info_from_dict = ZkLighterInfo.from_dict(zk_lighter_info_dict) ```