> For the complete documentation index, see [llms.txt](https://docs.madjik.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.madjik.io/integration-guides/a2a-integration.md).

# Using Madjik API for A2A

Enable autonomous agent communication and coordination using Madjik's market intelligence.

## Overview

A2A (Agent-to-Agent) protocols allow AI agents to communicate and collaborate. Madjik API provides the shared data layer for crypto-focused agent networks.

## A2A Architecture with Madjik

```
┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│  Agent A    │────▶│  Madjik API │◀────│  Agent B    │
│ (Sentiment) │     │  (Shared    │     │  (Risk)     │
└─────────────┘     │   Truth)    │     └─────────────┘
                    └─────────────┘
                          │
                          ▼
                    ┌─────────────┐
                    │  Agent C    │
                    │ (Execution) │
                    └─────────────┘
```

## Use Cases

### 1. Multi-Agent Trading System

```python
# Agent 1: Sentiment Analyst
class SentimentAgent:
    def analyze(self):
        sentiment = requests.get(
            "https://api.madjik.io/v1/metrics/me10030",
            headers={"Authorization": "Bearer YOUR_API_KEY"}
        ).json()
        return {"signal": "bullish" if sentiment['value'] > 60 else "bearish"}

# Agent 2: Risk Manager
class RiskAgent:
    def assess(self):
        liquidation = requests.get(
            "https://api.madjik.io/v1/metrics/me10016",
            headers={"Authorization": "Bearer YOUR_API_KEY"}
        ).json()
        return {"risk_level": liquidation['value']}

# Agent 3: Executor
class ExecutionAgent:
    def execute(self, sentiment_signal, risk_level):
        if sentiment_signal == "bullish" and risk_level < 50:
            return self.buy()
        elif risk_level > 80:
            return self.reduce_position()
```

### 2. Consensus-Based Decisions

```python
def multi_agent_consensus():
    agents = [
        SentimentAgent(),
        WhaleTrackingAgent(),
        TetherMonitorAgent()
    ]
    
    votes = []
    for agent in agents:
        # All agents use Madjik as shared truth
        signal = agent.analyze()
        votes.append(signal)
    
    # Majority vote
    return max(set(votes), key=votes.count)
```

### 3. Agent Communication Protocol

```python
# Standardized message format using Madjik metrics
message = {
    "from": "sentiment_agent",
    "to": "execution_agent",
    "timestamp": "2026-01-29T12:00:00Z",
    "data": {
        "madjik_metrics": {
            "ME10030": 72,  # Social Sentiment
            "ME10014": 0.05  # Funding Rate
        },
        "recommendation": "long",
        "confidence": 0.85
    }
}
```

## Best Practices

1. **Shared data source** - All agents should use Madjik as single source of truth
2. **Timestamped data** - Ensure agents reference same time window
3. **Conflict resolution** - Define rules when agents disagree
4. **Audit trail** - Log all agent decisions with underlying Madjik data

## See Also

* [AI Integration Guide](/integration-guides/ai-integration.md)
* [MCP Integration Guide](/integration-guides/mcp-integration.md)
* [All Metrics](https://github.com/madjik-io/madjik-api-docs/blob/main/metrics/README.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.madjik.io/integration-guides/a2a-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
