Using buckets to improve performance

This tutorial describes how you can improve performance of calls by using 'buckets' to control exactly which data is returned by various API methods.

Getting multiple data elements at once

You may want to retrieve multiple data items about an artist. Naturally, this is possible by making multiple separate calls to retrieve each data element. However, since each API call has a certain amount of overhead, making multiple calls can slow down your application. To reduce the overhead, you can retrieve multiple data elements with a single call by using the bucket parameter. The bucket parameter allows you to specify which data should be returned in the call.

Example

For example, we can retrieve the hotttnesss, familiarity and top term data for Weezer with the single call:

Response

{
    "response": {
        "artist": {
            "familiarity": 0.85401289656620716, 
            "hotttnesss": 0.56302316258640883, 
            "id": "AR633SY1187B9AC3B9", 
            "name": "Weezer", 
            "terms": [
                {
                    "frequency": 0.99998861927793226, 
                    "name": "pop rock", 
                    "weight": 1.0
                }, 
                {
                    "frequency": 1.0, 
                    "name": "rock", 
                    "weight": 0.8579258451572197
                },  
                # (terms omitted) 
            ]
        }, 
        "status": {
            "code": 0, 
            "message": "Success", 
            "version": "4.2"
        }
    }
}
For data items with multiple values (e.g. news, reviews, blogs ...), the most recent 15 or so items are returned. For example, the following call will return the 15 most recent blog posts and news items for Weezer.

Example

Response

