The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Getting public data

This document explains how to interact with Trello from R with read-only access. For editing/private access, see Authorized access and Editing functions.

Introduction

Most things in Trello live on a Board. A board encapsulates a hierarchy of resources: Members, Teams, Lists, Cards, Custom fields and Actions. Some of the resources may contain additional data (e.g. cards may have labels, due dates etc.) or other nested resources (e.g. boards may have lists, cards, label definitions etc.)

Each resource can have a parent resource (e.g. a board is a parent resource for a card) and child resources (a card can include actions as a child resource). A resource can have more than one parent (a board and a list are both parents to a card).

To access a resource, you need to know its unique ID, or the ID of its parent resource. In some cases (e.g. boards or cards), you can use the resource URL instead.

Getting data

The following snippet fetches 5 cards from the trelloR demo board. This is a public board and so does not require authentication:

library(trelloR)
#> R API for Trello
#> Disclaimer: trelloR is not affiliated, associated, authorized, endorsed by or
#> in any way officially connected to Trello, Inc. (www.trello.com).
board = "https://trello.com/b/wVWPK9I4/r-client-for-the-trello-api"
param = list(fields = "id,name,idList,labels")
cards = get_board_cards(board, query = param, limit = 5)
#> GET: https://api.trello.com/1/board/wVWPK9I4/cards?fields=id%2Cname%2CidList%2Clabels&limit=5
#> OK (HTTP 200).
#> Fetched 5 results
#> 
#> Request complete: 5 results.

The result is a data.frame (or a tibble if installed):

cards[, 1:3]
#> # A tibble: 5 × 3
#>   id                       name                                 idList          
#>   <chr>                    <chr>                                <chr>           
#> 1 600f54e86a3733550971ed6b Due date - completed                 600f54e86a37335…
#> 2 600f54e86a3733550971ed75 Comments                             600f54e86a37335…
#> 3 600f54e86a3733550971ed6f How to install                       600f54e86a37335…
#> 4 600f54e86a3733550971ed73 Usage example                        600f54e86a37335…
#> 5 600f54e86a3733550971ed71 I found a bug! I want a new feature! 600f54e86a37335…

Nested resources can be obtained by querying their parent resource. In the example above, we didn’t have to query each card individually - instead, we just queried the board resource to get all of its cards.

A general way of retrieving data from a board is to use the function get_resource() which allows you to specify parameters of the query. However, trelloR also includes a number of wrappers for specific resources. For example:

The following example creates a wrapper to fetch updates to a given card. This is represented by the “updateCard” action type passed to filter:

get_card_updates = function(id, ...) {
  get_resource(parent = "card", child  = "actions", id = id,
               filter = "updateCard", ...)
}
card_updates = get_card_updates(cards[["id"]][4])
#> GET: https://api.trello.com/1/card/600f54e86a3733550971ed73/actions?limit=100&filter=updateCard
#> OK (HTTP 200).
#> Fetched 1 results
#> 
#> Request complete: 1 results.
card_updates[, 1:5]
#> # A tibble: 1 × 5
#>   id                       idMemberCreator          appCreator type       date  
#>   <chr>                    <chr>                    <lgl>      <chr>      <chr> 
#> 1 600f56052f0cbc6b0308e3f2 541c236b4467f97670e44e04 NA         updateCard 2021-…

Error handling

If a request fails andretry.times > 1, it will be re-attempted. If it fails after all attempts are spent, the subsequent behavior is determined by the on.error argument.

error = get_card_actions(id = "wrong_id", on.error = "message")
#> GET: https://api.trello.com/1/card/wrong_id/actions?limit=100
#> invalid id (HTTP 400)
#> 
#> Fetched 1 results
#> 
#> Request complete: 1 results.
error
#> # A tibble: 1 × 4
#>   failed.url                         failed.status failed.message failed.headers
#>   <chr>                                      <int> <chr>          <list>        
#> 1 https://api.trello.com/1/card/wro…           400 invalid id     <named list>

Built with

sessionInfo()
#> R version 4.3.1 (2023-06-16)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: elementary OS 6.1 Jólnir
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=C              
#>  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Europe/London
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] trelloR_0.8.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] vctrs_0.6.3       httr_1.4.7        cli_3.6.1         knitr_1.43       
#>  [5] rlang_1.1.1       xfun_0.40         jsonlite_1.8.7    glue_1.6.2       
#>  [9] htmltools_0.5.6   sass_0.4.7        fansi_1.0.4       rmarkdown_2.24   
#> [13] evaluate_0.21     jquerylib_0.1.4   tibble_3.2.1      fastmap_1.1.1    
#> [17] yaml_2.3.7        lifecycle_1.0.3   compiler_4.3.1    pkgconfig_2.0.3  
#> [21] rstudioapi_0.15.0 digest_0.6.33     R6_2.5.1          utf8_1.2.3       
#> [25] pillar_1.9.0      curl_5.0.2        magrittr_2.0.3    bslib_0.5.1      
#> [29] tools_4.3.1       cachem_1.0.8

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.