सामग्री पर जाएं
PollsLive

June 28, 2026 · 9 min read

Poll API: अपने product में live polls

अपने code से polls बनाइए, live sessions चलाइए, results पढ़िए और webhooks पाइए: SaaS और community apps के लिए PollsLive poll API की developer guide।

By the PollsLive team·DevelopersHow-to

अगर आपके product के पास audience है (एक webinar tool, एक LMS, एक community platform, एक events app), तो देर-सबेर आप उसके अंदर polls चाहेंगे। real-time voting, anti-fraud और एक results UI शून्य से बनाना महीनों का काम है। PollsLive को embed करना एक दोपहर का। यह रहा developer का रास्ता: एक poll बनाएँ, embed डालें, results पढ़ें और webhooks पाएँ, डेवलपर दस्तावेज़ पर असली calls के साथ।

Authentication: एक अकेला Bearer token

Studio → डेवलपर API में एक workspace API key generate करें (वे `plv_live_…` जैसी दिखती हैं) और उसे एक Bearer token के रूप में भेजें। server-to-server उपयोग के लिए कोई OAuth नाच नहीं; जब आपको per-tenant scope चाहिए तब OAuth client-credentials उपलब्ध है।

export POLLSLIVE_API=https://pollslive.com/api/v1
export POLLSLIVE_KEY=plv_live_xxxxxxxxxxxxxxxxxxxx

# Every request carries the key as a Bearer token:
#   Authorization: Bearer $POLLSLIVE_KEY
# Limits and HTTP 429 handling: https://pollslive.com/docs/developers/rate-limits

Step 1: अपने code से एक poll बनाएँ

एक poll एक typed deck है: content.questions slides का एक array है, हर एक के साथ एक kind discriminator। POST /polls नई poll लौटाता है, जिसमें उसका slug शामिल है, जो उसे embed करने के लिए आपको चाहिए बस वही है।

curl -sS -X POST "$POLLSLIVE_API/polls" \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Which feature should we build next?",
    "renderingMode": "ASYNC",
    "content": {
      "questions": [{
        "id": "next",
        "kind": "multiple_choice",
        "text": "Which feature should we build next?",
        "options": [
          { "id": "a", "label": "Dark mode" },
          { "id": "b", "label": "Mobile app" },
          { "id": "c", "label": "Public API" }
        ]
      }]
    }
  }'
# → { "poll": { "slug": "which-feature-x7f2", ... } }

Step 2: इसे अपने UI में embed करें

एक-line वाले iframe से poll को किसी भी page पर रखें: कोई SDK नहीं, कोई client library नहीं और उसके साथ कोई third-party trackers नहीं। यह अपने container के मुताबिक़ ढलता है और React, WordPress, Webflow या सादे HTML के अंदर काम करता है।

<iframe
  src="https://pollslive.com/embed/which-feature-x7f2"
  width="100%" height="520"
  style="border:0;border-radius:12px"
  loading="lazy" title="PollsLive poll"></iframe>

Step 3: जब चाहें तब results पढ़ें

अपने ही dashboards के लिए counts on-demand पाएँ, या reporting के लिए एक CSV export करें। results slide-दर-slide counts के साथ और (scales के लिए) औसत के साथ लौटते हैं।

curl -sS "$POLLSLIVE_API/polls/POLL_ID/results" \
  -H "Authorization: Bearer $POLLSLIVE_KEY"
# → { "questions": [ { "id": "next", "options": [
#       { "id": "a", "label": "Dark mode",  "count": 64 },
#       { "id": "b", "label": "Mobile app", "count": 41 },
#       { "id": "c", "label": "Public API", "count": 95 } ] } ] }

Step 4: webhooks के साथ updates पाएँ

API को poll करना काम करता है, पर webhooks बेहतर हैं। एक endpoint register करें और PollsLive HMAC से signed events भेजता है (vote.created, poll.published, session.started/ended) ताकि आपका app real-time में react करे। signature verify करें और फिर अपना UI update करें या event को आगे भेज दें।

import crypto from "node:crypto";

// header: the X-PollsLive-Signature value, "t=<unix>,v1=<hex>"
export function verify(rawBody, header, secret, toleranceSec = 300) {
  const parts = Object.fromEntries(
    header.split(",").map((kv) => kv.split("=")),
  );
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;

  const expected = crypto
    .createHmac("sha256", secret)
    .update(`${t}.${rawBody}`)
    .digest("hex");

  const a = Buffer.from(expected);
  const b = Buffer.from(parts.v1 ?? "");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

बस यही है पूरा चक्र: बनाएँ, embed करें, पढ़ें, react करें। पूरे reference के लिए (हर endpoint, scope और event type) developer documentation देखें, और एक व्यावहारिक उदाहरण के लिए, webhooks के साथ live results को एक internal dashboard पर लाना।

Tip

create और publish के लिए REST API से शुरू करें, live result pushes चाहिए तो webhooks जोड़ें।

No-code sharing के लिए share and embed your poll देखें।

PollsLive पर बनाएँ: अपने ही code से polls बनाएँ, live sessions चलाएँ, results पाएँ और webhooks पाएँ।

developer documentation पढ़ें

आपको साइन इन रखने और डुप्लिकेट वोट रोकने के लिए हम आवश्यक कुकीज़ का उपयोग करते हैं। आपकी अनुमति से, हम पेज व्यू गिनने के लिए Cloudflare Web Analytics और यह देखने के लिए Whop Pixel का भी उपयोग करते हैं कि कौन-सी विज़िट खरीद तक ले जाती हैं। कुकी नीति