Package: pylendingclub
Free software: BSD 3-Clause LicenseInstallationpip install pylendingclubAboutA Python based wrapper for Lending Club’s API that enables easier programmatic use of the API. Also extends the functionality of the API through a higher-level wrapper for ease of use, and an AutoInvestor. More features to come.See the API documentation here:https://www.lendingclub.com/developers/api-overview.Getting StartedTo get started, download the package with pip:pip install pylendingclubOnce the package is installed, you will need a Session object. You can create one directly, by passing yourapi-keyandinvestor-id.from pylendingclub.session import LendingClubSession
session = LendingClubSession(api_key, investor_id)Alternatively, you can create environment variables for both of these values. Make sure they are created as ‘LC_API_KEY’ and ‘LC_INVESTOR_ID’.With environment variables set, you can create aSessionwith them like so:from pylendingclub import Session
session = LendingClubSession.from_environment_variables()Using the Session ObjectSessions and ResponsesCalls to the API through theSessionwill return aResponseobject. You can then work with this response as needed. If you just want the JSON data from the response, use the following syntax:response = session.resource.property
json_data = response.json()orresponse = session.resource.method()
json_data = response.json()You can also chain the.json()call directly onto the property, or method, but this won’t allow you to handle an error with the response without making a separate call to get the original response. Especially when working with thePOSTmethods, it is recommended to store the response separate from the JSON, but it is not required.Accessing ResourcesThere are two primary resources available within the API. These are theAccountandLoanresources. You can access them within theSessionlike so:account = session.account
loan = session.loanThese two resources expose the sub-resources/services within the API. More on this below.Remember, all of these services will return a `Response`.Account ResourceAccount SummaryAPI Documentation:https://www.lendingclub.com/developers/summaryMethod Type: GETSyntax:account_summary = session.account.summaryAvailable CashAPI Documentation:https://www.lendingclub.com/developers/available-cashMethod Type: GETSyntax:available_cash = session.account.available_cashNotesAPI Documentation:https://www.lendingclub.com/developers/notes-ownedMethod Type: GETSyntax:notes = session.account.notesDetailed NotesAPI Documentation:https://www.lendingclub.com/developers/detailed-notes-ownedMethod Type: GETSyntax:detailed_notes = session.account.detailed_notesPortfolios OwnedAPI Documentation:https://www.lendingclub.com/developers/portfolios-ownedMethod Type: GETSyntax:portfolios_owned = session.account.portfolios_ownedFiltersAPI Documentation:https://www.lendingclub.com/developers/filtersMethod Type: GETSyntax:filters = session.account.filtersCreate PortfolioAPI Documentation:https://www.lendingclub.com/developers/create-portfolioMethod Type: POSTSyntax:create_portfolio = session.account.create_portfolio(portfolio_name, [portfolio_description])Submit OrdersAPI Documentation:https://www.lendingclub.com/developers/submit-orderNote:The orders must be a list of dicts in the format:[
  {
    'loanId' : loan_id,
    'requestedAmount' : amount,
    'portfolioId' : portfolio_id
  }
]WhereloanIdandrequestedAmountare required, andrequestedAmountmust be a denomination of 25.For example:[
  {
    'loanId' : 1234,
    'requestedAmount' : 25,
  },
  {
    'loanId' : 1345,
    'requestedAmount' : 50,
    'portfolioId' : 12345
  }
]Method Type: POSTSyntax:submit_orders = session.account.submit_orders(orders)Submit OrderAPI Documentation:https://www.lendingclub.com/developers/submit-orderMethod Type: POSTNote: Therequested_amountmust be a denomination of $25.00. For example, 25, 100, and 2000 are all accepted values but 26, 115, and 2010 are not.Syntax:submit_order = session.account.submit_order(loan_id, requested_amount, [portfolio_id])Account/FundsPending TransfersAPI Documentation:https://www.lendingclub.com/developers/pending-transfersMethod Type: GETSyntax:pending_transfers = session.account.funds.pendingAddAPI Documentation:https://www.lendingclub.com/developers/add-fundsMethod Type: POSTNotes:Thetransfer_frequencyargument must be one of[LOAD_NOW, LOAD_ONCE, LOAD_WEEKLY, LOAD_BIWEEKLY, LOAD_ON_DAY_1_AND_16, LOAD_MONTHLY]The ‘start_date’ argument is required for recurring transfers, and forLOAD_ONCE.Syntax:add_funds = session.account.funds.add(amount, transfer_frequency, [start_date], [end_date])WithdrawAPI Documentation:https://www.lendingclub.com/developers/add-fundsMethod Type: POSTSyntax:withdraw_funds = session.account.funds.withdraw(amount)Cancel TransferAPI Documentation:https://www.lendingclub.com/developers/cancel-transfersMethod Type: POSTSyntax:cancel_transfer = session.account.funds.cancel(transfer_id)Loan ResourceListed LoansAPI Documentation:https://www.lendingclub.com/developers/listed-loansMethod Type: GETNotes:Theshow_allargument will determine whether all loans are shown, or only the loans from the most recent listing period are shown.Thefilter_idargument, if provided, will only show loans matching the filter.Syntax:listed_loans = session.loan.listed_loans([filter_id], [show_all]=True)Changelog4.0.0 (2018-10-16)First release on PyPI.