pollstR (version 2.0.1)

pollster_api: Make Huffpost Poster API request

Description

The function pollster_api is the lower-level function for making a request to the Huffpost Pollster API. There is also a function for each methods provided by the API.

Usage

pollster_api(path, query = NULL, version = "v2", response_type = NULL,
  as = "parsed", ...)

pollster_polls(cursor = NULL, tags = NULL, question = NULL, sort = c("created_at", "updated_at"), ...)

pollster_polls_slug(slug, ...)

pollster_questions(cursor = NULL, tags = NULL, election_date = NULL, ...)

pollster_questions_slug(slug, ...)

pollster_questions_responses_clean(slug, ...)

pollster_questions_responses_raw(slug, ...)

pollster_charts(cursor = NULL, tags = NULL, election_date = NULL, ...)

pollster_charts_slug(slug, ...)

pollster_charts_polls(slug, ...)

pollster_charts_trendlines(slug, ...)

pollster_tags(...)

Arguments

path

The API endpoint, as a character vector. If the length is greater than one, the elements will be collapsed and separated by "/".

query

Query parameters as a list.

version

The API version.

response_type

Response content type. One of "json", "tsv", or "xml". Some endpoints are json/xml, and some are tsv.

as

Passed to content.

...

Arguments passed to GET.

cursor

Special string used to handle pagination.

tags

Character vector of tag names.

question

Question slug.

sort

Sort order of polls.

slug

Unique identifier for the poll or question or chart.

election_date

A date object or a string in "YYYY-MM-DD" format for the election date.

Value

A pollster_api object which is a list with elements

  • content:The parsed content of the response,

  • url:The URL of the request,

  • response:The request object returned by GET.

Functions

  • pollster_polls: Get polls. See API docs.

  • pollster_polls_slug: Get a single poll. See API docs.

  • pollster_questions: Get questions. See API docs.

  • pollster_questions_slug: Get a poll question. See API Docs.

  • pollster_questions_responses_clean: Get a table where each row where each row is a single poll question + subpopulation and columns are response labels. See API Docs.

  • pollster_questions_responses_raw: Get a table where each row is single poll question + subpopulation + response. See API Docs.

  • pollster_charts: Return a list of charts. See hrefhttps://app.swaggerhub.com/swagger-ui/#!/default/get_chartsAPI Docs.

  • pollster_charts_slug: Get a chart. See hrefhttps://app.swaggerhub.com/swagger-ui/#!/default/get_charts_slugAPI Docs.

  • pollster_charts_polls: Get table with one row per poll used in a chart. See API Docs.

  • pollster_charts_trendlines: Get table with the trendline estimates used in a chart. See API Docs.

  • pollster_tags: Return the list of tags used in polls, questions, and charts. See API Docs.