Fetching Data From KoboToolbox
fetching-data-from-kobotoolbox.Rmd
library(SWMadagascar)fetch_kobotoolbox_data
This function will fetch data from the KoboToolbox API.
To do this, you’ll need to set up an account with KoboToolbox and obtain an API token. Once you have the token, you can use it to authenticate your requests to the KoboToolbox API.
# install.packages("robotoolbox")Assuming your API token is stored securely, you can use the following function to assert your settings:
library(robotoolbox)
kobo_settings()
#> <robotoolbox settings>
#> KoboToolbox URL: https://kf.kobotoolbox.org
#> KoboToolbox API Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1d2e5Now, to list the projects we have access to:
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
kobo_asset_list()
#> # A tibble: 6 × 8
#> uid name asset_type owner_username date_created date_modified deployed
#> <chr> <chr> <chr> <chr> <chr> <chr> <lgl>
#> 1 aPv8BRqCC… marc… survey aroo 2026-01-09 … 2026-01-26 1… TRUE
#> 2 aRdutgajY… marc… survey aroo 2026-01-09 … 2026-01-26 1… TRUE
#> 3 akbxu4SFk… vaon… survey aroo 2026-01-09 … 2026-01-09 1… TRUE
#> 4 aLwCykmdH… vaon… survey aroo 2026-01-09 … 2026-01-09 1… TRUE
#> 5 aeJMKmfiS… vaon… survey aroo 2025-10-10 … 2025-11-10 1… TRUE
#> 6 aNQpg9EDc… vaon… survey aroo 2025-10-10 … 2025-11-10 1… TRUE
#> # ℹ 1 more variable: submissions <int>Perfect!
fetch_kobotoolbox_data()
#> [1] 1