Skip to content

Instantly share code, notes, and snippets.

@tgoldenberg
Created July 10, 2017 03:35
Show Gist options
  • Select an option

  • Save tgoldenberg/cbe528ad4f764c87b3b1e10f0b4d4f0f to your computer and use it in GitHub Desktop.

Select an option

Save tgoldenberg/cbe528ad4f764c87b3b1e10f0b4d4f0f to your computer and use it in GitHub Desktop.
Get a list of investors, given a list of companies
require('dotenv').config(); /* store your Angel List API token */
const rp = require('request-promise');
const ACCESS_TOKEN = process.env.ACCESS_TOKEN; /* access token to access Angel List API */
const ANGEL_LIST = 'https://api.angel.co/1'; /* version of Angel List API */
const ACCELERATOR_ID = 'YOUR_ACCELERATOR_ID_HERE';
/* utility function to create query string */
function encodeQueryData(data) {
let result = [];
for (let d in data)
result.push(encodeURIComponent(d) + '=' + encodeURIComponent(data[d]));
return result.join('&');
}
async function getInvestors(companies) {
try {
let result = [ ];
for (let i = 0; i < companies.length; i++) {
let company = companies[i];
/* build query string for each company */
let params = {
access_token : ACCESS_TOKEN,
startup_id : company.id,
role : 'past_investor',
};
/* fetch investors for specific company */
let url = `${ANGEL_LIST}/startup_roles?${encodeQueryData(params)}`;
let response = await rp(url);
let data = JSON.parse(investors);
let investors = data.startup_roles.map(r => r.user);
investors.forEach(u => {
result.push({
name : u.name,
id : u.id,
url : u.angellist_url,
companyName : company.name,
bio : u.bio,
});
});
}
return result;
} catch (e) {
console.log(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment