MasterPoll API | Docs

MasterPoll API | Docs

MasterPoll


Master Poll - Sunday, 13 october 2019


The MasterPoll API is an HTTP-based interface created for developers for manage polls from other services.


⚠️ Warning

This article has been created for testing of MasterPollBot's API. Try it and report all bugs with @MasterPollSupport or in @MasterPollChat.


Authorizing your request

Each user have a unique authentication token, send /api in the chat with the Bot. The token looks something like 123456789:ABC-DEF1234ghIkl-zyx57W2v1u123ew11, but we'll use simply <token> in this document instead. You can revoke your token with /api > Revoke Token.


Making requests

All queries to the MasterPoll API must be served over HTTPS and need to be presented in this form: https://api.masterpoll.xyz/user<token>/METHOD_NAME. Like this for example:

https://api.masterpoll.xyz/user123456789:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe


1. Methods


2. Types


Available methods

We support GET and POST HTTP methods. The response contains a JSON object, which always has a Boolean field ok. If ok equals true, the request was successful, and the result of the query can be found in the result field. In case of an unsuccessful request, ok equals false, and the error is explained in the error field (e.g. ID_REQUIRED). All queries must be made using UTF-8.


getAllPolls

Use this method to get all polls you have created with our Bots. This method return an array of Poll type.

Sample request
https://api.masterpoll.xyz/user<token>/getAllPolls


getActivePolls

Use this method to get all opened polls you have created with our Bots. This method return an array of Poll type.

Sample request
https://api.masterpoll.xyz/user<token>/getActivePolls


getPoll

Use this method to get data from a specific poll. This method return a Poll type.

  • id (Integer)
    Required. Identifier of the poll, you can find them on the list command.
  • owner_id (Integer)
    Optional. By default your user_id is used. Telegram ID of the owner of a poll.
Sample request
https://api.masterpoll.xyz/user<token>/getPoll?id=96&owner_id=244432022


getMe

Use this method to get your Telegram's data from our database.

Sample request
https://api.masterpoll.xyz/user<token>/getMe


openPoll

Use this method for open a closed poll.

  • id (Integer)
    Required. Identifier of the poll, you can find them on the list command.
Sample request
https://api.masterpoll.xyz/user<token>/openPoll?id=25


closePoll

Use this method for close a opened poll.

  • id (Integer)
    Required. Identifier of the poll, you can find them on the list command.
Sample request
https://api.masterpoll.xyz/user<token>/closePoll?id=25


deletePoll

Use this method to delete a poll. This action is irreversible.

  • id (Integer)
    Required. Identifier of the poll, you can find them on the list command.
Sample request
https://api.masterpoll.xyz/user<token>/deletePoll?id=25


editPoll

Use this method to edit a poll. This method return the settings field edited successfully.

  • id (Integer)
    Required. Identifier of the poll, you can find them on the list command.
  • settings (Array)
    Required. Array of options to edit on the poll. View the Settings type.
Sample request
https://api.masterpoll.xyz/user<token>/editPoll?id=25&settings=[%27disable_web_page_preview%27:true]


createPoll

Use this method to create a new poll. This method create and return a Poll type.

  • title (String, 1-512 characters)
    Required. This is the title of your new poll.
  • description (String, 1-512 characters)
    Optional. This is the description of your new poll.
  • type (String, 1-64 characters)
    Required. This is the type of your new poll.
  • privacy (String, 1-32 characters)
    Required. This is the anonymous option of your new poll.
  • settings (Array)
    Optional. This is the settings of your new poll.
  • choices (Array)
    Required for the type 'vote', 'doodle' and 'limited doodle'. This is the choices of your new poll.
  • start_rating_range (Integer, 1-9)
    Required for the type 'rating'. This is the start namber of your rating poll.
  • end_rating_range (Integer, 2-10)
    Required for the type 'rating'. This is the end number of your rating poll.
Sample request
https://api.masterpoll.xyz/user<token>/createPoll?title=Test%20API&description=Successfully&type=participation&privacy=personal


graph

Use this method to get a graph image from Telegra.ph. This method return a String url. This method work only with 'vote', 'doodle', 'limited doodle' and 'rating' type of poll.

  • id (Integer)
    Required. Identifier of the poll, you can find them on the list command.
  • owner_id (Integer)
    Optional. By default your user_id is used. Telegram ID of the owner of a poll.
  • type (String)
    Required. This is the type of graph to render. Choose 'bar' to get a bar graph or 'pie' to get a pie graph.
Sample request
https://api.masterpoll.xyz/user<token>/editPoll?id=25&type=pie



Available types

All types used in the Telegraph API responses are represented as JSON-objects. Optional fields may be not returned when irrelevant.


Poll

This type return the poll's data.

  • poll_id (Integer)
    This is the identifier of the poll.
  • owner_id (Integer)
    This is the Telegram identifier of the owner.
  • title (String, 0-512 characters)
    This is the title of the poll.
  • description (String, 0-512 characters)
    This is the description of the poll.
  • privacy (String)
    This is the privacy of the poll. It can be 'anonymous' or 'personal' poll.
  • type (String)
    This is the type of poll. It can be 'vote', 'doodle', 'limited doodle', 'board', 'participation' or 'rating'.
  • max_choices (Integer)
    This is the max of choices for limited doodle poll.
  • participants (Array of strings)
    If the type of poll is 'participation' here you can find all names of the participants.
  • comments (Array of strings)
    If the type of poll is 'board' here you can find all comments. If the privacy is 'personal' the keys of all comments is the name of its.
  • choices (Array of strings)
    If the type of poll is 'vote', 'doodle' or 'limited doodle' here you can find all options and the number of voters for each option. If the privacy is 'personal' the values of all options will be an array of names.


Settings

This type return the poll's settings.

  • disable_web_page_preview (Boolean)
    Enable/Disable the web page preview for the message.
  • disable_web_content_preview (String, 0-1024 characters)
    Enable/Disable the content preview for the message.
  • sort (Boolean)
    Sort the options by number of votes.
  • appendable (Boolean)
    Enable/Disable the append option.
  • notification (Boolean)
    Enable/Disable notifications for append or board options.
  • votes_limit (Integer, 0-999)
    Set votes limit or remove it with 0.