Skip to main content

Python client for the LOBSTER financial data API

Project description

lobsterdata

LOBSTER Logo

Python client for the LOBSTER financial data API.

LOBSTER provides high-quality, tick-level order book data for NASDAQ-listed stocks, widely used in academic finance research.

Installation

pip install lobsterdata

To use the example CLI scripts (examples/cli.py and examples/bulk_request.py), install the examples optional dependency group, which adds anyio and python-dotenv:

pip install "lobsterdata[examples]"

Quick start

🦞 Pilot phase — The API is currently in pilot and access is by invitation only. If you are an active Lobsterian and would like to join, please send an email to service@lobsterdata.com with your name, institute, and email address. Only active Lobsterians will be granted access.

from lobsterdata import LobsterClient

client = LobsterClient(
    api_key="your_api_key",
    api_secret="your_api_secret",
    is_pilot=True,   # True → dev.lobsterdata.com, False → lobsterdata.com
)

1 — Submit a request

result = client.submit_request(
    symbol="AAPL",
    start_date="2025-02-03",
    end_date="2025-02-07",
    level=10,
    exchange="NASDAQ",
)
request_id = result["data"]["request_id"]
print(f"Request submitted – ID: {request_id}")

Submitting in a loop? Sleep at least 3 seconds between each call on the pilot server to stay well within the rate limit of 20 requests per minute. Exceeding it will block your API key for 10 minutes.

import time

for symbol in symbols:
    client.submit_request(symbol, start_date, end_date)
    time.sleep(3)   # avoid rate-limit block

Construction typically takes a few minutes depending on the date range and symbol.

2 — Check if ready

List your requests and inspect their status and data size:

requests = client.list_requests()
for req in requests:
    rid = req.get("request_id") or req.get("id")
    status = req.get("status")
    size_mb = req.get("request_data_size", 0) / (1024 * 1024)
    print(f"ID {rid} | {req.get('symbol')} | status: {status} | size: {size_mb:.2f} MB")

A request is ready to download when status == "finished" and request_data_size > 0.

Construction typically takes a few minutes. Re-run the snippet above until your request meets both conditions.

3 — Download and clean up

filepath = client.download_request(request_id, download_dir="./downloads")
print(f"Saved to: {filepath}")

client.delete_request(request_id)
print("Deleted from server.")

See the examples/ directory for ready-to-run CLI scripts — a great starting point for learning the full API workflow. examples/cli.py covers interactive single-request submission and download; examples/bulk_request.py shows an async multi-symbol pipeline.

API limits & constraints

⚠️ Violating any of these constraints will result in a rejected request (error=1) or a temporary API key block.

Request constraints

Parameter Allowed values Notes
level 0 or 10 Any other value is rejected
frequency_seconds 0 or null Any other value is rejected
Date range ≤ 31 days end_date − start_date must not exceed 31 days

Rate limiting

Limit Consequence
20 requests per minute Exceeding this blocks your API key for 10 minutes

Storage limit

The pilot server has a storage limit of 200 GB of raw CSV data (not the compressed zip size). If your total stored data on the server exceeds this quota, your API key will be blocked with the reason "Storage breached". The block is lifted automatically once you delete enough files to drop below the limit — use delete_request() or download_and_cleanup() to free up space.

Checking your block state

state = client.get_block_state()
print(state)
# {"blocked": False, "block_reason": None, "unblock_time": None}

If blocked is True, the response will include block_reason and unblock_time.

API reference

Method Description
submit_request(symbol, start_date, end_date, level, exchange) Submit a new data construction request
list_requests() List all requests for the authenticated user
get_request(request_id) Look up a single request by ID
list_alive_requests() Requests with status waiting, running, or undeleted finished
list_downloadable_requests() Finished requests with data available for download
download_request(request_id, download_dir) Download a completed request's data file
delete_request(request_id) Delete a request and its file from the server
download_and_cleanup(download_dir) Download all available files then delete them from the server
get_block_state() Check whether your API key is currently blocked and why

Credentials

Credentials are read from a .env file (recommended) or environment variables.

.env file (recommended)

Copy the provided template and fill in your values:

cp .env.example .env
LOBSTER_API_KEY=your_api_key
LOBSTER_API_SECRET=your_api_secret
LOBSTER_IS_PILOT=true

The CLI scripts load .env automatically via python-dotenv. .env is git-ignored.

Environment variables

export LOBSTER_API_KEY="your_api_key"
export LOBSTER_API_SECRET="your_api_secret"
export LOBSTER_IS_PILOT="false"

License

MIT

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

lobsterdata-0.1.3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

lobsterdata-0.1.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file lobsterdata-0.1.3.tar.gz.

File metadata

  • Download URL: lobsterdata-0.1.3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lobsterdata-0.1.3.tar.gz
Algorithm Hash digest
SHA256 75a8943f366523cf13858612ff4505dae81eb476fdbdb8bfa9992faffd8412bf
MD5 ba53e24c03594f09f776f71a57e69fac
BLAKE2b-256 b80fb4a238aa2904807e07745bf6edecee8d09f5b676ec214886cb3fe9221cd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lobsterdata-0.1.3.tar.gz:

Publisher: publish.yml on rhuang10/lobsterdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lobsterdata-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: lobsterdata-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lobsterdata-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b69094e512ba1483d7492d2081992bafe5e5468f1d5911fb9423a601267df53b
MD5 b2c6ec161e19c81be54ffed3d63f68d3
BLAKE2b-256 43b80213fc7e844ab95093825c57feb26d18d58bb7e0a786190eebb5485d1be2

See more details on using hashes here.

Provenance

The following attestation bundles were made for lobsterdata-0.1.3-py3-none-any.whl:

Publisher: publish.yml on rhuang10/lobsterdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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