consuming-endpoints-from-client-code
Was er macht
Dieser Skill zeigt, wie ein PostHog-Endpunkt aus einer separaten App aufgerufen wird, etwa einer mobilen App oder einem Server. Er richtet sich an Entwickler, die PostHog-Daten in ihrem eigenen Produkt nutzen wollen.
Wann du ihn nutzt
- ✓Wenn du einen PostHog-Endpunkt aus deiner eigenen App oder deinem Server aufrufen willst.
- ✓Wenn du aus der OpenAPI-Spezifikation des Endpunkts einen typisierten Client erzeugen musst.
- ✓Wenn ein Aufruf des Endpunkts mit einem Authentifizierungs- oder Ratenlimit-Fehler fehlschlägt.
Link zum Skill
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/consuming-endpoints-from-client-code/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Wie rufe ich meinen PostHog-Endpunkt aus unserer mobilen App auf, und wie sieht die Anfrage aus?”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Skill liest die Konfiguration und die OpenAPI-Spezifikation des Endpunkts und zeigt, wie der richtige Auth-Header und die Variablen gesendet werden. Er kann auch einen Code-Generator vorschlagen, der einen typisierten Client erzeugt.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Consuming endpoints from client code
This skill is the caller-side counterpart to creating-an-endpoint. It helps integrate an
existing endpoint into a separate codebase — a mobile app, server backend, customer dashboard,
or downstream pipeline. No PostHog code is modified here.
When to use this skill
- "How do I call my endpoint?" / "What does a request look like?"
- "Generate a typed TypeScript / Python / Go client for this endpoint"
- "I'm getting a 401 calling the endpoint" / auth questions
- "The endpoint rejects my call when I omit
user_id" → materialised-endpoint variable questions - "How do I handle rate limits?"
If the user is creating the endpoint, use creating-an-endpoint first.
Available tools
| Tool | Purpose |
|---|---|
endpoint-get |
Full config for a named endpoint, including the query shape and required variables |
endpoint-openapi-spec |
OpenAPI 3.0 spec for one endpoint, ready to feed to a code generator |
endpoint-run |
A live call against the endpoint — useful to confirm a payload works before sharing it with the user's app |
The endpoint URL
/api/projects/{team_id}/endpoints/{name}/run
team_idis the project ID (numeric). Available in PostHog under project settings, or viaprojects-getif the user doesn't know it.nameis the endpoint name — seeendpoints-get-allif the user isn't sure.- The trailing
/runis required.
POST is the canonical method. GET also works for simple cases without a request body but
POST is preferred — variables go in the body.
Auth
Endpoints are authenticated with a personal API key. The header is:
Authorization: Bearer <key>
Keys are scoped — for endpoints, the key needs at least endpoint:read. If the user gets a 403,
they're usually missing the scope; if they get a 401, the key is missing or malformed.
Never put a personal API key in client-side code that's shipped to end users (mobile apps, browser JS). Personal API keys grant scoped account access. For customer-facing apps, route through the user's own backend, which holds the key.
The request payload
{
"variables": { "code_name_1": value, "code_name_2": value },
"limit": 100,
"offset": 0,
"refresh": "cache"
}
| Field | Notes |
|---|---|
variables |
Keyed by code_name for HogQL endpoints; for insight endpoints with breakdowns, key is the breakdown property name |
limit |
Max rows returned. |
offset |
Skip rows. Only HogQL endpoints |
refresh |
"cache" (return cached results if fresh enough), "force" (always recalculate), "direct" (bypass materialisation, materialised endpoints only). Default is "cache" |
Call endpoint-get to see the exact variable shape. The response includes the query definition
with declared variables — each variable's code_name is what the client should send.
Materialised endpoints: all variables are required
If endpoint-get shows is_materialized: true on the current version, the endpoint requires
every declared variable to be passed on each call. This is a security boundary — without
filters, a single call would return the entire pre-aggregated dataset.
Common symptom: the user's app worked when the endpoint was unmaterialised, then started returning 400 errors after materialisation was enabled. The error message lists which variables are missing.
Optional/partial variables on materialised endpoints are a known limit
Häufige Fragen
Ändert dieser Skill etwas in PostHog?
Nein. Er hilft nur beim Verbinden mit einem Endpunkt aus einer anderen Codebasis.
Kann er einen Client in jeder Sprache erzeugen?
Er deckt das Erzeugen typisierter Clients für TypeScript, Python und Go ab, mit Generatoren wie openapi-generator oder @hey-api/openapi-ts.
Was ist, wenn mein Aufruf wegen einer fehlenden Variable abgelehnt wird?
Der Skill erklärt, wie die Variablen für materialisierte Endpunkte aufgebaut sein müssen, damit alle benötigten Werte enthalten sind.
Details
Originalbeschreibung des Autors
Wire a PostHog endpoint into a client app or SDK. Covers fetching the OpenAPI spec, generating a typed client with openapi-generator or @hey-api/openapi-ts, sending the right auth header, shaping the variables payload (HogQL code_name vs insight breakdown property), handling rate-limit and materialised-endpoint error responses. Use when the user says "how do I call my endpoint", "generate a client for this", or "what auth header do I use".
repo: PostHog/posthog
Beliebtheit
- GitHub-Sterne
- 41k
- Platz im Ranking
- #6858
- Lizenz
- —
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
depot-ci
41kBringt deinem Agenten bei, Depot-CI-Workflows einzurichten, bestehende Workflows zu migrieren und Laufprotokolle auszuwerten.
depot-container-builds
41kHilft deinem Agenten, Docker-Images auf Depot-Remote-Buildern zu bauen, mit Multi-Plattform-Images, Registry-Push und Fehlerbehebung.
depot-github-runners
41kLässt deinen Agenten GitHub-Actions-Jobs auf Depot-Runnern laufen, mit passender Runner-Größe und Labels, und hilft bei Einrichtungsfehlern.
editing-agents-md
41kHilft deinem Agenten zu entscheiden, ob eine Regel in AGENTS.md oder CLAUDE.md gehört, und sie so zu formulieren, dass sie hält.
Ähnliche Skills
api-connector-builder
280kLässt deinen Agenten neue API-Anbindungen nach dem bestehenden Muster bauen. Nutze es, wenn du eine weitere Integration ergänzen willst, ohne neue Wege einzuführen.
api-design
280kHilft deinem Agenten, REST-APIs nach Best Practices zu entwerfen. Nützlich für die Kommunikation, die Fehlerausgabe und die Organisation von Daten.
backend-patterns
280kHilft deinem Agenten bei Architekturmustern für die Serverseite und bei der Datenbankoptimierung. Nützlich zum Bauen und Prüfen von Server-Code.