Skip to main content

Simple Python SDK for the CoinPulse crypto portfolio API

Project description

coinpulse-python

Simple Python SDK for the CoinPulse crypto portfolio API.

No OAuth, no complex setup. Just prices and portfolios.

Install

pip install coinpulse

Quick Start

from coinpulse import CoinPulse

# Get your free API key at https://coinpulse.dev
client = CoinPulse(api_key="your-api-key")

# Get current prices
prices = client.get_prices(["bitcoin", "ethereum", "solana"])
for p in prices:
    print(f"{p.coin_id}: ${p.price_usd:,.2f}")

# bitcoin: $91,187.00
# ethereum: $3,245.00
# solana: $187.50

Features

Prices

# Current prices for multiple coins
prices = client.get_prices(["bitcoin", "ethereum"])

# Single coin
btc = client.get_price("bitcoin")
print(f"BTC: ${btc.price_usd:,.2f}")

# Historical prices (up to 365 days)
history = client.get_historical_prices("bitcoin", days=30)
for h in history:
    print(f"{h.timestamp}: ${h.price_usd:,.2f}")

# Backtesting
result = client.backtest(
    coin_id="bitcoin",
    start_date="2024-01-01",
    end_date="2024-12-31",
    initial_investment=1000
)
print(f"Return: {result.price_change_percent:.1f}%")

# List supported coins
coins = client.get_supported_coins()
# ['bitcoin', 'ethereum', 'solana', ...]

Portfolios

# Create a portfolio
portfolio = client.create_portfolio(name="My Crypto")

# Add holdings
client.add_holding(
    portfolio_id=portfolio.id,
    coin_id="bitcoin",
    symbol="btc",
    amount=0.5,
    average_buy_price=45000
)

client.add_holding(
    portfolio_id=portfolio.id,
    coin_id="ethereum",
    symbol="eth",
    amount=5.0,
    average_buy_price=2500
)

# Get portfolio with current values
details = client.get_portfolio(portfolio.id)
print(f"Total value: ${details.total_value:,.2f}")
print(f"Total P/L: ${details.total_profit_loss:,.2f}")

for h in details.holdings:
    print(f"{h.coin_id}: {h.amount} coins")
    print(f"  Bought at: ${h.purchase_price:,.2f}")
    print(f"  Now worth: ${h.current_value:,.2f}")
    print(f"  P/L: {h.profit_loss_percent:+.1f}%")

Price Alerts (PRO tier)

# Create an alert
alert = client.create_alert(
    coin_id="bitcoin",
    target_price=100000,
    condition="above",
    notification_method="webhook",
    webhook_url="https://your-webhook.com/alert"
)

# List alerts
alerts = client.get_alerts()

# Toggle on/off
client.toggle_alert(alert.id)

# Delete
client.delete_alert(alert.id)

Pricing

Tier Price Requests/hr Features
Free $0 25 Prices, portfolios, historical
Starter $15/mo 500 All features, higher limits
Pro $49/mo 2,500 + Price alerts, backtesting
Enterprise $149/mo 10,000 + Priority support

Get your API key at coinpulse.dev

Error Handling

from coinpulse import (
    CoinPulse,
    AuthenticationError,
    RateLimitError,
    NotFoundError,
)

client = CoinPulse(api_key="your-key")

try:
    prices = client.get_prices(["bitcoin"])
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after}s")
except NotFoundError:
    print("Coin not found")

Type Hints

Everything is typed. Works great with your IDE:

from coinpulse import CoinPulse
from coinpulse.models import Price, Portfolio, Holding

client = CoinPulse(api_key="...")
prices: list[Price] = client.get_prices(["bitcoin"])

Configuration

client = CoinPulse(
    api_key="your-key",
    base_url="https://coinpulse.dev",  # default
    timeout=30,  # seconds
)

License

MIT

Links

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

coinpulse-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

coinpulse-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file coinpulse-0.1.0.tar.gz.

File metadata

  • Download URL: coinpulse-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for coinpulse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3aecf8690d19356c8ac4fda971f0108a53b8134738bc2f0ab2a62b4cd8d36e14
MD5 ef453b411730164983be73cfa6578535
BLAKE2b-256 74768e6ea365e398ff23cd434a00eb62e2226aaa4e6cc8443f930b50e2a588df

See more details on using hashes here.

File details

Details for the file coinpulse-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: coinpulse-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for coinpulse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98c77b2369f9b09987c7c01ffcf96f49b745fd5c936ca152e52838b94cd3b138
MD5 3bc7f097560068af1eb4262f75e72e94
BLAKE2b-256 01fa5cf6cd9a36d790774ed48ade48e11014c65355679cf5ada1ddc835119061

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