A Ruby API gem for Inbound.org platform

You're here : Homepage > Blog > This Blog Post

  Read this post   Share   Tweet   4-minutes read

A Ruby API gem for Inbound.org platform

Posted on 26/01/2017 at 8:00 PM by The Vibe.

Software Development Documentation Ruby

Ever heard of this term - Growth hacking? Probably not. Growth hacking refers to a procedure by which you artificially increase your circle on any social-media platform in general. This is a really important factor that start-ups have to consider, while they're still in their initial phase. And the need to automate growth hacking is really immense. Keep reading, to understand the logic of growth-hacking and functionality of this API.


Logic of Growth Hacking

Growth hacking has a very interesting logic behind its working. This is what a step-by-step analysis of growth hacking would roughly resemble -

  1. Repeat steps 2 to 5 for each social-media platform.
  2. Get the list of users who're following your competitor in that social-media platform. Most of them are your target audience too, as they were interested in your competitor. Repeat steps 3 to 5 for each such follower.
  3. Select a user from the above list.
  4. Follow that user. They receive a notification that you've followed them.
  5. If they follow you back within n days, great - mission accomplished. Else,
    1. If you've already followed them for a critical cut-off of m times, don't follow them anymore. That user is probably not interested in this sector - let's not spam them with any more notifications.
    2. Else, unfollow them & repeat from step 3.

Pretty smooth, huh? Most social-media platforms such as Facebook, Linkedin, Twitter, Google offer APIs for programmatic implementation of growth-hacking. This Inbound API Ruby gem is a similar API for ruby language.


Working with the API

  • Setting up dependencies :

    This API depends on 2 ruby gems - Mechanize & JSON. They should be installed by default, while installing this gem. In any case, considering that you already have ruby & rubygems setup, type the below commands in your terminal to install the dependencies -

    gem install mechanize to install Mechanize gem.

    gem install json to install the native JSON gem.

    Great! You're now ready to install the Inbound API Ruby gem.

  • Installation :

    Type gem install inbound_api on your terminal.

    => Successfully installed inbound_api-1.0.3

    => 1 gem installed

    After the gem is installed, try out the below commands in your ruby console (irb ) or in a ruby file.

  • Initializing :

    require 'inbound_api'

    => true

    instance = InboundAPI.new()

    => #< InboundAPI: ... >

  • Logging in :

    instance.login('inbound_email_id','inbound_password')

    => {'response'=>'Success'}

    Note that this and also the below statements return a hash, whose response field contains value of Success or Failure - making it easier to debug.

  • Fetch a user's data :

    instance.fetch_user_data('dany_jon_tyrion')

    => {'response'=>'Success', 'userid'=>'1277018', 'name'=>'Athitya Kumar', 'imageurl'=>'https://www.filepicker.io/api/file/d1e3Zr61Q8ef8dRFMeUr', 'location'=>'Chennai', 'karma'=>4, 'numberfollowers'=>541, 'numberfollowing'=>11341, 'work'=>'Student at IIT Kharagpur', 'companylink'=>'https://athityakumar.github.io/', 'twitterlink'=>'https://twitter.com/danyjontyrion', 'facebooklink'=>'https://www.facebook.com/athitya.kumar', 'linkedinlink'=>nil, 'googlepluslink'=>nil, 'mylink'=>'https://athityakumar.github.io/blog/page1/', 'numberbadges'=>nil, 'badges'=>nil, 'recent_activity'=>nil}

    Note that all information of a user that isn't available at inbound.org portal is initialised as nil.

  • Fetch a user's followers :

    followers = instance.fetch_followers('dany_jon_tyrion')['followers']

    followers.count

    => 535

  • Fetch a list of usernames followed by a user :

    followers = instance.fetch_following('dany_jon_tyrion')

    => {'response'=>'Failure'}

    Note that the server 500 error encountered on Inbound.org portal translates into a hash output with 'response' field as 'Failure'.

  • Fetch a list of usernames as search results with / without pagination :

    instance.search_users(name,location,badges,skills,number_of_pages)

    where,

    name and location are strings initialised as ""

    badges and skills are lists initialised as []

    pages is an integer number of pages initialised as 1.

    For example,

    instance.search_users('Dany','Chennai',['Inbound','HubSpot'],['Web','Graphics'],100)

    => {'response'=>'Success', 'usernames'=>['valiantsystems', 'webdesigningco1', '11Ganapathy', 'DENTISTINDIA', 'RenegadeCricket']}

    Note that the actual list of Badges & Skills can be found by functions instance.get_all_badges() & instance.get_all_skills() .

  • Follow a user :

    instance.follow_user('dany_jon_tyrion')

    => {'response'=>'Success'}

    Note that you'd have to login first to follow / unfollow.

  • Unfollow a user :

    instance.unfollow_user('dany_jon_tyrion')

    => {'response'=>'Success'}

    Don't try to unfollow yourself - you would get 'Failure' as the response.


Any suggestions?

You can find this gem on RubyGems website. If there are any suggestions / enhancements you'd like to see in this Ruby API gem, do comment below, or open a new issue here. Also, if you liked this project, do star the repository. And fellow developers, you're welcome to contribute - for, this is an open-source project.