An R interface to the 'typeform' < https://typeform.com> application program interface. Also provides functions for downloading your results.
Typeform is a company that specializes in online form building. This R package allows users to download their form results through the exposed API (V2).
rtypeform package now uses V2. This is a breaking change from
the previous version.**
The package can be installed from CRAN
and loaded in the usual way.
library("rtypeform")#> This package now uses V2 of the typeform API.This update breaks ALL code (sorry, not my fault).The README provides some guidence on using the new functions.You will need to generate a new API. See the README for details.
To use this package you need a V2 API key. It is fairly easy to obtain one. See typeform’s help page. The token will look something like
Whenever the package refers to
api, this is the object it needs.
Once you have this key, we can extract data from typeform
api = "XXXXX"# Was get_typeforms() in V1 of the packageforms = get_forms(api)
The forms object is also contains attributes containing the total number of forms.
attr(forms, "total_items")#>  5
If you don’t pass your
api key as an argument, it will attempt to read
typeform_api2 from your
.Renviron file, via
Sys.getenv("typeform_api2"). If this variable is set correctly, then
you can omit the
# See ?get_forms for further detailsforms = get_forms()
In all function calls below, the
api argument can be omitted if the
environment variable is set (see Efficient R programming
for more details).
You can download data from a particular typeform via
# Most recent typeformform_id = forms$form_idq = get_responses(form_id, completed = TRUE)
q is a list. The first element is
meta that contain
details on the user, such as, their
other list elements are responses to each question.
There are a number of options for downloading the data. For example
q = get_responses(form_id, completed = TRUE, page_size = 100)
?get_responses() help page for other options.
Since the responses is list, we get to perform lots of map operations. I
purrr and the
tidyverse make this a bit easier. To see
the question types we can use string a few
map() commands together
library("tidyverse")question_types = q[-1] %>% # Remove the metamap(~select(.x, type)) %>%map_df(~slice(.x, 1)) %>%pull()
Imagine we only want:
completed = TRUE.
page_size = 5.
since = "2018-01-01 11:00:00"# convert to date-timesince = lubridate::ymd_hms(since)q = get_responses(form_id, completed = TRUE,page_size = 5, since = since)
Development of this package was supported by Jumping Rivers
get_results()now depreciated. Instead, use
get_questionnaire(). This returns a list with http_status, question stats, questions, completed, and uncompleted responses (thanks to @hrbrmstr).
get_results()function (thanks to @1beb).