LendingClub - Perl extension for interacting with Lending Club
use LendingClub;
my $lc = LendingClub->new( { username => 'email@domain.com', password => 'p4ssw0rd', debug => 1, noproxy => 1 } );
my %stats = $lc->get_account_statistics(); #return information about my account to a hash
my @invested_notes = $lc->get_invested_notes();
my @available_notes = $lc->get_available_notes();
my %note = $lc->get_note_data(12345); #return basic information about this note as a hash
#get some information about the area that this member is from
my $citystate = $note{'member'}->{'location'}->{'value'}; #pull out the "location" (city, state) of the member
my $location_info = $lc->get_location_info($citystate);
my $avg_housing = $location_info->{'housing'}[0]->{'value'}[0]->{'median_dollars'}[0]->{'content'};
my $avg_income = $location_info->{'economy'}[0]->{'income'}[0]->{'median_household_income_dollars'}[0]->{'content'};
This perl module is intended to act as a loose API for interacting with the website lendingclub.com.
Prerequisites:
WWW::Mechanize Text::CSV XML::Simple
The following methods are provided:
(NOTE: In general, if any method/value produces a "null" or invalid value, this module will attempt to normalize that to "N/A")
The constructor takes hash style parameters. The following parameters are recognized:
username: email / username for your Lending Club account password: the password to the username logging in debug: enable debugging withe the module (bool) noproxy: disable the underlying proxy in WWW::Mechanize (bool)
The get_invested_notes() function serves two purposes: 1. Return an array of notes that have been invested in by the logged in user in an array, where each element in the array is a note ID 2. Load up personal investment statistics about the note into memory, which will be available in later calls in get_note_data(...) calls. Without making this call first, some data may be unavailable to get_note_data() execution
Example:
foreach my $noteid ($lc->get_invested_notes())
{
my %note_data = $lc->get_note_data($noteid);
}
The get_avaialable_notes() function serves two purposes: 1. Return an array of notes that have are available for investing by the logged in user in an array, where each element in the array is a note ID 2. Load up additional note data into memory, which will be available in later calls in get_note_data(...) calls. Without making this call first, some data may be unavailable to get_note_data() execution
Example:
foreach my $noteid ($lc->get_avaialable_notes())
{
my %note_data = $lc->get_note_data($noteid);
}
The get_account_statistics() function will bring back statistics of your account back a hash. The following variables are available in the hash:
interest_received (expected: numeric decimal representing the dollar amount of interest received) account_total (expected: numeric decimal representing the total amount of dollars in the account) in_funding (expected: numeric decimal representing the dollar amount currently in funding) available_cash (expected: numeric decimal representing the dollar amount available for investment or withdrawl) outstanding_principal (expected: numeric decimal representing the outstanding dollar amount of principal investment) accrued_interest (expected: numeric decimal representing the dollar amount of interest accrued, assuming all payments remain current) total_note_count (expected: numeric integer describing the total number of notes that have been invested in) total_paid (expected: numeric decimal representing the invested dollar amount paid back in total) principal_paid (expected: numeric decimal representing the invested dollar amount paid back from principal) interest_paid (expected: numeric decimal representing the invested dollar amount paid back from interest) late_fees (expected: numeric decimal representing the invested dollar amount paid in late fees) net_annualized_return (expected: numeric decimal representing the net percentage annualized return)
The get_note_data() function takes in a note ID and returns information about the note in a hash. Information about the note, information about the posts, as well as information about the member is available.
In this sample call...
$note{'member'} may contain the a hash of the following:
total_credit_lines (expected: numeric integer representing the total number of credit lines under the borrower's name)
open_credit_lines (expected: numeric integer representing total count of open credit lines)
recent_inquiries (expected: numeric integer representing total count of recent inquiries)
earliest_credit_line (expected: string {MM/YYYY})
debt_to_income_pct (expected: numeric decimal representing the debt to income percentage for the borrower)
revolving_credit_balance (expected: numeric decimal representing $ of revolving utilization of credit)
revolving_credit_utilization_pct (expected: numeric decimal representing revolving % of credit utilized each month)
delinquent_accounts (expected: numeric integer representing the total number of delinquent accounts under the borrower's name)
recent_delinquencies (expected: numeric integer representing the total number of recent delinquencies under the borrower's name)
last_delinquency_months_elapsed (expected: numeric integer representing the number of months elapsed since the last delinquency under the borrower's name)
delinquent_amount (expected: numeric decimal represing total $ amount delinquent)
gross_income (expected: numeric decimal representing $ per month earned)
current_employer (expected: string {unformatted})
length_of_employment (expected: numeric integer representing months of employment. 'N/A' for <1 year)
home_ownership (expected: string {OWN, RENT or MORTGAGE})
location (expected: string {City, ST})
public_records_count (expected: numeric integer representing total count of public records on file)
last_public_record_months_elapsed (expected: numeric integer representing the number of months since the last public record)
name (expected: string representing the member's name)
NOTE:
- Each of these will have two sub-values: "value" and "verified". "Value" will have the aforementioned value and "verified" will have a "1" if the value has been verified by LendingClub.
- For example, to get the income, use
$note{'member'}->{'gross_income'}->{'value'}>
and to check the verification of that
$note{'member'}->{'gross_income'}->{'verified'}
$note{'loan'} may contain the a hash of the following: num_investors (expected: a numeric integer representing the total number of investers who have invested in the loan)
amount_requested (expected: a numeric decimal representing the dollar amount requested by the borrower)
funding_received (expected: string representing the "funding received" for the loan. See also: funding_received_amt and funding_received_pct)
funding_received_pct (expected: a numeric decimal representing the percentage of requested funding received)
funding_received_amt (expected: a numeric decimal representing the dollar amount of requested funding received)
interest_rate (expected: a numeric decimal representing the percentage interest rate)
monthly_payment (expected: a numeric decimal representing the dollar amount scheduled for payment each month for this loan)
loan_grade (expected: string {{XY} where X is the A-G grade and Y is the 1-5 subgrade})
loan_length (expected: a numeric integer representing the number of months the loan was scheduled for)
loan_status (expected: string {In Funding, Issued, Current, Paid Off, Defaulted, < 30 Days Late, > 30 Days Late})
loan_submitted_date_time (expected: string {Mm/Dd/YY Hh:NN [AM/PM]})
listing_expires_in (expected: a numeric integer representing the APPROXIMATE number of minutes until the loan expires. may also be empty or "EXPIRED")
loan_purpose (expected: string {'Debt consolidation', 'Wedding Expenses', etc})
title (expected: string representing the title of the loan)
description (expected: string representing the description of the loan, as described by the borrower)
If the get_invested_notes() function was previously called, the following data may also be available in the $note{'loan'} hash:
is_invested (expected: boolean representing if this note has been invested in by the current uesr)
amount_lent (expected: numeric integer representing the sum of dollars lent into this note
remaining_principal (expected: numeric decimal representing the total principal remaining to be paid back to the current user)
payments_received (expected: numeric decimal representing the total amount of money that has been received from payments in this note)
next_payment_date (expected: string {MM/DD/YYYY} of the next payment due date)
in_portfolio_names (expected: string (csv) of portfolio names that this note is invested in)
in_portfolio_ids (expected: string (csv) of portfolio IDs that this note is invested in)
If the get_available_notes() function was previously called, the following data may also be available in the $note{'member'} hash:
job_title (expected: string representing the self-described job title by the member)
employment_status (expected: string {'EMPLOYED', 'SELFEMPLOYED', 'RETIRED', 'CONTRACTOR', 'STUDENT', 'UNEMPLOYED', 'PART_TIME'})
gross_income
->verification_status (expected: string {'VERIFIED', 'REQUESTED', 'FAILED_1', 'NOT_REQUIRED'})
Uses the API at http://www.fizber.com to get information about a city. This may be useful for gathering general statistics about an area, including housing and economy information. A great variety of information is available as a result of this call, and for an example full XML, please see: http://www.fizber.com/xml_data/xml_neighborhood_info.xml?type=city&state=OH&city=Massillon
For example, to get the median househod income in dollars:
$location_info->{'economy'}[0]->{'income'}[0]->{'median_household_income_dollars'}[0]->{'content'};
This is used internally, but may be used externally, to remove any non-numerics. Useful for stripping out percentage (%), dollar ($), and comma (,) symbols, as well as trimming spaces, etc.
www.lendingclub.com
www.fizber.com
Shane P Connelly <shane@eskibars.com>
Copyright (C) 2010 by Shane P Connelly
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.