First draft - JavaScript Library for Behance Integration

Back in April of this year I blogged about how you could create a "widget" version of your Behance portfolio on your web site. This was done using a little library I built and a user's RSS feed. By using the RSS feed we could bypass the somewhat strict limits on the Behance API (150 hits per hour). I had a few people ask about using the real API so I decided to take a stab at it today.

I've begun with the simplest use case imaginable, getting the projects for a single user. First, you begin with your HTML template.

<!doctype html>
<html lang="en">
        <h1>Regular Site</h1>
        Some vanilla content.

        <h1>My Projects</h1>
        <div id="projects">
        <script src="jquery-2.0.0.min.js"></script>
        <script src="behance_api.js"></script>
        <script src="demo1.js"></script>

Nothing special here. I've got a basic template with an empty div block I'll be using to display my templates. I'm loading jQuery as a dependency, my new library, and demo1.js, which is just the JavaScript file for this page. Let's look at that next.

/* global $,console,document,behanceAPI */
var behancekey = "vNvOiZI0cD9yfx0z4es9Ix6r4L2J7KdI";

$(document).ready(function() {
    //Set my key
    //Now get my projects
    behanceAPI.getProjects("gwilson", function(p) {

        //Manually draw them out  
        var s = "";
        for(var i=0; i<p.length; i++) {
            var proj = p[i];
            s += "<h2>" + + "</h2>";
            s += "<p>";
            s += "<a href='" + proj.url + "'><img src='" + proj.covers[404] + "'></a>";
            s += "</p>";


In this demo, all I'm doing is setting the API key (see note below) and then running the getProjects call. The method takes two arguments - the user and the function to run after the data has been fetched. I do not have any error handling yet, that will come later. The result is simply an array of projects that you can display however you want. In this case I just create a big ugly string. Typically you would want to use something like Handlebars instead.

The actual library itself is pretty simple:

/* global console,$ */
var behanceAPI = function() {
    var key;
    var baseURL = "";
    function setKey(k) {
        key = k;    
    function getProjects(user, cb) {
        var url = baseURL + "users/" + user + "/projects?api_key=" + key + "&callback=";
        $.get(url, {}, function(res, code) {
        }, "JSONP");
    return {
        setKey: setKey,
        getProjects: getProjects    

So, because of the limits Behance puts on API calls, I decided not to put this demo online. (And yes, I realize my own key is up there!) Instead, I've attached a zip of the project to this blog entry. Here is a screenshot of the result:

Not terribly exciting yet, I know. But - I'm thinking that in my next revision, I'm going to allow you to create a simple template, pass it to the library, and have the output handled for your automatically. My thinking is that many of the people who may use this API are creatives who may not have much JavaScript experience.

Download attached file.

Like This?

If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can also subscribe to the email feed to get notified of new posts.