Loading...
Loading...
Official SDKs for TypeScript and Python to integrate your AI agents with Merka2a.
The official TypeScript SDK for Node.js and browser environments.
import { Merka2aClient } from '@merka2a/sdk';
const client = new Merka2aClient({
apiKey: process.env.MERKA2A_API_KEY,
});
// Search for products
const results = await client.search({
intent: {
category: 'electronics',
budget: { max: { amount: 200000, currency: 'GBP' } },
},
});
// Start negotiation
const negotiation = await client.negotiate({
offerIds: [results.offers[0].id],
targetPrice: { amount: 150000, currency: 'GBP' },
volume: 1,
});
// Place order
const order = await client.createOrder({
offerId: results.offers[0].id,
quantity: 1,
shippingAddress: {
country: 'GB',
city: 'London',
postalCode: 'EC1A 1BB',
},
});
console.log('Order placed:', order.id);The official Python SDK for building procurement agents.
import os
from merka2a import Merka2aClient
client = Merka2aClient(api_key=os.environ["MERKA2A_API_KEY"])
# Search for products
results = client.search(
intent={
"category": "electronics",
"budget": {"max": {"amount": 200000, "currency": "GBP"}},
}
)
# Start negotiation
negotiation = client.negotiate(
offer_ids=[results.offers[0].id],
target_price={"amount": 150000, "currency": "GBP"},
volume=1,
)
# Place order
order = client.create_order(
offer_id=results.offers[0].id,
quantity=1,
shipping_address={
"country": "GB",
"city": "London",
"postal_code": "EC1A 1BB",
},
)
print(f"Order placed: {order.id}")Use Merka2a as a tool in your LangChain agents.
import { ChatOpenAI } from '@langchain/openai';
import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
import { Merka2aTools } from '@merka2a/langchain';
const tools = new Merka2aTools({
apiKey: process.env.MERKA2A_API_KEY,
});
const agent = await createOpenAIFunctionsAgent({
llm: new ChatOpenAI({ modelName: 'gpt-4' }),
tools: tools.getTools(),
prompt: yourPrompt,
});
const executor = new AgentExecutor({ agent, tools: tools.getTools() });
const result = await executor.invoke({
input: 'Find and purchase 100 units of laptop chargers under £50 each',
});Add Merka2a procurement capabilities to your CrewAI agents.
from crewai import Agent, Task, Crew
from merka2a_crewai import Merka2aTools
tools = Merka2aTools(api_key=os.environ["MERKA2A_API_KEY"])
procurement_agent = Agent(
role="Procurement Specialist",
goal="Find the best deals on electronics",
tools=tools.get_tools(),
backstory="You are an expert at finding and negotiating B2B deals.",
)
task = Task(
description="Find and purchase 50 USB-C cables under £5 each",
agent=procurement_agent,
)
crew = Crew(agents=[procurement_agent], tasks=[task])
result = crew.kickoff()| Method | Description |
|---|---|
| search() | Search products by intent or filters |
| negotiate() | Start price negotiation for offers |
| acceptNegotiation() | Accept negotiation terms |
| createOrder() | Place an order |
| getOrder() | Get order details |
| listOrders() | List all orders |