Liquid API is an intelligent API integration framework that combines the power of Language Models (LLMs) with swarm algorithms to enable seamless communication between incompatible applications. It's designed to solve complex business integration scenarios where traditional API approaches fall short.
🤖 LLM-Powered Decision Making: Intelligent routing and data transformation using small, efficient language models 🔄 Flexible Adapter System: Easy-to-implement adapters for any API endpoint ⚡ Async Processing: Built on modern async/await patterns for optimal performance ���️ Enterprise-Ready: Comprehensive error handling, logging, and security features 🎯 Configuration-Driven: Simple YAML configuration for quick deployment 🔄 Automatic Retries: Built-in retry mechanisms for reliable operations
Python 3.8+ PyTorch transformers aiohttp pyyaml
- Create Configuration File Create a config.yml file: yamlCopymodel_name: "HuggingFaceTB/SmolLM2-135M" adapters:
-
name: crm_adapter config: url: "https://api.crm.example.com" method: "GET" headers: Authorization: "Bearer ${CRM_API_KEY}" retry_attempts: 3 timeout: 30
-
name: erp_adapter config: url: "https://api.erp.example.com" method: "POST" headers: Api-Key: "${ERP_API_KEY}" retry_attempts: 3 timeout: 30
- Basic Usage pythonCopyfrom liquid_api import LiquidAPI
async def main(): # Initialize Liquid API liquid_api = LiquidAPI.from_config('config.yml')
# Define integration context
context = {
"source_system": "CRM",
"target_system": "ERP",
"data_mapping": {
"customer_id": "erp_customer_number",
"order_details": "sales_order"
}
}
# Execute integration
result = await liquid_api.integrate(
source_adapter="crm_adapter",
target_adapter="erp_adapter",
context=context
)
print(f"Integration completed: {result}")
if name == "main": import asyncio asyncio.run(main()) Custom Adapters Create custom adapters by inheriting from the APIAdapter base class: pythonCopyfrom liquid_api import APIAdapter, APIConfig
class CustomAdapter(APIAdapter): async def transform_request(self, data): # Transform outgoing data return data
async def transform_response(self, response):
# Transform incoming data
return response
Environment Variables Liquid API supports environment variables in configuration: yamlCopyadapters:
- name: secure_adapter config: url: "${API_URL}" headers: Authorization: "Bearer ${API_KEY}" Logging Configuration pythonCopyimport logging
logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' )
CRM to ERP Integration pythonCopy# Define custom adapters class CRMAdapter(APIAdapter): async def transform_request(self, data): return { "customer_number": data["customer_id"], "order_data": data["order_details"] }
class ERPAdapter(APIAdapter): async def transform_response(self, response): return { "erp_reference": response["reference_id"], "status": response["order_status"] }
liquid_api.register_adapter("crm", CRMAdapter(crm_config)) liquid_api.register_adapter("erp", ERPAdapter(erp_config)) Error Handling pythonCopytry: result = await liquid_api.integrate( source_adapter="crm", target_adapter="erp", context=context ) except Exception as e: logging.error(f"Integration failed: {e}") # Implement fallback logic Best Practices
Store sensitive data in environment variables Use separate configurations for development/production
Implement comprehensive error handling Use the built-in retry mechanism for transient failures
Utilize async/await for I/O-bound operations Configure appropriate timeouts
Regularly rotate API keys Implement rate limiting Use HTTPS for all API endpoints
We welcome contributions! Please see our Contributing Guide for details.
Fork the repository Create a feature branch Commit your changes Push to the branch Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.