{
    "response": {
        "artist": {
            "blogs": [
                {
                    "date_found": "2011-06-07T05:42:42", 
                    "date_posted": "2011-06-07T05:42:36", 
                    "id": "07afea2463e7e6b7743011bbe665429f", 
                    "name": "Required Summer Listening II", 
                    "summary": "(text omitted)",
                    "url": "http://www.awkwardsound.com/2011/06/required-summer-listening-ii.html"
                }, 
                {
                    "date_found": "2011-06-06T23:42:53", 
                    "date_posted": "2011-06-06T23:42:44", 
                    "id": "b86831e59b5d0c94adcdb3719d5adde1", 
                    "name": "Stars line up for \u2018Cars 2\u2032 soundtrack", 
                    "summary": "(text omitted)"
                    "url": "http://frenchmusic.thatilove.net/?p=4246"
                }, 
                {
                    "date_found": "2011-06-07T00:45:48", 
                    "date_posted": "2011-06-06T22:38:44", 
                    "id": "807aaba17bcffb12897c4cf9c57911ff", 
                    "name": "Radiohead vai lan\u00e7ar remixes de \u201cThe King of Limbs\u201d", 
                    "summary": "(text omitted)"
                    "url": "http://www.rocknbeats.com.br/2011/06/06/radiohead-vai-lancar-remixes-de-the-kings-of-limbs/"
                }, 
                {
                    "date_found": "2011-06-06T18:44:15", 
                    "date_posted": "2011-06-06T18:44:03", 
                    "id": "a587df9bfcb06c21cd34ada0fadeeda7", 
                    "name": "Monday EP (Mister Heavenly, Kids On A Crime Spree, Correatown, Gold Leaves, The National)", 
                    "summary": "(text omitted)"
                    "url": "http://sideonetrackone.com/archive/2011/june/060611.htm"
                }, 
                {
                    "date_found": "2011-06-06T19:44:09", 
                    "date_posted": "2011-06-06T17:43:45", 
                    "id": "c9c96bbaa9d70a538d6286cb5efe880b", 
                    "name": "Tonight's picks: Weezer, Bob Schneider, Harry and the Potters", 
                    "summary": "(text omitted)"
                    "url": "http://www.austin360.com/blogs/content/shared-gen/blogs/austin/music/entries/2011/06/06/tonights_picks_weezer_bob_schn.html?cxntfid=blogs_austin_music_source"
                }, 
                {
                    "date_found": "2011-06-06T15:42:29", 
                    "date_posted": "2011-06-06T15:42:21", 
                    "id": "ca9ddc1f392c40e1b04c8efd84037696", 
                    "name": "Last Night: Weezer At Free Press Summer Fest", 
                    "summary": "(text omitted)"
                    "url": "http://blogs.houstonpress.com/rocks/2011/06/weezer_free_press_summer_fest.php"
                }, 
                {
                    "date_found": "2011-06-06T17:43:19", 
                    "date_posted": "2011-06-06T15:00:02", 
                    "id": "288690c872394f408c8627fb440619db", 
                    "name": "Green Like July \u201cNo Light Will Shine on Me\u201d", 
                    "summary": "(text omitted)"
                    "url": "http://one-track-mind.com/green-like-july-no-light-will-shine-on-me-free-mp3/"
                }, 
                {
                    "date_found": "2011-06-06T15:42:28", 
                    "date_posted": "2011-06-06T14:00:00", 
                    "id": "0799642272fd6e87514ac2a962c24746", 
                    "name": "Free Music Monday is back!", 
                    "summary": "(text omitted)"
                    "url": "http://www.athousandguitars.com/2011/06/free-music-monday-is-back.html"
                }, 
                {
                    "date_found": "2011-06-06T22:42:59", 
                    "date_posted": "2011-06-06T00:27:42", 
                    "id": "16abe2961b285c1d3d495ad3e6b98f77", 
                    "name": "The End Unplugged 6.05.11", 
                    "summary": "(text omitted)"
                    "url": "http://blogs.1077theend.com/endunplugged/2011/06/05/the-end-unplugged-6-05-11/"
                }, 
                {
                    "date_found": "2011-06-04T10:43:36", 
                    "date_posted": "2011-06-04T10:43:29", 
                    "id": "9e21237f617e15e3a0a0589e7c3b4431", 
                    "name": "Clinton Sparks - My Awesome Mixtape (2011)", 
                    "summary": "(text omitted)"
                    "url": "http://www.greenhitz.com/forums/showthread.php?76063-Clinton-Sparks-My-Awesome-Mixtape-(2011)&goto=newpost"
                }, 
                {
                    "date_found": "2011-06-06T13:41:45", 
                    "date_posted": "2011-06-04T01:22:35", 
                    "id": "757228e0a7dd0238999f95c8b3a50a7c", 
                    "name": "ALBUM REVIEW: The Swellers - Good For Me", 
                    "summary": "(text omitted)"
                    "url": "http://www.altpress.com/reviews/entry/the_swellers_-_good_for_me/"
                }, 
                {
                    "date_found": "2011-06-04T03:42:34", 
                    "date_posted": "2011-06-04T00:00:38", 
                    "id": "7ff473671a3512ba0579ad3b028fc593", 
                    "name": "Bloggy Goodness: Team Jenny", 
                    "summary": "(text omitted)"
                    "url": "http://www.glidemagazine.com/hiddentrack/bloggy-goodness-team-jenny/"
                }, 
                {
                    "date_found": "2011-06-03T21:42:49", 
                    "date_posted": "2011-06-03T21:42:28", 
                    "id": "e1e366a7de1da3516222110cb2e03f43", 
                    "name": "BALKANS - \"FLOWERS EVERYWHERE\" (DIVERSOS V\u00cdDEOS)", 
                    "summary": "(text omitted)"
                    "url": "http://possoouvirumdisco.blogspot.com/2011/06/balkans-flowers-everywhere-diversos.html"
                }, 
                {
                    "date_found": "2011-06-03T20:42:39", 
                    "date_posted": "2011-06-03T20:42:24", 
                    "id": "ea3d1088c2f10cc8f2a3391c9c0dd63c", 
                    "name": "The MTV Movie Awards' Best Musical Moments", 
                    "summary": "(text omitted)"
                    "url": "http://newsroom.mtv.com/2011/06/03/mtv-movie-awards-musical-moments/"
                }, 
                {
                    "date_found": "2011-06-03T12:44:39", 
                    "date_posted": "2011-06-03T12:44:34", 
                    "id": "36b2a4d98110f2bd15a7971c2e6e7079", 
                    "name": "State\u2019s Office Stereo \u2013 tUnE-yArDs, Underworld, Civil Civic, David Thomas Broughton and em, S Club 7", 
                    "summary": "(text omitted)"
                    "url": "http://www.state.ie/28207-features/states-office-stereo-tune-yards-underworld-civil-civic-david-thomas-broughton-and-em-s-club-7"
                }
            ], 
            "id": "AR633SY1187B9AC3B9", 
            "name": "Weezer", 
            "news": [
                {
                    "date_found": "2011-06-03T10:42:37", 
                    "date_posted": "2011-06-03T00:00:00", 
                    "id": "f1f2c7642c668bbc834a78e9d394f319", 
                    "name": "Weezer, Jane's Addication and Big Boi Headline DeLuna Festival", 
                    "summary": "(text omitted)"
                    "url": "http://www.mxdwn.com/2011/06/03/news/weezer-janes-addication-and-big-boi-headline-deluna-festival/"
                }, 
                {
                    "date_found": "2011-06-01T11:43:53", 
                    "date_posted": "2011-06-01T00:00:00", 
                    "id": "7ac668e1a74957e957736cc4fc99ddd8", 
                    "name": "Charity Picks From Paul Weller, Ronnie Wood, Coldplay, Depeche Mode, Weezer and more", 
                    "summary": "(text omitted)"
                    "url": "http://www.antimusic.com/news/11/june/01Charity_Picks_From_Paul_Weller,_Ronnie_Wood,_Coldplay,_Depeche_Mode,_Weezer_and_more.shtml"
                }, 
                {
                    "date_found": "2011-06-01T20:43:27", 
                    "date_posted": "2011-06-01T00:00:00", 
                    "id": "8cf7c1fa5c09909d95eede9863772060", 
                    "name": "Chairman of Disney Music Group Announces Retirement", 
                    "summary": "(text omitted)"
                    "url": "http://www.hollywoodreporter.com/news/chairman-disney-music-group-announces-193904"
                }, 
                {
                    "date_found": "2011-06-01T04:43:17", 
                    "date_posted": "2011-05-31T23:43:00", 
                    "id": "b645ae7d333f54f4653b0099df81dbcb", 
                    "name": "DeLuna Fest Announces 2011 Lineup", 
                    "summary": "(text omitted)"
                    "url": "http://www.pastemagazine.com/articles/2011/05/deluna-fest-announces-2011-lineup.html"
                }, 
                {
                    "date_found": "2011-05-31T16:44:08", 
                    "date_posted": "2011-05-31T12:00:00", 
                    "id": "15e369fc7b29d97edfd1b02301d60c93", 
                    "name": "Videos: Weezer: \"Paranoid Android\" (Radiohead cover)", 
                    "summary": "(text omitted)"
                    "url": "http://www.punknews.org/article/42832"
                }, 
                {
                    "date_found": "2011-05-31T16:43:34", 
                    "date_posted": "2011-05-31T09:50:00", 
                    "id": "d8abb3c23422fbcef59f922bf9888d48", 
                    "name": "New Green Day Music, Weezer Does Radiohead", 
                    "summary": "(text omitted)"
                    "url": "http://www.spin.com/articles/new-green-day-music-weezer-does-radiohead"
                }, 
                {
                    "date_found": "2011-05-31T20:42:09", 
                    "date_posted": "2011-05-31T00:00:00", 
                    "id": "f4350ca92442b5e3c1fde28d7bc744ee", 
                    "name": "Trent Reznor and Karen O Cover Led Zeppelin, Weezer Cover Radiohead and More", 
                    "summary": "(text omitted)"
                    "url": "http://www.americansongwriter.com/2011/05/trent-reznor-and-karen-o-cover-led-zeppelin-weezer-cover-radiohead-and-more/"
                }, 
                {
                    "date_found": "2011-05-31T22:44:08", 
                    "date_posted": "2011-05-31T00:00:00", 
                    "id": "38f48dfed9be269ec6f0f5399004a16d", 
                    "name": "Band to Watch: JEFF the Brotherhood's Pop-wise Scuzz-Rock", 
                    "summary": "(text omitted)"
                    "url": "http://www.rollingstone.com/music/news/band-to-watch-jeff-the-brotherhoods-pop-wise-scuzz-rock-20110531"
                }, 
                {
                    "date_found": "2011-05-29T13:00:54", 
                    "date_posted": "2011-05-29T13:00:09", 
                    "id": "1f0d5aa48b0c67c48ac70dfb1dffefe2", 
                    "name": "Weezer cover Radiohead's 'Paranoid Android' - videoWeezer Tickets", 
                    "summary": "(text omitted)"
                    "url": "http://www.nme.com/news/weezer/56956"
                }, 
                {
                    "date_found": "2011-05-27T20:44:03", 
                    "date_posted": "2011-05-27T20:43:37", 
                    "id": "76ca6b867228549b1c29cf638346eb5d", 
                    "name": "Weezer Cover Radiohead", 
                    "summary": "(text omitted)"
                    "url": "http://www.alterthepress.com/2011/05/weezer-cover-radiohead.html"
                }, 
                {
                    "date_found": "2011-05-27T21:41:52", 
                    "date_posted": "2011-05-27T00:00:00", 
                    "id": "d74fc43d3337361293b5bd32cef1f04c", 
                    "name": "People Have Finally Stopped Listening to The Who", 
                    "summary": "(text omitted)"
                    "url": "http://www.deathandtaxesmag.com/96114/people-have-finally-stopped-listening-to-the-who/"
                }, 
                {
                    "date_found": "2011-05-27T23:41:50", 
                    "date_posted": "2011-05-27T00:00:00", 
                    "id": "7d7a5af3ea94b32c16d40383d01e684c", 
                    "name": "Weezer Covering Radiohead's 'Paranoid Android' (VIDEO)", 
                    "summary": "(text omitted)"
                    "url": "http://www.deathandtaxesmag.com/96242/weezer-covering-radioheads-paranoid-android-video/"
                }, 
                {
                    "date_found": "2011-05-28T00:43:06", 
                    "date_posted": "2011-05-27T00:00:00", 
                    "id": "5efa2edb75132a65cb14c4cdc9adabcc", 
                    "name": "Weezer Cover \"Paranoid Android\"", 
                    "summary": "(text omitted)"
                    "url": "http://stereogum.com/715222/weezer-cover-paranoid-android/mp3s/"
                }, 
                {
                    "date_found": "2011-05-28T01:42:48", 
                    "date_posted": "2011-05-27T00:00:00", 
                    "id": "3ccd38a4f982303ea092570195750b37", 
                    "name": "Weezer Does Radiohead's \"Paranoid Android\"", 
                    "summary": "(text omitted)"
                    "url": "http://www.crawdaddy.com/index.php/2011/05/27/weezer-does-radioheads-paranoid-android/"
                }, 
                {
                    "date_found": "2011-05-25T12:42:25", 
                    "date_posted": "2011-05-25T00:00:00", 
                    "id": "46dc0498252e01a36af68e0732243794", 
                    "name": "Sum 41 Singer Collapses- Freese Pulls Out of A Perfect Circle Tour- Judas Priest Boxset- Scott Weiland Late Night- Cradle Of Anthrax Supergroup- Paul Di'Anno Tour- more", 
                    "summary": "(text omitted)"
                    "url": "http://www.antimusic.com/news/11/may/25Sum_41_Singer_Collapses-_Freese_Pulls_Out_of_A_Perfect_Circle_Tour-_Judas_Priest_Boxset-_Scott_Weiland_Late_Night-_Cradle_Of_Anthrax_Supergroup-_Paul_DiAnno_Tour-_more.shtml"
                }
            ]
        }, 
        "status": {
            "code": 0, 
            "message": "Success", 
            "version": "4.2"
        }
    }
}
The use of buckets is a great way to get a lot of data in a single call. For instance, here's an example of finding all of the similar artists to The Beatles, and retrieving the audio, biographies, blogs, familiarity, hotttnesss, images, news reviews, and songs for each of these artists, all with a single call.

Example

Response

This call eliminates the need to make 165 separate calls (15 artists * 11 pieces of data). The resulting response contains over a megabyte of data and is omitted here for brevity.