Skip to main content

Python SDK for Laplace stock data platform

Project description

Laplace Python SDK

PyPI version Python Support License

The official Python SDK for the Laplace stock data platform. Get easy access to stock data, collections, financials, funds, and AI-powered insights.

Features

  • 🚀 Easy to use: Simple, intuitive API
  • 📊 Comprehensive data: Stocks, collections, financials, funds, and AI insights
  • 🔧 Well-typed: Full TypeScript-style typing with Pydantic models
  • 🧪 Well-tested: Comprehensive test coverage with real API integration
  • 🌍 Multi-region: Support for US and Turkish markets
  • Fast: Built on httpx for high performance

Installation

pip install laplace-python-sdk

Quick Start

from laplace import LaplaceClient

# Initialize the client
client = LaplaceClient(api_key="your-api-key")

# Get stock details
stock = client.stocks.get_detail_by_symbol(symbol="AAPL", region="us")
print(f"{stock.name}: {stock.description}")

# Get all stocks in a region
stocks = client.stocks.get_all(region="us", page=1, page_size=10)
for stock in stocks:
    print(f"{stock.symbol}: {stock.name}")

# Get collections
collections = client.collections.get_collections(region="tr", locale="en")
for collection in collections:
    print(f"{collection.title}: {collection.num_stocks} stocks")

# Get collection details
collection_detail = client.collections.get_collection_detail(
    collection_id="620f455a0187ade00bb0d55f", 
    region="tr"
)
print(f"Stocks in {collection_detail.title}:")
for stock in collection_detail.stocks:
    print(f"  {stock.symbol}: {stock.name}")

API Reference

Stocks Client

# Get all stocks with pagination
stocks = client.stocks.get_all(region="us", page=1, page_size=10)

# Get stock detail by symbol
stock = client.stocks.get_detail_by_symbol(symbol="AAPL", region="us", asset_class="equity")

# Get stock detail by ID
stock = client.stocks.get_detail_by_id(stock_id="stock-id", locale="en")

# Get historical prices
prices = client.stocks.get_price(region="us", symbols=["AAPL", "GOOGL"], keys=["1D", "1W"])

# Get historical prices with custom interval
from datetime import datetime
from laplace.stocks import HistoricalPriceInterval

prices = client.stocks.get_price_with_interval(
    symbol="AAPL",
    region="us", 
    from_date=datetime(2024, 1, 1),
    to_date=datetime(2024, 1, 31),
    interval=HistoricalPriceInterval.ONE_DAY
)

# Get tick rules (Turkey only)
rules = client.stocks.get_tick_rules(region="tr")

# Get restrictions (Turkey only)
restrictions = client.stocks.get_restrictions(region="tr")

Collections Client

# Get all collections
collections = client.collections.get_collections(region="tr", locale="en")

# Get collection detail
detail = client.collections.get_collection_detail(collection_id="id", region="tr")

# Get themes
themes = client.collections.get_themes(region="tr", locale="en")

# Get theme detail
theme_detail = client.collections.get_theme_detail(theme_id="id", region="tr")

# Get industries
industries = client.collections.get_industries(region="tr", locale="en")

# Get industry detail
industry_detail = client.collections.get_industry_detail(industry_id="id", region="tr")

# Get sectors
sectors = client.collections.get_sectors(region="tr", locale="en")

# Get sector detail
sector_detail = client.collections.get_sector_detail(sector_id="id", region="tr")

Supported Regions

  • US: United States stock market
  • TR: Turkey stock market (Borsa Istanbul)

Error Handling

from laplace import LaplaceClient, LaplaceAPIError

client = LaplaceClient(api_key="your-api-key")

try:
    stock = client.stocks.get_detail_by_symbol(symbol="INVALID", region="us")
except LaplaceAPIError as e:
    print(f"API Error: {e}")
    print(f"Status Code: {e.status_code}")
    print(f"Response: {e.response}")

Authentication

Get your API key from the Laplace platform and initialize the client:

client = LaplaceClient(api_key="your-api-key-here")

Development

Setup

git clone https://github.com/Laplace-Analytics/laplace-python-sdk.git
cd laplace-python-sdk
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=laplace

# Run integration tests (requires API key)
LAPLACE_API_KEY=your-key pytest -m integration

Requirements

  • Python 3.8+
  • httpx >= 0.24.0
  • pydantic >= 2.0.0

Documentation

Full API documentation is available at laplace.finfree.co/en/docs

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

laplace_python_sdk-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

laplace_python_sdk-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: laplace_python_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for laplace_python_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c6c3fff4cef0addac21ab49f3d95d7fdc84aba8f9d1d1f0629bb66093c10c1f8
MD5 fb15d23104a999f5322ae29fe7efca17
BLAKE2b-256 70ba28e0e39bb36a7ace646e5c8050acf7d33dd89223c3825cdeb691af51a1e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for laplace_python_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1340f17fcaac5e4afa0f96360f57b0bcec694b79cd5e413e62be7d2f367e04b
MD5 9acddcc7ec4912c7341395c3f44b183e
BLAKE2b-256 0f93db665f24a24af9b3180ffa25342678ff0f13dd1a817a38b2943d37b0a9ae

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