Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

jeremyw/swish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swish! A Ruby wrapper for the Dribbble API

Learn about the Dribbble API at dribbble.com/api.

Installation

Swish is just a Ruby gem:

gem install swish

Not playing in the Ruby league? Here are the others we know of so far:

Examples

require 'swish'

# Find a shot
shot = Dribbble::Shot.find(21603)

# See some data about the shot
shot.title
shot.image_url
shot.url
shot.player.name
shot.views_count
shot.likes_count
shot.comments_count
shot.rebounds_count

# Or get a shot's rebounds
shot.rebounds

# Find more shots
inspiring       = Dribbble::Shot.popular
call_the_police = Dribbble::Shot.everyone
yay_noobs       = Dribbble::Shot.debuts

# Find a player
player = Dribbble::Player.find('jeremy')

# See some data about the player
player.name
player.avatar_url
player.url
player.location
player.twitter_screen_name
player.drafted_by_player_id

# Player stats
player.shots_count
player.draftees_count
player.followers_count
player.following_count

# List a player's shots
player.shots

# List shots by players that this player follows
player.shots_following

# List a player's draftees
player.draftees

# List a player's followers
player.followers

# List the players who a player is following
player.following

Pagination

The Dribbble API returns paginated lists, with a default page size of 15 items. Swish makes it easy to traverse the pages of any list.

# Get the second page of popular shots, with 30 shots per page
shots = Dribbble::Shot.popular(:page => 2, :per_page => 30)

# Some useful stats for rendering pagination links
shots.page     # => current page number
shots.per_page # => number of items per page
shots.total    # => total number of items on all pages
shots.pages    # => total number of pages

# Try it with other lists
Dribbble::Player.find('jeremy').shots(:per_page => 5)
Dribbble::Player.find('jeremy').shots_following(:page => 10)
Dribbble::Shot.find(21603).rebounds(:page => 2, :per_page => 10)

See dribbble.com/api#pagination for more information.

Who’s using Swish?

  • liiikes.com, “Using statistics to find the best content on Dribbble.”

  • hooppps.com, “A free open-source mobile dribbble browser”

Email [email protected] to have your project added to this list.

Thanks

Thanks to Dan and Rich for creating Dribbble (and its API!), and to everyone that has contributed to Swish, including:

  • Jeffrey Chupp

  • Jon Distad

  • Michael Parenteau

  • Adam Perfect

Email [email protected] if you should be on this list. Apologies and thanks in advance.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Jeremy Weiskotten. See LICENSE for details.