Skip to main content

Code-Snippets

Kein SDK

Diese Snippets sind ein Startpunkt, kein unterstütztes SDK. Es gibt heute kein SDK – du nutzt die HTTP-API direkt, die stabil und in der Referenz vollständig dokumentiert ist.

Erster API-Call – Python

import os
import requests
BASE = "https://api.etg24.de/propertymanagement/v2"
headers = {"Authorization": f"Bearer {os.environ['ETG24_API_KEY']}"}
response = requests.get(f"{BASE}/query/contacts", headers=headers)
response.raise_for_status()
print(response.json())

Erster API-Call – JavaScript (Node.js)

const BASE = 'https://api.etg24.de/propertymanagement/v2'
const headers = {Authorization: `Bearer ${process.env.ETG24_API_KEY}`}
const response = await fetch(`${BASE}/query/contacts`, {headers})
if (!response.ok) throw new Error(`HTTP ${response.status}`)
console.log(await response.json())

MCP-Verbindung – Python

import os
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
MCP_URL = "https://api.etg24.de/propertymanagement/v2/mcp"
headers = {"Authorization": f"Bearer {os.environ['ETG24_API_KEY']}"}
async with streamablehttp_client(MCP_URL, headers=headers) as (read, write, _):
async with ClientSession(read, write) as session:
tools = await session.list_tools()
print([tool.name for tool in tools.tools])

MCP-Verbindung – JavaScript

import {Client} from '@modelcontextprotocol/sdk/client/index.js'
const client = new Client({name: 'mein-agent', version: '0.1.0'})
await client.connect(/* der etg24-MCP-Transport, authentifiziert mit deinem API-Key */)
const {tools} = await client.listTools()
console.log(tools.map((tool) => tool.name))

Lieber eine geführte Einrichtung direkt in deiner App? Siehe MCP mit deinem KI-Agenten verbinden für Claude, ChatGPT, Mistral, Perplexity, opencode und mehr.

Einen Kontakt anlegen (Command-Beispiel)

Commands sind POST-Requests auf /command/<type>:

Terminal window
curl -s -X POST "https://api.etg24.de/propertymanagement/v2/command/contacts.create" \
-H "Authorization: Bearer DEIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contact": {"firstName": "Ada", "lastName": "Lovelace"}}'

Denk an die CQRS-Trennung: Commands ändern Zustand, Queries lesen ihn – und Read-only-Keys können nur Queries ausführen.