Python SDK for Lighthouse Private Markets API with PostgREST-style querying
Project description
Lighthouse API Client (Python)
Simple and powerful Python client for interacting with the Lighthouse API. Perfect for managing and analyzing your startup's data.
Features
- 🚀 Easy to use API
- 📦 Built on Supabase
- 💪 Python support
- ⚡ Lightweight
Installation
Using pip:
pip install lighthouse-private-markets-sdk
Quick Start
Importing and Initialization
from lighthouse import Lighthouse
# Initialize the client
lighthouse = Lighthouse('your-api-key')
Fetching Startups
def get_startups():
try:
response = lighthouse.from_('startups').select('*').limit(10).execute()
if response.error:
raise Exception(response.error)
print("Startups:", response.data)
except Exception as err:
print("Error:", err)
get_startups()
Common Query Examples
Select Single Record
# Get a specific startup
response = lighthouse.from_('startups').select('*').eq('id', 123).single().execute()
Filter Records
# Get all startups valued over $1M
response = lighthouse.from_('startups').select('name, valuation').gte('valuation', 1000000).order('valuation', desc=True).execute()
Select with Relationships
# Get startups with their founders
response = lighthouse.from_('startups').select('name, founders (name, role)').execute()
Pagination
# Get 10 records with offset
response = lighthouse.from_('startups').select('*').range(0, 9).execute()
Full Text Search
# Search startups by name
response = lighthouse.from_('startups').select('*').fts('name', 'tech').execute()
API Reference
Query Building
The Lighthouse client uses a builder pattern for constructing queries. The typical flow is:
- Start with
from_()to specify the table - Use
select()to specify columns - Add filters and modifiers
- Call
execute()to run the query
Core Classes
Lighthouse
The main client class.
from_(table: str): Start building a query for the specified table
LighthouseSelectQuery
Intermediate query builder after from_() but before select().
select(*columns: str): Choose specific columns to return
LighthouseFilterQuery
The main query builder with all filter methods.
Available Methods
Basic Filters
select(*columns: str): Choose specific fields to returnsingle(): Request a single recordmaybe_single(): Retrieve at most one row from the resulteq(column: str, value: Any): Equal to filterneq(column: str, value: Any): Not equal to filtergt(column: str, value: Any): Greater than filterlt(column: str, value: Any): Less than filtergte(column: str, value: Any): Greater than or equal to filterlte(column: str, value: Any): Less than or equal to filteris_(column: str, value: Any): 'IS' filterin_(column: str, values: Iterable[Any]): 'IN' filter for array of values
Text Search
like(column: str, pattern: str): Pattern matching (case sensitive)ilike(column: str, pattern: str): Pattern matching (case insensitive)like_all_of(column: str, pattern: str): Match all patternslike_any_of(column: str, pattern: str): Match any patternilike_all_of(column: str, pattern: str): Match all patterns (case insensitive)ilike_any_of(column: str, pattern: str): Match any pattern (case insensitive)
Full Text Search
fts(column: str, query: Any): Full text searchplfts(column: str, query: Any): Plain full text searchphfts(column: str, query: Any): Phrase full text searchwfts(column: str, query: Any): Websearch full text search
Array/JSON Operations
contains(column: str, value: Union[Iterable[Any], str, Dict[Any, Any]]): Check if array/json contains valuecontained_by(column: str, value: Union[Iterable[Any], str, Dict[Any, Any]]): Check if contained by valueoverlaps(column: str, values: Iterable[Any]): Overlaps with valuescs(column: str, values: Iterable[Any]): Contains filter (shorthand)cd(column: str, values: Iterable[Any]): Contained by filter (shorthand)ov(column: str, value: Iterable[Any]): Overlaps filter (shorthand)
Range Operations
sl(column: str, range: Tuple[int, int]): Strictly left of rangesr(column: str, range: Tuple[int, int]): Strictly right of rangenxl(column: str, range: Tuple[int, int]): Not extending left of rangenxr(column: str, range: Tuple[int, int]): Not extending right of rangeadj(column: str, range: Tuple[int, int]): Adjacent to rangerange_gt(column: str, range: Tuple[int, int]): Greater than rangerange_gte(column: str, range: Tuple[int, int]): Greater than or equal to rangerange_lt(column: str, range: Tuple[int, int]): Less than rangerange_lte(column: str, range: Tuple[int, int]): Less than or equal to rangerange_adjacent(column: str, range: Tuple[int, int]): Adjacent to range
Result Modification
order(column: str, desc: bool = False, nullsfirst: bool = False, foreign_table: Optional[str] = None): Sort resultslimit(size: int, foreign_table: Optional[str] = None): Limit number of rowsrange(start: int, end: int, foreign_table: Optional[str] = None): Get a range of rowsoffset(size: int): Set the starting row index
Logical Operations
not_(): Negate the next filteror_(filters: str, reference_table: Optional[str] = None): OR conditionmatch(query: Dict[str, Any]): Match multiple columnsfilter(column: str, operator: str, criteria: str): Apply a custom filter
Output Format
csv(): Return results as CSVexplain(analyze: bool = False, verbose: bool = False, settings: bool = False, buffers: bool = False, wal: bool = False, format: Literal["text", "json"] = "text"): Get query explanation
Execution
execute() -> APIResponse[_ReturnT]: Execute the query and return results
Examples
# Complex query example
response = (lighthouse.from_('startups')
.select('name, valuation, founders')
.gte('valuation', 1000000)
.ilike('name', '%tech%')
.order('valuation', desc=True)
.limit(10)
.execute())
# Full text search
response = (lighthouse.from_('startups')
.select('*')
.fts('description', 'artificial intelligence')
.execute())
# Array operations
response = (lighthouse.from_('startups')
.select('*')
.contains('tags', ['AI', 'ML'])
.execute())
# Range operations
response = (lighthouse.from_('funding_rounds')
.select('*')
.range_gte('amount', (1000000, 5000000))
.execute())
Error Handling
response = lighthouse.from_('startups').select('*').execute()
if response.error:
if response.error.code == 'PGRST116':
print('Invalid API key')
elif response.error.code == '42P01':
print('Table does not exist')
else:
print('An error occurred:', response.error)
exit()
# Process your data
print(response.data)
Best Practices
- Always check for errors before using data
- Use try/except blocks for error handling
- Limit your selections to required fields only
- Use pagination for large datasets
- Cache results when appropriate
Support
- 📧 Email: hello@trylighthouse.vc
License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lighthouse_private_markets_sdk-0.1.2.tar.gz.
File metadata
- Download URL: lighthouse_private_markets_sdk-0.1.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
079f2a20d3545ac9b93329b6a54ce7ff423bac889bc11648d768c7a637d03aa7
|
|
| MD5 |
09b42d68b550c840aba223d15e0c27ad
|
|
| BLAKE2b-256 |
ca41ea52822604240591e9d670574d717fdf41337ce23558a20b2964815a6e32
|
File details
Details for the file lighthouse_private_markets_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: lighthouse_private_markets_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d28056cd5bc206841d5acbfd56af10ef371fe96140a6dea8b774fb06905ada40
|
|
| MD5 |
1997e0fe258a9372ea7daf06c7fb7e54
|
|
| BLAKE2b-256 |
cad845f438cbdb70ce748307486357d22a5bbf2eb8487b9e227f376d6706865e
|