creating-an-endpoint
यह क्या करती है
यह स्किल आपको सहेजी हुई क्वेरी या इनसाइट को ऐसे एंडपॉइंट में बदलने में मार्गदर्शन देती है जिसे दूसरे सिस्टम कॉल कर सकें। यह उन लोगों के लिए है जो चाहते हैं कि PostHog डेटा किसी बाहरी ऐप या पाइपलाइन को मिले।
कब इस्तेमाल करें
- ✓जब आप PostHog क्वेरी को कॉल करने योग्य API रूट के रूप में दिखाना चाहें।
- ✓जब आप मौजूदा इनसाइट को किसी बाहरी सिस्टम के लिए एंडपॉइंट बनाना चाहें।
- ✓जब कोई नया ऐप या पाइपलाइन PostHog डेटा माँगे और आप तय कर रहे हों कि उसे कैसे दिया जाए।
Skill का लिंक
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/creating-an-endpoint/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“ऐसा एंडपॉइंट बनाइए जो हमारे साप्ताहिक सक्रिय उपयोगकर्ता लौटाए, ताकि मेरा मोबाइल ऐप उसे कॉल कर सके।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह कुछ फ़ैसले क्रम से लेती है: एंडपॉइंट सही टूल है या नहीं, कौन से वेरिएबल दिखाने हैं, डेटा कितना ताज़ा हो, और नतीजे सहेजने हैं या नहीं। फिर वह एंडपॉइंट बनाती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Creating an endpoint
This skill walks through creating a new endpoint with the right configuration. Endpoints expose saved HogQL or insight queries as callable HTTP routes — the configuration choices made at creation time determine cost, latency, and how callers integrate.
The materialisation deep-dive lives at references/materializing.md. Pull it in when the
materialisation decision is non-obvious.
When to use this skill
- "Create an endpoint for [query]"
- "Expose this insight as an API"
- "Help me turn this HogQL into a callable endpoint"
- A new caller (mobile app, customer-facing dashboard, downstream pipeline) needs PostHog data and the user is choosing how to deliver it
Decisions to make in order
1. Should this even be an endpoint?
Endpoints are right when:
- An external system (someone else's code) needs to call PostHog for data
- The query is stable — not exploratory analysis
- The shape is reusable — same query with different parameters
Endpoints are wrong when:
- An internal PostHog dashboard or insight needs the data — use the insight directly; an endpoint only adds an external API surface you don't need internally
- One-off, exploratory analysis — use the
execute-sqltool (or the SQL editor) directly
Heavy aggregation is not a reason to avoid an endpoint. Endpoints are themselves saved queries, and a heavy, frequently-called aggregation is often the best case for an endpoint with materialisation turned on.
If the user is unsure, ask what's calling the endpoint and what shape they expect.
2. Pick a name
Names are URL-safe (letters, numbers, hyphens, underscores), start with a letter, max 128 chars, must be unique within the project. Lean toward:
- Descriptive over generic —
weekly_active_users_by_orgovermetrics - Snake_case — matches how the name appears in code paths and URLs
- No version in the name — versions are managed by the endpoint itself
- No "endpoint" in the name — redundant
The name appears in the URL: /api/projects/{team_id}/endpoints/{name}/run. It's not
trivially renameable later (callers depend on the path) — get it right at creation.
3. Pick the query kind
Two options exist:
- HogQL (
HogQLQuery) — raw SQL written by the user. Variables defined via{variables.x}syntax, matched oncode_name. Recommended for new endpoints when the caller cares about the exact column shape of the response. - Insight — wraps an existing insight definition. Best supported for
TrendsQuery,LifecycleQuery, andRetentionQuery: these can be materialised, and the breakdown can act as a variable (Trends and Retention only; Lifecycle has no breakdown). Other insight kinds such asFunnelsQuerycan run inline but cannot be materialised and don't expose breakdown variables — rewrite those as HogQL if you need either.
HogQL is the more flexible choice. Pick insight only when the user is genuinely re-publishing an existing insight (see "Creating from an existing insight" below) rather than building a new query.
4. Decide which inputs become variables
Anything that should change per-caller goes in variables; the rest is hard-coded in the query.
For HogQL endpoints, variables are declared in the query payload with code_name, type,
and default. Each execution call passes { "variables": { "<code_name>": value } }.
Common patterns:
- Time windows:
date_from,date_to, or a singlelookback_daysinteger - Identity filters:
user_id,account_id,team_id - Pagination control beyond
limit/offset(these are first-class on the run endpoint already)
For insight endpoints, the breakdown property acts as the variable (Trends and Retention
only — Lifecycle has no breakdown). Pass the breakdown property name as the key. date_from /
date_to are accepted as variables only on non-materialised insight endpoints — a materialised
endpoint bakes its date range into the view, so callers can't shift the window.
Avoid:
- Variables that change the shape of the result — keep the columns stable. If callers need fundamentally different result shapes, ship separate endpoints.
- Variables that bypass safety — don't expose a
where_clausevariable that lets callers inject arbitrary SQL.
Creating from an existing insight
There's no server-side "make an endpoint from insight N" operation. To do it: read the insight's query (via the insight tools), pass that quer
अक्सर पूछे जाने वाले सवाल
मुझे एंडपॉइंट कब नहीं बनाना चाहिए?
अगर केवल आपका अपना PostHog डैशबोर्ड डेटा चाहता है, तो इनसाइट सीधे इस्तेमाल करें। एक बार की खोज SQL क्वेरी से बेहतर होती है।
यहाँ डेटा की ताज़गी का क्या मतलब है?
यह तय करता है कि लौटाया गया डेटा दोबारा गणना होने से पहले कितना पुराना हो सकता है, यानी गति और ताज़ा नतीजों के बीच चुनाव।
क्या मुझे पहले दिन से नतीजे सहेजने चाहिए?
स्किल क्वेरी कितनी भारी है और उसे कितनी बार कॉल किया जाएगा, इसके आधार पर इसका फ़ैसला करने में मदद करती है।
जानकारी
लेखक का मूल विवरण
Create a PostHog endpoint with the right shape on the first try — covers query kind choice, name conventions, what to expose as variables (HogQL code_name vs insight breakdown), data_freshness_seconds, and whether to materialise on day one. Use when the user says "create an endpoint", "expose this query as an API", "turn this insight into an endpoint", or asks for help structuring a new endpoint. Steers away from common mistakes: materialising a query with cohort breakdowns or an ineligible compare query, inline-only variables on a materialised endpoint, unbounded date ranges, ambiguous names.
repo: PostHog/posthog
लोकप्रियता
- GitHub स्टार
- 41k
- रैंकिंग में स्थान
- #6860
- लाइसेंस
- —
- अपडेट की गई
- 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
discrawl
394kयह आपके एजेंट को Discord संदेशों के सेव किए गए स्थानीय आर्काइव में खोजने, उसका सारांश बनाने और उसकी ताज़गी जांचने में मदद करती है।
clickhouse-io
280kआपके एजेंट को ClickHouse databases में queries और schemas optimize करने में मदद करता है। high-performance analytical workloads के लिए best practices लागू करता है। जब analytical queries बहुत धीमी हों, तब इसका उपयोग करें।
scientific-db-pubmed-database
280kआपके एजेंट को बायोमेडिकल क्षेत्र के वैज्ञानिक लेख खोजने में मदद करता है। जिस रिसर्च में खास मेडिकल जानकारी चाहिए, उसके लिए यह काम का है।