Read Trello Cards

Updated: Nov 10, 2023

This example shows you how to read the cards on a Trello board using DataPipeline.

For this example you will need TRELLO_API_KEY, TRELLO_API_TOKEN and TRELLO_BOARD_ID. For information on how to obtain this credentials visit Trello.

Java Code Listing

package com.northconcepts.datapipeline.examples.trello;

import com.northconcepts.datapipeline.core.DataReader;
import com.northconcepts.datapipeline.core.DataWriter;
import com.northconcepts.datapipeline.core.StreamWriter;
import com.northconcepts.datapipeline.job.Job;
import com.northconcepts.datapipeline.trello.CardFilter;
import com.northconcepts.datapipeline.trello.TrelloBoardCardsReader;

public class ReadTrelloCards {

    private static final String TRELLO_API_KEY = "API_KEY";
    private static final String TRELLO_API_TOKEN = "API_TOKEN";
    private static final String TRELLO_BOARD_ID= "BOARD_ID";

    public static void main(String[] args) {
        DataReader reader = new TrelloBoardCardsReader(TRELLO_API_KEY, TRELLO_API_TOKEN, TRELLO_BOARD_ID)
                .setCardFilter(CardFilter.CLOSED)
                ;
        DataWriter writer = StreamWriter.newSystemOutWriter();

        Job.run(reader, writer);
    }
    
}

Code Walkthrough

  1. An instance of TrelloBoardCardsReader which takes TRELLO_API_KEY, TRELLO_API_TOKEN and TRELLO_BOARD_ID as arguments is created. This will be used to read a list of Trello cards belonging to the specified board.
  2. .setCardFilter(CardFilter.CLOSED) is used to filter the type of card that you need. The options are ALL, CLOSED, NONE, OPEN and VISIBLE.
  3. StreamWriter.newSystemOutWriter() is used to write the output record to the console.
  4. Job.run() is then used to transfer data from the reader to StreamWriter.
Mobile Analytics