Avvo API Client

This gem provides an ActiveResource[http://api.rubyonrails.org/classes/ActiveResource/Base.html]-based client to information on Avvo, a directory of lawyers.

Requirements

Apart from the gems installed as dependencies, this gem requires an account on Avvo associated with an API key. Visit the API Documentation for details.

Usage

Somewhere during your app’s initialization, you should include the gem and set it up with your Avvo credentials:

require 'avvo_api'
AvvoApi.setup('[email protected]', 'password')

For the most part, the models supplied by this gem should act like ActiveRecord models. These models parallel the resources listed on api.avvo.com, and everything accessible from the Avvo API is accessible using this gem.

Examples

Details about the specific information returned by these calls can be found in the documentation at api.avvo.com. An example of using the API in a command-line program can be found in the examples subdirectory.

Find a lawyer with a known ID

l = AvvoApi::Lawyer.find(28995)

Find a lawyer based on known attributes, like email, zip code, etc.

l = AvvoApi::Lawyer.resolve(:name => 'Mark Britton', :zip_code => '98101')

Search for lawyers matching a keyword in a specific location

AvvoApi::Lawyer.search(:q => 'criminal defense', :loc => 'seattle')

Retrieve the headshot URL for a lawyer

AvvoApi::Lawyer.find(28995).headshot.headshot_url

or

AvvoApi::Headshot.find(:one, :params => {:lawyer_id => 28995}).headshot_url

Getting a list of addresses for a lawyer

addresses = AvvoApi::Lawyer.find(28995).addresses

or

addresses = AvvoApi::Address.find(:all, :params => {:lawyer_id => lawyer.id})

Getting the main address for a lawyer

main_address = AvvoApi::Address.main(:lawyer_id => lawyer.id)