Lightweight API client for the Finder Enrichment Orchestrator service
Project description
Finder Enrichment Orchestrator API Client
A lightweight Python package for interacting with the Finder Enrichment Orchestrator API. This client provides synchronous methods for enriching listings, descriptions, images, and floorplans.
Features
- Simple: Easy-to-use interface for enrichment operations
- Synchronous: Immediate processing without background jobs
- Type-safe: Full Pydantic model support for requests and responses
- Configurable: Support for both environment variables and direct configuration
- Comprehensive: Support for all enrichment operations (listings, descriptions, images, floorplans)
Installation
pip install finder-enrichment-orchestrator-api-client
Quick Start
Basic Usage
from finder_enrichment_orchestrator_api_client import OrchestratorAPIClient
# Initialize with environment variables
client = OrchestratorAPIClient()
# Or initialize with direct configuration
client = OrchestratorAPIClient(
base_url="http://localhost:3100",
api_key="your-api-key-here"
)
# Enrich a single listing
result = client.enrich_listing(listing_id="123")
if result.status == "success":
print(f"Enriched listing: {result.enriched_listing_id}")
print(f"Processing time: {result.processing_time_seconds}s")
else:
print(f"Error: {result.error_message}")
Batch Enrichment
# Enrich multiple listings
batch_result = client.enrich_listings(listing_ids=["123", "456", "789"])
print(f"Total processed: {batch_result.total_processed}")
print(f"Successful: {batch_result.total_successful}")
print(f"Failed: {batch_result.total_failed}")
for result in batch_result.results:
print(f"Listing {result.original_listing_id}: {result.status}")
Description Enrichment
# Enrich a listing's description
result = client.enrich_description(listing_id="123")
if result.status == "success":
print(f"Description output: {result.description_output}")
print(f"Model used: {result.model}")
Image Enrichment
# Enrich all images for a listing
result = client.enrich_listing_images(listing_id="123")
print(f"Processed {result.image_count} images")
for image_result in result.results:
print(f"Image {image_result.original_image_id}: {image_result.status}")
# Enrich a single image
image_result = client.enrich_image(image_id="456")
if image_result.status == "success":
print(f"Image analytics: {image_result.image_analytics_output}")
Floorplan Enrichment
# Enrich a single floorplan
result = client.enrich_floorplan(floorplan_id="789")
if result.status == "success":
print(f"Floorplan analytics: {result.floorplan_analytics_output}")
print(f"Analytics run ID: {result.analytics_run_id}")
Environment Variables
The client uses the following environment variables by default:
# Base URL for the orchestrator API (default: http://localhost:3100)
export ORCHESTRATOR_BASE_URL="https://your-orchestrator-api.com"
# API key for authentication (required)
export ORCHESTRATOR_API_KEY="your-api-key-here"
You can also set these in a .env file:
ORCHESTRATOR_BASE_URL=http://localhost:3100
ORCHESTRATOR_API_KEY=your-api-key-here
API Reference
OrchestratorAPIClient
Initialization
client = OrchestratorAPIClient(
base_url: Optional[str] = None, # Default: ORCHESTRATOR_BASE_URL env var
api_key: Optional[str] = None, # Default: ORCHESTRATOR_API_KEY env var
api_prefix: str = "/api", # API path prefix
default_timeout_seconds: float = 30.0 # Request timeout
)
Methods
Listing Enrichment
-
enrich_listing(listing_id: str, *, timeout_seconds: Optional[float] = None) -> EnrichmentResultEnrich a single listing synchronously.
-
enrich_listings(listing_ids: List[str], *, timeout_seconds: Optional[float] = None) -> BatchEnrichmentResultEnrich multiple listings in a batch.
Description Enrichment
-
enrich_description(listing_id: str, *, timeout_seconds: Optional[float] = None) -> DescriptionAnalysisResultEnrich a listing's description.
Image Enrichment
-
enrich_listing_images(listing_id: str, *, timeout_seconds: Optional[float] = None) -> BatchImageAnalysisResultEnrich all images for a listing.
-
enrich_image(image_id: str, *, timeout_seconds: Optional[float] = None) -> ImageAnalysisResultEnrich a single image.
Floorplan Enrichment
-
enrich_floorplan(floorplan_id: str, *, timeout_seconds: Optional[float] = None) -> FloorplanAnalysisResultEnrich a single floorplan.
Response Models
All methods return Pydantic models with the following common fields:
status:"success","failed", or"timeout"error_message: Error description (if applicable)processing_time_seconds: Time taken for processingtimestamp: When the operation completed
See the individual model classes for specific fields:
EnrichmentResultBatchEnrichmentResultDescriptionAnalysisResultImageAnalysisResultBatchImageAnalysisResultFloorplanAnalysisResultBatchFloorplanAnalysisResult
Error Handling
from finder_enrichment_orchestrator_api_client import OrchestratorAPIClient
import requests
client = OrchestratorAPIClient()
try:
result = client.enrich_listing(listing_id="123")
if result.status == "success":
print("Success!")
else:
print(f"Processing failed: {result.error_message}")
except requests.HTTPError as e:
print(f"HTTP error: {e}")
except ValueError as e:
print(f"Invalid response: {e}")
Development
Setup
# Clone the repository
git clone https://github.com/giacomokavanagh/finder-enrichment-orchestrator.git
cd finder-enrichment-orchestrator/src/finder_enrichment_orchestrator_api_client
# Install in development mode
pip install -e ".[dev]"
Testing
# Run tests
pytest
# Run tests with coverage
pytest --cov=finder_enrichment_orchestrator_api_client
Code Formatting
# Format code
black .
isort .
# Check style
flake8
Building
# Install build dependencies
pip install build twine
# Build the package
python -m build
# Upload to PyPI
twine upload dist/*
License
MIT License
Support
For issues and questions, please visit the GitHub Issues page.
Project details
Release history Release notifications | RSS feed
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 finder_enrichment_orchestrator_api_client-0.1.0.tar.gz.
File metadata
- Download URL: finder_enrichment_orchestrator_api_client-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7aef7f2558646d4cc8e91e1701c9679dee97b71d4329dede7f0b3fcae038e2d
|
|
| MD5 |
1ffdfd39a73ff132b7ee875c5d0c9ded
|
|
| BLAKE2b-256 |
8d401238df4e5cc60b019c0820f0f02a1c02fe749450bb0d3a0d54c2102bf277
|
File details
Details for the file finder_enrichment_orchestrator_api_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: finder_enrichment_orchestrator_api_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750a982a20d5b85fc1150c970a61a9f36d36ad0407c753c10f0a8576a3071eda
|
|
| MD5 |
0c0efcb9973cf86acd55db0aa9e11e83
|
|
| BLAKE2b-256 |
903dc5e8e9b0c32bb02ca94e48b894873ed94b91310b80661d051a7cf7bf8ef7
|