How Trello does SDKs

So, Trello doesn't have an official SDK, which makes it a bit of an odd choice to write about here. However, someone built an unofficial Node one, and it's one of my favorite API SDKs to interact with. The lack of an official SDK is one of the reasons it's actually my favorite!

var Trello = require("node-trello");
var t = new Trello("<your key>", "<token>");

t.get("/1/members/me", { cards: "open" }, function(err, data) {
  if (err) throw err;
  console.log(data);
});

One thing you'll notice with this SDK is that it's a very light wrapper. Rather than making up method names for each endpoint (such as t.getMember), it literally just accepts an actual Trello URL path. This means you don't need to check out separate documentation to see how endpoints map to methods. So, why have an SDK at all? It is really nice to not have to worry about figuring out how to pass in API keys, deal with scopes, or mess with token expirations. You don't need to know if the "data" being passed in a query string or form data or body params. It's just JSON. File uploads? Not a problem! It normalizes them so you don't have to think about how to get a file to your API.

var fs = require("fs");
var path = require("path");
var Trello = require("node-trello");
var t = new Trello("<your key>", "<token>");

var cardId = "<the card id>";
var a = fs.createReadStream(path.resolve(__dirname, "/path/to/file.doc"));

t.post(`/1/cards/${cardId}/attachments`, { attachment: a }, (err, attachments) => {
    if (err) throw err;
    console.log(attachments);
});

This SDK takes care of sending all the data properly. It abstracts away the crappy part of APIs while keeping their charm. In my mind, it's the perfect balance between no SDK and one of those heavy language-specific SDKs. I wish more people built API SDKs like this.