본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)41k · #6858

consuming-endpoints-from-client-code

하는 일

이 스킬은 모바일 앱이나 서버처럼 별도의 앱에서 PostHog 엔드포인트를 호출하는 방법을 보여 줍니다. 자신의 제품 안에서 PostHog 데이터를 쓰려는 개발자를 위한 것입니다.

사용하는 경우

  • ✓자신의 앱이나 서버에서 PostHog 엔드포인트를 호출하고 싶을 때.
  • ✓엔드포인트의 OpenAPI 명세에서 타입이 지정된 클라이언트를 생성해야 할 때.
  • ✓엔드포인트 호출이 인증 또는 속도 제한 오류로 실패할 때.

스킬 링크

https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/consuming-endpoints-from-client-code/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/consuming-endpoints-from-client-code/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“모바일 앱에서 제 PostHog 엔드포인트를 어떻게 호출하나요? 요청은 어떻게 생겼나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

엔드포인트의 설정과 OpenAPI 명세를 읽은 뒤, 올바른 인증 헤더와 변수를 보내는 방법을 보여 줍니다. 타입이 지정된 클라이언트를 만들 코드 생성기도 제안할 수 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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_id is the project ID (numeric). Available in PostHog under project settings, or via projects-get if the user doesn't know it.
  • name is the endpoint name — see endpoints-get-all if the user isn't sure.
  • The trailing /run is 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

자주 묻는 질문

이 스킬이 PostHog의 무엇을 바꾸나요?

아니요. 다른 코드베이스에서 엔드포인트에 연결하는 것만 도와줍니다.

어떤 언어의 클라이언트든 생성할 수 있나요?

TypeScript, Python, Go용 타입 클라이언트 생성을 다루며, openapi-generator나 @hey-api/openapi-ts 같은 생성기를 씁니다.

변수가 빠졌다고 호출이 거부되면 어떻게 하나요?

스킬은 구체화된 엔드포인트에서 변수가 어떤 형태여야 하는지 설명하므로, 필요한 값이 포함됩니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
41k
순위
#6858
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