डेवलपर्स

डेवलपर API

अपने स्वयं के बैकएंड से PollsLive को स्वचालित करें - पोल बनाएं, परिणाम पढ़ें, लाइव सेशन चलाएं और webhooks प्राप्त करें। Pro और Enterprise प्लान पर उपलब्ध।

अवलोकन

डेवलपर API एक REST API है जो /api/v1के अंतर्गत है। सभी अनुरोध और प्रतिक्रियाएं JSON हैं। पूरा, इंटरैक्टिव कॉन्ट्रैक्ट यहां है API संदर्भ; यह पेज आपको आपकी पहली सफल कॉल तक पहुंचाता है।

प्रमाणीकरण

एक वर्कस्पेस API कुंजी के साथ प्रमाणित करें जो Bearer टोकन के रूप में भेजी जाती है। एक उत्पन्न करें Studio → Developers में (Pro/Enterprise)। सीक्रेट केवल एक बार दिखाया जाता है - इसे कहीं सुरक्षित रखें; यदि आप इसे खो देते हैं, तो कुंजी रद्द करें और एक नई बनाएं।

Authorization हेडर
Authorization: Bearer plv_live_xxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxx

कुंजियां अपने वर्कस्पेस के भीतर एडमिन अधिकार के साथ कार्य करती हैं। कभी भी क्लाइंट-साइड कोड में कुंजी उजागर न करें - API को अपने सर्वर से कॉल करें।

You can also authenticate using an OAuth 2.0 Client Credentials access token for machine-to-machine integrations.

क्विकस्टार्ट

एक पोल बनाएं, इसे प्रकाशित करें, फिर परिणाम पढ़ें:

एक पोल बनाएं
curl -X POST https://pollslive.com/api/v1/polls \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Lunch vote",
    "content": {
      "questions": [{
        "id": "q1", "kind": "multiple_choice", "text": "Where to?",
        "type": "single",
        "options": [
          { "id": "a", "label": "Tacos" },
          { "id": "b", "label": "Sushi" }
        ]
      }]
    }
  }'
इसे प्रकाशित करें (create प्रतिक्रिया से id का उपयोग करें)
curl -X PATCH https://pollslive.com/api/v1/polls/POLL_ID \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "publish": true }'
परिणाम पढ़ें
curl https://pollslive.com/api/v1/polls/POLL_ID/results \
  -H "Authorization: Bearer $POLLSLIVE_KEY"

प्रश्न प्रकार

एक पोल टाइप की गई स्लाइड्स का एक डेक है। प्रत्येक स्लाइड पर kind सेट करें। सभी सात प्रकार API के माध्यम से बनाए जा सकते हैं:

  • multiple_choice - type (single/multiple), options[]। एसिंक्रोनस रूप से वोट करने योग्य।
  • quiz - options[], correctOptionIds[], timeLimitSec, points, speedBonus
  • scale - min, max, minLabel, maxLabel, statements[]
  • ranking - options[] (उत्तरदाता उन्हें क्रमबद्ध करते हैं)।
  • open_ended - maxLength, render (list/cloud)।
  • qa - moderated, allowUpvotes
  • content - केवल प्रदर्शन।
एक स्केल स्लाइड और एक quiz स्लाइड
{
  "questions": [
    {
      "id": "s1", "kind": "scale", "text": "How likely are you to recommend us?",
      "min": 0, "max": 10, "minLabel": "Not likely", "maxLabel": "Very likely"
    },
    {
      "id": "q2", "kind": "quiz", "text": "Capital of France?",
      "options": [{ "id": "a", "label": "Paris" }, { "id": "b", "label": "Rome" }],
      "correctOptionIds": ["a"], "timeLimitSec": 20, "points": 1000
    },
    {
      "id": "q3", "kind": "ranking", "text": "Rank these features by importance",
      "options": [
        { "id": "r1", "label": "Speed" },
        { "id": "r2", "label": "Reliability" },
        { "id": "r3", "label": "Price" }
      ]
    },
    {
      "id": "q4", "kind": "open_ended", "text": "Any other feedback?",
      "maxLength": 300, "render": "list"
    },
    {
      "id": "q5", "kind": "qa", "text": "Questions for the presenter",
      "moderated": true, "allowUpvotes": true
    }
  ]
}

छवियां, वीडियो और लिंक

कोई भी स्लाइड और कोई भी विकल्प mediaले जा सकता है। एक URL अपलोड करें या पास करें POST /media और लौटाए गए ऑब्जेक्ट को एम्बेड करें। छवियां डाउनलोड की जाती हैं, WebP में फिर से एन्कोड की जाती हैं और फिर से होस्ट की जाती हैं (छोटे पेलोड)। YouTube वीडियो और वेब लिंक अपनी URL रखते हैं और क्लाइंट-साइड रेंडर होते हैं, इसलिए आप वीडियो होस्ट करने के लिए कभी भुगतान नहीं करते। आप media: { type, url } को स्लाइड/विकल्प पर इनलाइन भी पास कर सकते हैं और सहेजते समय API इसे हल कर देता है।

एक छवि इंजेस्ट करें, फिर उसे एम्बेड करें
# 1) Ingest an image (returns { data: { type, url, storedUrl, width, height } })
curl -X POST https://pollslive.com/api/v1/media \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/cat.jpg" }'

# 2) Embed the storedUrl on a slide option
{ "id": "a", "label": "Option A", "media": { "type": "image", "url": "https://cdn.pollslive.com/media/abc.webp" } }

# Or pass the original URL inline - the API resolves it on save:
{ "id": "a", "label": "Option A", "media": { "type": "image", "url": "https://example.com/cat.jpg" } }

