consuming-endpoints-from-client-code
Fungsinya
Skill ini menunjukkan cara memanggil endpoint PostHog dari aplikasi terpisah, seperti aplikasi seluler atau server. Ditujukan untuk pengembang yang ingin menggunakan data PostHog di dalam produk mereka sendiri.
Kapan dipakai
- βSaat Anda ingin memanggil endpoint PostHog dari aplikasi atau server Anda sendiri.
- βSaat Anda memerlukan klien bertipe yang dihasilkan dari spesifikasi OpenAPI endpoint.
- βSaat panggilan ke endpoint gagal karena error autentikasi atau batas laju.
Link skill
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/consuming-endpoints-from-client-code/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBagaimana cara memanggil endpoint PostHog saya dari aplikasi seluler, dan seperti apa bentuk permintaannya?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill membaca konfigurasi dan spesifikasi OpenAPI endpoint, lalu menunjukkan cara mengirim header autentikasi dan variabel yang tepat. Skill juga dapat menyarankan generator kode untuk membuat klien bertipe.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Apakah skill ini mengubah sesuatu di PostHog?
Tidak. Skill hanya membantu Anda terhubung ke endpoint dari basis kode lain.
Bisakah membuat klien dalam bahasa apa pun?
Skill mencakup pembuatan klien bertipe untuk TypeScript, Python, dan Go, menggunakan generator seperti openapi-generator atau @hey-api/openapi-ts.
Bagaimana jika panggilan saya ditolak karena variabel hilang?
Skill menjelaskan bagaimana variabel harus dibentuk untuk endpoint termaterialisasi, sehingga nilai yang diperlukan disertakan.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 41k
- Peringkat
- #6858
- Lisensi
- β
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
depot-ci
41kMembantu agent Anda menyiapkan dan menjalankan alur kerja Depot CI, alternatif GitHub Actions, termasuk memigrasikan alur kerja yang ada dan membaca log eksekusi.
depot-container-builds
41kMembantu agent Anda membangun image Docker di builder jarak jauh Depot, termasuk image multi-platform, pengiriman ke registry, dan perbaikan kegagalan build.
depot-github-runners
41kMembantu agent Anda memindahkan job GitHub Actions ke runner yang dikelola Depot, memilih ukuran dan label runner, serta memecahkan masalah pengaturan runner.
editing-agents-md
41kMembantu agent Anda memutuskan apakah sebuah aturan layak masuk ke berkas AGENTS.md atau CLAUDE.md, dan menulisnya agar tetap dipatuhi tanpa membuat berkas membengkak.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.