consuming-endpoints-from-client-code
यह क्या करती है
यह स्किल दिखाती है कि मोबाइल ऐप या सर्वर जैसे अलग ऐप से PostHog एंडपॉइंट कैसे कॉल करें। यह उन डेवलपर्स के लिए है जो अपने प्रोडक्ट के अंदर PostHog डेटा इस्तेमाल करना चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप अपने ऐप या सर्वर से PostHog एंडपॉइंट कॉल करना चाहें।
- ✓जब आपको एंडपॉइंट की OpenAPI स्पेक से टाइप्ड क्लाइंट बनवाना हो।
- ✓जब एंडपॉइंट की कॉल प्रमाणीकरण या रेट लिमिट की त्रुटि से विफल हो।
Skill का लिंक
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/consuming-endpoints-from-client-code/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं अपने मोबाइल ऐप से अपना PostHog एंडपॉइंट कैसे कॉल करूँ, और अनुरोध कैसा दिखता है?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह एंडपॉइंट की कॉन्फ़िगरेशन और OpenAPI स्पेक पढ़ती है, फिर दिखाती है कि सही auth हेडर और वेरिएबल कैसे भेजे जाएँ। यह टाइप्ड क्लाइंट बनाने के लिए कोड जनरेटर भी सुझा सकती है।
तकनीकी सामग्री (मूल 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_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
अक्सर पूछे जाने वाले सवाल
क्या यह स्किल 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
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
depot-ci
41kयह आपके एजेंट को Depot CI वर्कफ़्लो सेट अप करने, चलाने और माइग्रेट करने में मदद करती है, साथ ही रन के लॉग पढ़ने में।
depot-container-builds
41kयह आपके एजेंट को Depot के रिमोट बिल्डर पर Docker इमेज बनाने में मदद करती है, जिसमें मल्टी-प्लेटफ़ॉर्म इमेज और बिल्ड सुधार शामिल हैं।
depot-github-runners
41kयह आपके एजेंट को GitHub Actions जॉब Depot के मैनेज्ड रनर पर ले जाने, रनर का साइज़ और लेबल चुनने, और रनर सेटअप की समस्याएँ ठीक करने में मदद करती है।
editing-agents-md
41kयह आपके एजेंट को तय करने में मदद करती है कि कोई नियम AGENTS.md या CLAUDE.md में जाए या नहीं, और उसे ऐसे लिखे कि फ़ाइल भारी न हो।
मिलती-जुलती skills
api-connector-builder
280kयह आपके एजेंट को मौजूदा pattern के हिसाब से नए API connections बनाने देता है। जब बिना कोई नया तरीका बनाए एक और integration जोड़ना हो, तब इसका इस्तेमाल करें।
api-design
280kयह आपके एजेंट को best practices के हिसाब से REST APIs डिज़ाइन करने में मदद करता है। यह तय करने में काम आता है कि APIs आपस में कैसे बात करें, errors कैसे दिखें, और data को कैसे व्यवस्थित करें।
backend-patterns
280kआपके एजेंट को server-side architecture patterns और database optimization में मदद करता है। server पर चलने वाला code बनाने या review करने के लिए उपयोगी है।