npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-potato

v1.0.0

Published

A wrapper for the opinion potato API

Downloads

2

Readme

Status GitHub Issues GitHub Pull Requests License


Table of Contents

About

Node Potato is a JavaScript API wrapper for Opinion Potato. It provides a simple and easy-to-use interface for interacting with the Opinion Potato API, allowing you to easily add Opinion Potato functionality to your own applications.

An API key and API identifier is required to use this API wrapper. To obtain an API Key, you must first contact: [email protected] asking for a key, stating what you will use it for, and how you will interact with it.

If your application is successful, an API key and API identifier key will be sent to you via email.

API Key = This is your secure key for authenticating with the API. You should never share this with anyone. If you need a new key, contact [email protected]

API Identifier = This is a unique number assigned to you which will allow you to query your own polls separately from the public list. This is mainly used when interacting with Private polls that you have created

Installing

For Installation With NPM

npm i node-potato

Usage

Below is the basic usage of Node Potato

Create Potato

Creating the potato object

const { potato } = require("node-potato");

//Creates a new potato object
let Potato = new potato({apiKey: "API_KEY", apiIdentifier: API_IDENTIFIER});

Note: API_IDENTIFIER must be passed as an int

Get Poll

Get a poll

//Get an opinion potato poll with the Id 626288817
Potato.getPoll(626288817).then((value) =>{

    console.log(value);

});

/*expected output:{
  pollId: 626288817,
  question: 'Which political system do you believe in',
  topic: 'politics',
  optionA: 'Democracy',
  optionB: 'Socialism',
  optionAVotes: 2,
  optionBVotes: 141,
  CreatedOn: '2023-07-30T23:19:39.228Z',
  archived: false,
  visibility: 'Public',
  pollSlug: 'which-political-system-do-you-believe-in-democracy-or-socialism'
}*/

Get All Polls

Gets all public polls listed on opinion potato

//Gets all public polls
Potato.getAllPolls().then((value) =>{

    console.log(value);

});

/*expected output:[
    {
        pollId: 626288817,
        question: 'Which political system do you believe in',
        topic: 'politics',
        optionA: 'Democracy',
        optionB: 'Socialism',
        optionAVotes: 2,
        optionBVotes: 141,
        CreatedOn: '2023-07-30T23:19:39.228Z',
        archived: false,
        visibility: 'Public',
        pollSlug: 'which-political-system-do-you-believe-in-democracy-or-socialism'
    },
    ...
]*/

Get Private Poll

Get a poll you have created that is private

//Gets the private poll with the Id 644304039
Potato.getPrivatePoll(644304039).then((value) =>{

    console.log(value);

});

/*expected output:{
        pollId: 626288817,
        question: 'Which political system do you believe in',
        topic: 'politics',
        optionA: 'Democracy',
        optionB: 'Socialism',
        optionAVotes: 2,
        optionBVotes: 141,
        CreatedOn: '2023-07-30T23:19:39.228Z',
        archived: false,
        visibility: 'Private',
        pollSlug: 'which-political-system-do-you-believe-in-democracy-or-socialism'
    }*/

Vote Poll

Vote on a poll

//Votes on the poll with and Id of 992659119 option A
Potato.submitVote(992659119, "A").then((value) =>{

    console.log(value);
    
});
//expected output: { Message: 'Vote applied successfully', optionA: 5, optionB: 0 }


//Votes on the poll with and Id of 992659119 option B
Potato.submitVote(992659119, "B").then((value) =>{

    console.log(value);
    
});
//expected output: { Message: 'Vote applied successfully', optionA: 5, optionB: 1 }

Create Poll

Creates a public poll on Opinion Potato

//Create the options for the poll
const options = {
    "question":"test poll for the api wrapper",
    "optionA":"optionA",
    "optionB":"optionB",
    "topic":"science-technology",
    "visibility":"Public"
}

//Submit poll to Opinion Potato
Potato.createPoll(options).then((value) =>{

    console.log(value)

})

//expected output: { pollId: 133486009 }


//Create the options for the poll
const options = {
    "question":"test private poll for the api wrapper",
    "optionA":"optionA",
    "optionB":"optionB",
    "topic":"science-technology",
    "visibility":"Private"
}

//Submit a private poll to Opinion Potato
Potato.createPoll(options).then((value) =>{

    console.log(value)

})

//expected output: { pollId: 133486036 }

Note:

  • The question should not include a question mark (?)
  • A poll must not already exist with the same question and answer combination
  • Topic must include one of the following:
    • music
    • arts-crafts
    • religion
    • politics
    • sport
    • food-drink
    • literature
    • science-technology
    • education
    • nature-environment
    • fashion
    • history
    • lifestyle
    • climate
    • celebrities
    • society
    • health
    • countries
    • war
    • space
    • culture
    • travel
    • beliefs
    • gaming
    • money

Authors