Skip to main content

Code snippets

Not an SDK

These snippets are a starting point, not a supported SDK. No SDK exists today — you use the HTTP API directly, which is stable and fully documented in the reference.

First 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())

First 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 connection — 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 connection — JavaScript

import {Client} from '@modelcontextprotocol/sdk/client/index.js'
const client = new Client({name: 'my-agent', version: '0.1.0'})
await client.connect(/* the etg24 MCP transport, authenticated with your API key */)
const {tools} = await client.listTools()
console.log(tools.map((tool) => tool.name))

Prefer a guided setup inside your favorite app? See Connect MCP to your AI agent for Claude, ChatGPT, Mistral, Perplexity, opencode and more.

Creating a contact (command example)

Commands are POST requests to /command/<type>:

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

Remember the CQRS split: commands change state, queries read it — and read-only keys can only run queries.