# YouTube on a question slide
{ "id": "q1", "kind": "content", "text": "Watch this first",
  "media": { "type": "youtube", "url": "https://youtu.be/dQw4w9WgXcQ" } }

प्रतिक्रियाएं और परिणाम

multiple_choice स्लाइड्स वोट लेती हैं POST /polls/{id}/votesके माध्यम से। हर दूसरा प्रकार एसिंक्रोनस प्रतिक्रियाएं लेता है POST /polls/{id}/responses के माध्यम से - स्लाइड से मेल खाने वाला फ़ील्ड भेजें (scaleValue, rankingOrder, text, या optionIds)। प्रति-स्लाइड एग्रीगेट पढ़ें GET /polls/{id}/resultsसे।

Record a scale response
curl -X POST https://pollslive.com/api/v1/polls/POLL_ID/responses \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "voterId": "user-123", "slideId": "s1", "scaleValue": 9 }'
Record a ranking response
curl -X POST https://pollslive.com/api/v1/polls/POLL_ID/responses \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "voterId": "user-123",
    "slideId": "q3",
    "rankingOrder": ["r2", "r1", "r3"]
  }'
Record an open-ended response
curl -X POST https://pollslive.com/api/v1/polls/POLL_ID/responses \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "voterId": "user-123", "slideId": "q4", "text": "Great product!" }'

Live sessions & session control

A live session lets you drive a poll in real time in front of an audience. Create a session via the API, share the PIN or QR code, then control pacing and results visibility with the control endpoint.

Create a session
curl -X POST https://pollslive.com/api/v1/sessions \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "pollId": "POLL_ID" }'
# Response includes: id, pin, status, currentSlideIndex, hostToken (once)
Advance to the next slide
curl -X POST https://pollslive.com/api/v1/sessions/SESSION_ID/control \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "action": "next" }'

All session control actions

POST to /sessions/{id}/control with one of these action strings:

ActionDescription
startOpen the session and broadcast the first slide.
nextAdvance to the next slide.
prevGo back to the previous slide.
gotoJump to a specific slide - pass slideIndex (0-based) alongside action.
showResultsReveal live results for the current slide to participants.
hideResultsHide results (stop showing them to participants).
lockLock answers - participants can no longer submit for the current slide.
unlockUnlock answers so participants can respond.
endClose the session. Participants see a results summary.
Jump to slide 2 (0-based)
{ "action": "goto", "slideIndex": 2 }

AI branching

AI branching adds conditional skip logic to your poll with a plain-English instruction - no need to manually wire conditions. Pro and Enterprise only.

Apply branching to a poll
curl -X POST https://pollslive.com/api/v1/polls/POLL_ID/branch \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "instruction": "If the respondent selects Yes on question 1, skip to question 3. Otherwise go to question 2."
  }'
# Response: { data: { draftJson: { ... conditions: [...] }, source: "openai" | "rules" } }

Exporting results

Download aggregate poll results as a UTF-8 CSV file. Each row contains the slide number, question text, type, answer label, and count or value. Pro and Enterprise only.

Export a poll's results as CSV
curl https://pollslive.com/api/v1/polls/POLL_ID/export \
  -H "Authorization: Bearer $POLLSLIVE_KEY" \
  --output results.csv

# CSV structure:
# Slide, Question, Type, Answer / Label, Count / Value
# 1, "Where to?", multiple_choice, Tacos, 12
# 1, "Where to?", multiple_choice, Sushi, 8
# 2, "Rate your experience", scale, Average, 8.50
# 2, "Rate your experience", scale, Rating 10, 5

Endpoints

  • पोल - GET/POST /polls, GET/PATCH/DELETE /polls/{id}
  • परिणाम - GET /polls/{id}/results, GET/POST /polls/{id}/responses
  • वोट - GET/POST /polls/{id}/votes
  • मीडिया - POST /media
  • सेशन - POST /sessions, GET /sessions/{id}, POST /sessions/{id}/control
  • AI - POST /polls/{id}/branch
  • Export - GET /polls/{id}/export

अनुरोध/प्रतिक्रिया प्रारूप देखें और लाइव कॉल आज़माएं API संदर्भमें।

त्रुटियां और रेट लिमिट

त्रुटियां एक स्थिर लिफ़ाफ़े का उपयोग करती हैं:

त्रुटि प्रतिक्रिया
{ "error": { "code": "not_found", "message": "Poll not found." } }

सामान्य कोड: 401 अमान्य/अनुपस्थित कुंजी, 402 प्लान अपग्रेड आवश्यक, 404 नहीं मिला, 409 विरोध (जैसे पहले ही वोट किया, पोल बंद), 422 सत्यापन विफल, 429 रेट लिमिट।,

Rate limits

The API allows 120 requests per minute per key for all endpoints. Media ingestion (POST /media) is separately capped at 30 requests per minute. HTTP 429 is returned when exceeded - back off and retry.

EndpointLimit
All endpoints120 req / min
POST /media30 req / min

OAuth2 (Enterprise)

Enterprise वर्कस्पेस स्थिर कुंजियों के बजाय OAuth2 क्लाइंट-क्रेडेंशियल्स का उपयोग कर सकते हैं। यह रोल आउट हो रहा है - हमसे संपर्क करें अपने खाते के लिए इसे सक्षम करने के लिए।

अभी भी कोई सवाल है?

हमारी टीम मदद करने में खुश होगी।

हमसे संपर्क करें
डेवलपर API - क्विकस्टार्ट और प्रमाणीकरण | PollsLive | PollsLive