Developers

Build with StrawPoll

Create polls and forms from your own code, collect responses and read the results. One API key and a few lines are all it takes.

Create your first poll

Three steps from nothing to a live poll.

  1. 01

    Create an API key

    Create one in Settings → API keys and put it in an environment variable, so it stays out of your code:

    shell
    export STRAWPOLL_API_KEY="sp_your_key"
  2. 02

    Run a script

    Save the script and run it. It publishes a poll and prints its voting and results links.

    curl -s -X POST "https://new.strawpoll.com/api/v4/polls" \
      -H "X-API-Key: $STRAWPOLL_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "title": "Where should we go for lunch?",
      "options": ["Pizza", "Sushi", "Tacos"]
    }' \
      | jq -r '.urls.voteUrl, .urls.resultsUrl'
    Run sh create-poll.sh · Needs jq
  3. 03

    Read the results

    Fetch the poll by its id, the end of its link. Each option comes with its votes.

    curl "https://new.strawpoll.com/api/v4/polls/w8Jq3KdN" \
      -H "X-API-Key: $STRAWPOLL_API_KEY"

Everything for developers