cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <h1 class="roster_title">Etsy.com Team Roster from API</h1>
<ul id="roster"></ul>  
            
          
!
            
              body {
  font-family: "Arial", "Helvetica", sans-serif;
  color: #666;
}
#roster {
  list-style-type: none;
}

a {
  color: teal;
  text-decoration: none;
}

.roster_title {
  color: teal;
  text-align: center;
}
.member {
  float: left;
  position: relative;
  width: 230px;
  height: 78px;
  margin: 0 15px 15px 0;
  padding: 8px 15px 8px 8px;
  border: 1px solid #EAEAEA;
  border-radius: 4px;
  overflow: hidden;
}

.member_img {
  float: left;
  position: relative;
}

.member_info {
  display: inline-block;
  margin-left: 8px;
  overflow: auto;
  max-width: 145px;
}

.member_name,
.member_shop,
.member_desc {
  font-size: 12px;
  margin: 0;
}
            
          
!
            
              //Make the API call
$(document).ready(function() {
  // Var 1 returns results 0-100, Var 2 returns results 100-200
  var teamURL1 = "https://openapi.etsy.com/v2/teams/5436/users.js?status=active&fields=login_name&includes=Shops(shop_name,title),Profile(image_url_75x75)&callback=getProfile&limit=100&offset=0&api_key=tm0azjut17hrivf2leczqkpf";
  var teamURL2 = "https://openapi.etsy.com/v2/teams/5436/users.js?status=active&fields=login_name&includes=Shops(shop_name,title),Profile(image_url_75x75)&callback=getProfile&limit=100&offset=100&api_key=tm0azjut17hrivf2leczqkpf";

  // Add in userID of members not captured in team roster
  var usersURL = "https://openapi.etsy.com/v2/users/willowtextiles,TreasuresbyCamille,splrsplne,HoppysFavorite,mj44223,eclaughman,ThreeFriendsOneBrain,LiberalSmarts.js?fields=login_name&includes=Shops(shop_name,title),Profile(image_url_75x75)&callback=getProfile&api_key=tm0azjut17hrivf2leczqkpf";

  // Call Var 1
  $.ajax({
    url: teamURL1,
    dataType: "jsonp"
  }).done(function(teamURL1Data) {
    if (teamURL1Data.ok) {
      // Call Var 2
      $.ajax({
        url: teamURL2,
        dataType: "jsonp"
      }).done(function(teamURL2Data) {
        if (teamURL2Data.ok) {
          // Call Var 3
          $.ajax({
            url: usersURL,
            dataType: "jsonp"
          }).done(function(usersData) {
            // Concatenate results 
            extract_results(teamURL1Data.results.concat(teamURL2Data.results, usersData.results));
          });

        };

      });
    };

  });
});

// Extract the desired information and send it to the page
function extract_results(results) {
  // Sort results alphabetically
  results.sort(function(a, b) {
      if (a.login_name.toLowerCase() < b.login_name.toLowerCase()) return -1;
      if (a.login_name.toLowerCase() > b.login_name.toLowerCase()) return 1;
      return 0;
    })
    //Loop through each result
  for (i = 0; i < results.length; i++) {
    // Pull out information
    var user = results[i];
    var name = user.login_name;
    var shopTitle = '';
    var shopName = '';
    if (user.Shops.length > 0) {
      shop = user.Shops[0];
      shopTitle = shop.title;
      shopName = shop.shop_name;
    };
    var pic = user.Profile.image_url_75x75;
    //Append information to page in a list
    $("#roster").append("<li class='member'><a href='https://www.etsy.com/people/" + name + "'><img class='member_image' src='" + pic + "'/></a><div class='member_info'><a href='https://www.etsy.com/people/" + name + "'><h2 class='member_name'>" + name + "</h2></a><h3 class='member_shop'><a href='https://www.etsy.com/shop/" + shopName + "'>" + shopName + "</a></h3><p class='member_desc'>" + shopTitle + "</p></div></li>");
  }
  // Hide Ajax loading image
  $("#loading").hide();
};
            
          
!
999px
Loading ..................

Console