Back to top

Polls

Polls is a simple API allowing consumers to view polls and vote in them.

Questions

Resources related to questions in the API.

Question Collection

this is Question Collection [/questions]

List All Questions
GET/questions

this is List All Questions [GET]

Example URI

GET /questions
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "question": "Favourite programming language?",
    "published_at": "2014-11-11T08:40:51.620Z",
    "url": "/questions/1",
    "choices": [
      {
        "choice": "Swift",
        "url": "/questions/1/choices/1",
        "votes": 2048
      },
      {
        "choice": "Python",
        "url": "/questions/1/choices/2",
        "votes": 1024
      },
      {
        "choice": "Objective-C",
        "url": "/questions/1/choices/3",
        "votes": 512
      },
      {
        "choice": "Ruby",
        "url": "/questions/1/choices/4",
        "votes": 256
      }
    ]
  }
]

Create a New Question
POST/questions

You may create your own question using this action. It takes a JSON object containing a question and a collection of answers in the form of choices.

  • question (string) - The question

  • choices (array[string]) - A collection of choices.

Example URI

POST /questions
Response  201
HideShow
Headers
Content-Type: application/json
Location: /questions/1
Body
{
  "question": "Favourite programming language?",
  "published_at": "2014-11-11T08:40:51.620Z",
  "url": "/questions/1",
  "choices": [
    {
      "choice": "Swift",
      "url": "/questions/1/choices/1",
      "votes": 0
    },
    {
      "choice": "Python",
      "url": "/questions/1/choices/2",
      "votes": 0
    },
    {
      "choice": "Objective-C",
      "url": "/questions/1/choices/3",
      "votes": 0
    },
    {
      "choice": "Ruby",
      "url": "/questions/1/choices/4",
      "votes": 0
    }
  ]
}

Question

Create a New Question
POST/questions/{question_id}

Example URI

POST /questions/question_id
URI Parameters
HideShow
question_id
number (required) 

ID of the Question in the form of an integer

question_type
string (required) 

Type of the Question in the form of an String

View a Questions Detail
GET/questions/

Example URI

GET /questions/
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "question": "Favourite programming language?",
  "published_at": "2014-11-11T08:40:51.620Z",
  "url": "/questions/1",
  "choices": [
    {
      "choice": "Swift",
      "url": "/questions/1/choices/1",
      "votes": 2048
    },
    {
      "choice": "Python",
      "url": "/questions/1/choices/2",
      "votes": 1024
    },
    {
      "choice": "Objective-C",
      "url": "/questions/1/choices/3",
      "votes": 512
    },
    {
      "choice": "Ruby",
      "url": "/questions/1/choices/4",
      "votes": 256
    }
  ]
}

Generated by aglio on 14 Nov 2017