Votingo is a open-sourced real-time polling app created with the MERN stack. Votingo lets you create edit, update, delete public polls and vote on them publicly. You can make polls without signing or sign in to make polls private, you can also vote without being signed in or sign in for the option of putting your name on your vote.
Votingo has both a REST api and a graphql api
all requests require an api key which is provided in the request header
interface headers = {
"X-API-Key": String
}
// GET ALL POLLS
"https://api.votingo.xyz/v1/polls" ->
[
{
name: String,
description: String | null
creator: String, // creator's id or "anonymous" if there is no creator
_id: String,
options: [Object],
}
]
// GET A SINGLE POLL
"https://api.votingo.xyz/v1/polls/:id" ->
{
name: String,
description: String | null
creator: String, // creator's id or "anonymous" if there is no creator
_id: String,
options: [Object],
}
// request body
interface PollBody = {
name: String,
description?: String
options: Array<String> // array of option names
}
"https://api.votingo.xyz/v1/polls" ->
{
name: String,
description: String | null
creator: String, // creator's id or "anonymous" if there is no creator
_id: String,
options: [Object],
}
// request body
interface PollVote = {
option: String // name of vote option
}
"https://api.votingo.xyz/v1/polls/vote/:id" ->
{
name: String,
description: String | null
creator: String, // creator's id or "anonymous" if there is no creator
_id: String,
options: [Object],
message: "Thanks for Voting!"
}
"https://api.votingo.xyz/v1/polls" ->
{
name: String,
description: String | null
creator: String, // creator's id or "anonymous" if there is no creator
_id: String,
options: [Object],
message: "Successfully deleted the poll"
}
https://api.votingo.xyz/graphql
Make a GET request to the graphql endpoint to get the playground with built in docs
The two types of allowed operations in Votingo's GraphQL API are queries and mutations. Comparing GraphQL to REST, queries operate like GET requests, while mutations operate like POST/PATCH/DELETE. The mutation name determines which modification is executed.
GraphQL queries return only the data you specify. To form a query, you must specify fields within fields (also known as nested subfields) until you return only scalars.
Queries are structured like this:
query {
JSON objects to return
}
To form a mutation, you must specify three things:
- Mutation name. The type of modification you want to perform.
- Input object. The data you want to send to the server, composed of input fields. Pass it as an argument to the mutation name.
- Payload object. The data you want to return from the server, composed of return fields. Pass it as the body of the mutation name.
Mutations are structured like this:
mutation {
mutationName(input: {MutationNameInput!}) {
MutationNamePayload
}
The input object in this example is MutationNameInput, and the payload object is MutationNamePayload.
In the mutations reference, the listed input fields are what you pass as the input object. The listed return fields are what you pass as the payload object.