Created
July 21, 2017 16:01
-
-
Save sshadmand/3382212cca8e65a0a96c4bdb2eb450f7 to your computer and use it in GitHub Desktop.
Pitchbook API with JS and JQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BASE_URL = "https://api.pitchbook.com" | |
const TOKEN = "TOKEN HERE" | |
$.ajaxSetup({ | |
headers: { 'authorization': TOKEN } | |
}); | |
const generalSearch = function(name) { | |
var def = jQuery.Deferred(); | |
$.getJSON( BASE_URL + '/search?name=' + name, function( response ) { | |
def.resolve(response.results.results); | |
}); | |
return def.promise(); | |
} | |
const getCompanyProfile = function(companyID) { | |
var def = jQuery.Deferred(); | |
$.getJSON( BASE_URL + '/companies/' + companyID['companyId'] + '/details', function( response ) { | |
// def.resolve(response); | |
console.log(response) | |
}); | |
return def.promise(); | |
} | |
const companySearch = function(keywords) { | |
var def = jQuery.Deferred(); | |
$.getJSON( BASE_URL + '/companies/search?keywords=' + keywords, function( response ) { | |
const companyIDs = response.results.items; | |
companyIDs.forEach(function(companyObj, index){ | |
getCompanyProfile(companyObj).then(function(companyProfile){ | |
// console.log(companyProfile) | |
}); | |
}); | |
}); | |
return def.promise(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment