Skip to main content

LN Markets API Python SDK

Project description

LN Markets SDK v3

CI

This is the Python version of the LN Markets API SDK. It provides a client-based interface for interacting with the LN Markets API.

Usage

For public endpoints, you can just do this:

from lnmarkets_sdk.v3.http.client import LNMClient
import asyncio

async with LNMClient() as client:
  ticker = await client.futures.get_ticker()
  await asyncio.sleep(1)
  leaderboard = await client.futures.get_leaderboard()

Remember to sleep between requests, as the rate limit is 1 requests per second for public endpoints.

For endpoints that need authentication, you need to create an instance of the LNMClient class and provide your API credentials:

from lnmarkets_sdk.v3.http.client import APIAuthContext, APIClientConfig, LNMClient

config = APIClientConfig(
    authentication=APIAuthContext(
        key=your_key,
        secret=your_secret,
        passphrase=your_passphrase,
    ),
    network="mainnet",
    timeout=60.0,  # 60 second timeout (default is 30s)
    )

async with LNMClient(config) as client:
  account = await client.account.get_account()

For endpoints that requires input parameters, you can find the corresponding models in the lnmarkets_sdk.models module.

from lnmarkets_sdk.v3.http.client import APIAuthContext, APIClientConfig, LNMClient
from lnmarkets_sdk.v3.models.account import GetLightningDepositsParams

config = APIClientConfig(
    authentication=APIAuthContext(
        key=your_key,
        secret=your_secret,
        passphrase=your_passphrase,
    ),
    network="mainnet",
    timeout=60.0,  # 60 second timeout (default is 30s)
    )

async with LNMClient(config) as client:
    deposits = await client.account.get_lightning_deposits(
        GetLightningDepositsParams(limit=5)
    )

Check our example for more details.

Available Methods

🔒 = requires API credentials

# Ping
client.ping()

# Account 🔒
client.account.get_account()
client.account.get_bitcoin_address()
client.account.add_bitcoin_address()
client.account.deposit_lightning()
client.account.withdraw_lightning()
client.account.withdraw_internal()
client.account.withdraw_on_chain()
client.account.get_lightning_deposits()
client.account.get_lightning_withdrawals()
client.account.get_internal_deposits()
client.account.get_internal_withdrawals()
client.account.get_on_chain_deposits()
client.account.get_on_chain_withdrawals()

# Futures
client.futures.get_ticker()
client.futures.get_leaderboard()
client.futures.get_candles()
client.futures.get_funding_settlements()

# Futures Isolated 🔒
client.futures.isolated.new_trade()
client.futures.isolated.get_running_trades()
client.futures.isolated.get_open_trades()
client.futures.isolated.get_closed_trades()
client.futures.isolated.close()
client.futures.isolated.cancel()
client.futures.isolated.cancel_all()
client.futures.isolated.add_margin()
client.futures.isolated.cash_in()
client.futures.isolated.update_stoploss()
client.futures.isolated.update_takeprofit()
client.futures.isolated.get_funding_fees()

# Futures Cross 🔒
client.futures.cross.new_order()
client.futures.cross.get_position()
client.futures.cross.get_open_orders()
client.futures.cross.get_filled_orders()
client.futures.cross.close()
client.futures.cross.cancel()
client.futures.cross.cancel_all()
client.futures.cross.deposit()
client.futures.cross.withdraw()
client.futures.cross.set_leverage()
client.futures.cross.get_transfers()
client.futures.cross.get_funding_fees()

# Oracle
client.oracle.get_index()
client.oracle.get_last_price()

# Synthetic USD
client.synthetic_usd.get_best_price()
client.synthetic_usd.get_swaps()  # 🔒
client.synthetic_usd.new_swap()   # 🔒

API Reference

For full API documentation, see: LNM API v3 Documentation

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lnmarkets_sdk-0.0.18.tar.gz (48.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lnmarkets_sdk-0.0.18-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file lnmarkets_sdk-0.0.18.tar.gz.

File metadata

  • Download URL: lnmarkets_sdk-0.0.18.tar.gz
  • Upload date:
  • Size: 48.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for lnmarkets_sdk-0.0.18.tar.gz
Algorithm Hash digest
SHA256 ea3292c249a43944a381c86d10b498c20c411c01cb6981f198873e68639c44f9
MD5 c80af48a922039ec59f2a270e0e05636
BLAKE2b-256 45b1ccc7c567ffa56ac8b72ee95f23bb7f69d404a6e4e3fc635cef80a6eb7ab4

See more details on using hashes here.

File details

Details for the file lnmarkets_sdk-0.0.18-py3-none-any.whl.

File metadata

File hashes

Hashes for lnmarkets_sdk-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 8c9a69c56de7011d3a37ba65102a3a73a70cf14ceb18a68496536b40c4f43d3a
MD5 355141e7ea603a58085b538b2b0a2278
BLAKE2b-256 6e123630bdf26827bd5f34e080a46249d6adb9dff9d7afbe1c58e2f65815df02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page