In this vignette, we demonstrate how to interact with the Nettskjema API to perform the following tasks: 1. Retrieve a list of all forms you have access to. 1. Download reports associated with a form.
Before you begin, ensure that you have already set up authentication. If you haven’t, refer to the vignette on authentication setup.
Additionally, load the required package:
library(nettskjemar)
ns_sitrep()
#>
#> ── Nettskjema API Sitrep ───────────────────────────────────────────────────────
#> ✔ nettskjemar version: 1.0.3
#>
#> ── Nettskjema API Configuration ──
#>
#> ℹ API URL is set to: "https://nettskjema.no/api/v3/"
#> ✔ Client ID: Valid format and length.
#> ✔ Client Secret: Valid format and length.
#>
#> ── API Connectivity ──
#>
#> ✔ Successfully connected to API
#> ℹ Tested by fetching client profile
#>
#> ── Environment ──
#>
#> ✔ R version: "R version 4.5.1 (2025-06-13)"
#> ✔ OS: "Darwin" "24.6.0"
#> ────────────────────────────────────────────────────────────────────────────────
To see which forms you have access to, use the
ns_get_forms
function.
# Retrieve all forms
forms <- ns_get_forms()
head(forms)
#> formId title openFrom openTo
#> 1 123823 API test form 2023-06-01T20:55:49 2024-06-02T02:00:02
#> lastSubmissionDate modifiedDate personalDataErasedDate
#> 1 2023-06-01T20:59:50 2025-08-26T13:08:28 NA
#> deliveryDestination anonymous numberOfDeliveredSubmissions owners
#> 1 DATABASE FALSE 3 3
#> isDictaphone myFormsFormListingGroup open
#> 1 FALSE OLD FALSE
If you prefer to get the raw list format as returned by the API, use
asis = TRUE
.
# Retrieve raw form data
raw_forms <- ns_get_forms(asis = TRUE)
# Display the raw response
print(raw_forms)
#> [[1]]
#> [[1]]$formId
#> [1] 123823
#>
#> [[1]]$title
#> [1] "API test form"
#>
#> [[1]]$openFrom
#> [1] "2023-06-01T20:55:49"
#>
#> [[1]]$openTo
#> [1] "2024-06-02T02:00:02"
#>
#> [[1]]$lastSubmissionDate
#> [1] "2023-06-01T20:59:50"
#>
#> [[1]]$modifiedDate
#> [1] "2025-08-26T13:08:28"
#>
#> [[1]]$personalDataErasedDate
#> NULL
#>
#> [[1]]$deliveryDestination
#> [1] "DATABASE"
#>
#> [[1]]$anonymous
#> [1] FALSE
#>
#> [[1]]$numberOfDeliveredSubmissions
#> [1] 3
#>
#> [[1]]$owners
#> [1] 3
#>
#> [[1]]$isDictaphone
#> [1] FALSE
#>
#> [[1]]$myFormsFormListingGroup
#> [1] "OLD"
#>
#> [[1]]$open
#> [1] FALSE
Each form can have reports such as CSV, Excel, or SPSS files
associated with it. Use the ns_get_form_reports
function to
download these reports.
For custom output locations, make sure to provide the full file path
in the path
argument.