# Crunchbase Crunchbase is a ruby wrapper base on Crunchbase V4 API. It provides easy to get the API data by each endpoint. [CB-v4 doc](https://app.swaggerhub.com/apis/Crunchbase/crunchbase-enterprise_api/1.0.1) [![Gem Version](https://badge.fury.io/rb/crunchbase4.svg)](https://badge.fury.io/rb/crunchbase4) [![Build Status](https://travis-ci.org/encoreshao/crunchbase4.svg?branch=master)](https://travis-ci.org/encoreshao/crunchbase4) ## Installation Add this line to your application's Gemfile: ```ruby gem 'crunchbase4', github: 'ekohe/crunchbase4' ``` And then execute: $ bundle install Or install it yourself as: $ gem install crunchbase4 ## Getting Started ### Configure your API certificate ``` require 'crunchbase4' CB_CONFIG = YAML.load(File.read('crunchbase.yml')) Crunchbase.config do |c| c.user_key = CB_CONFIG['user_key'] end OR Crunchbase.config.user_key = CB_CONFIG['user_key'] ``` ## Usage ### The first step is to build an API client ``` pry(main)> client = Crunchbase::Client.new ``` ### Entity #### Get the organization data ``` pry(main)> response = client.organization('ekohe') => # pry(main)> response.name => "Ekohe" pry(main)> response.permalink => "ekohe" ``` Or, if you want to use json data, please call `response.as_json` in your project. #### Get the person data ``` pry(main)> response = client.person('mark-zuckerberg') => # pry(main)> response.name => "Mark Zuckerberg" pry(main)> response.permalink => "mark-zuckerberg" ``` #### Get the funding round data ``` => # pry(main)> response = client.funding_round('371c20af-8aa9-4bcb-a8da-0694d138f247') => # pry(main)> response.name => "Secondary Market - Facebook" pry(main)> response.uuid => "371c20af-8aa9-4bcb-a8da-0694d138f247" ``` #### Get the acquisition data ``` pry(main)> response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928') => # pry(main)> response.uuid => "7638eae9-07b7-4fc6-ad20-5d99de3ff928" pry(main)> response.acquiree_funding_total => 150949998 ``` #### Get the press reference data ``` pry(main)> response = client.press_reference('0171b30e-9cf8-4ad5-8288-2993e4308e0f') => # ``` #### Get the investment data ``` pry(main)> response = client.investment('1368da0c-07b0-46ef-9a86-b518367e60d6') => # ``` ### Search * Search query parameters for each endpoint ``` { "field_ids": [], "query": [], "order": [], "limit": 0 } ``` #### Search organizations by query conditions and order * Step1: Needs to build the query conditions ``` query_data = { 'field_ids' => %w[ name website uuid short_description company_type ], 'order' => [ { 'field_id' => 'company_type', 'sort' => 'asc' } ], 'query' => [ { 'type' => 'predicate', 'field_id' => 'funding_total', 'operator_id' => 'between', 'values' => [ { 'value' => 1_000_000, 'currency' => 'usd' }, { 'value' => 10_000_000, 'currency' => 'usd' } ] }, { 'type' => 'predicate', 'field_id' => 'facet_ids', 'operator_id' => 'includes', 'values' => %w[company investor] } ], 'limit' => 4 } ``` * Use `client` to send a request and parse response ``` pry(main)> response = client.search_organizations(query_data) => #["name", "website", "uuid", "short_description", "company_type"], "order"=>[{"field_id"=>"company_type", "sort"=>"asc"}], "query"=> [{"type"=>"predicate", "field_id"=>"funding_total", "operator_id"=>"between", "values"=>[{"value"=>1000000, "currency"=>"usd"}, {"value"=>10000000, "currency"=>"usd"}]}, {"type"=>"predicate", "field_id"=>"facet_ids", "operator_id"=>"includes", "values"=>["company", "investor"]}], "limit"=>4}, @count=4, @entities= [#, #, #, #], @entity_type="organization", @kclass_name=Crunchbase::Models::Organization, @total_count=44871> ``` - Get all entities: `response.entities` - Get total count: `response.total_count` - Get entities count: `response.count` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. ### Examples of API requests ``` Crunchbase.config.user_key = 'user_key' client = Crunchbase::Client.new response = client.organization('ekohe') response = client.person('mark-zuckerberg') response = client.funding_round('371c20af8aa94bcba8da0694d138f247') response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928') ``` ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/ekohe/crunchbase4. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ekohe/crunchbase4/blob/master/CODE_OF_CONDUCT.md). ## License Crunchbase is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). ## Code of Conduct Everyone interacting in the Crunchbase project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ekohe/crunchbase4/blob/master/CODE_OF_CONDUCT.md).