lending club ws integration
DESCRIPTION
lendingTRANSCRIPT
Lending Club WS Integration
Guide
Contents Scope ........................................................................................................................................................... 3
Overview ...................................................................................................................................................... 3
Integration .................................................................................................................................................... 4
JDK standard JAX-WS ................................................................................................................................ 4
Client stub generation ........................................................................................................................... 4
Client stub instantiation ........................................................................................................................ 4
Apache Axis2/Java..................................................................................................................................... 5
Client stub generation ........................................................................................................................... 5
Client stub instantiation ........................................................................................................................ 5
PHP with wsdl2php ................................................................................................................................... 6
Client stub generation ........................................................................................................................... 6
Client stub instantiation ........................................................................................................................ 6
SoapUI ....................................................................................................................................................... 7
Integration Steps ....................................................................................................................................... 7
FAQ .............................................................................................................................................................. 7
Scope This document is intended as a guide for customers integrating with the Lending Club (LC)
platform using its webservice application programming interface (API’s). This document
indicates the different steps that LC recommends to integrate with the API and provides details
of the various staging and production environments. It also includes references to some of the
most commonly used web service tools and specifies code snippets across commonly used
programming languages. The document should be used in conjunction with the LendingClub –
Webservices-Technical Overview document and the LendingClub.wsdl and LendingClub -
schema.xsd definitions.
Overview Lending Club exposes XML web service API’s that allow investors to access the primary market
platform programmatically. The webservice operations are defined in the LendingClub.wsdl and
any investor wishing to integrate with LC can use the wsdl file to generate client side stubs to
invoke the different operations. Integrating with the Lending Club web service into a third party
application is a technology platform-dependent task. However, the following steps are generally
required:
• Client side stub generation.
• Instantiating the client.
Instructions for JDK standard JAX-WS, Apache Axis2/Java tools, and PHP are provided in this
document. SOAPUI has also been referred to as a quick lookup tool that can conveniently be
used to understand the services without the need of coding.
Integration
JDK standard JAX-WS
Client stub generation
Since this tool comes with any JDK6+ no additional downloads are required. To have the stubs
generated just run the following command:
<jdk-dir>/bin/wsimport -d <path-to-classes-output-dir> -keep -s <path-
to-source-code-output-dir> –verbose
https://www.lendingclub.com/ws/<version>?wsdl
You may want to compile the code yourself and add it to your source repository, so it’s
suggested that you point <path-to-classes-output-dir> to a temporary or disposable
folder.
Note that JDK is needed, JRE will not suffice.
Client stub instantiation
To instantiate a client you must create a Lending Club service instance and get the port and set
the username and password to its request context. Every time you reuse the client the
credentials will be automatically sent as a header, you don’t need to set or send them again on
each request.
The generated client is not thread-safe, so you should avoid sharing the client object among
threads at the same time.
For high frequency users, we encourage the use a pool of clients to reduce SSL handshaking
delays. (This requires you to leave Java system property http.keepAlive as true, the default, see
this)
Code example:
package com.lendingclub.wsexample; import java.util.Map; import javax.xml.ws.BindingProvider; import com.lendingclub.ws.LendingClub; import com.lendingclub.ws.LendingClub_Service; public class JaxWsExample { public static void main(String[] args) { LendingClub lendingClub = new LendingClub_Service().getLendingClubPort(); BindingProvider bindingProvider = (BindingProvider) lendingClub; Map<String, Object> requestContext = BindingProvider.getRequestContext(); requestContext.put( BindingProvider.USERNAME_PROPERTY, "[email protected]");
requestContext.put(BindingProvider.PASSWORD_PROPERTY, "mypwd"); } }
Apache Axis2/Java
Client stub generation
Get the latest binary distribution of Axis2/Java from http://axis.apache.org/axis2/java/core/ and
extract it into your file system. Then set the AXIS2_HOME environment variable to the chosen
file system directory (this is only required for client generation, you don’t need to set this
variable permanently). Generate the client by running:
<axis2-dir>/bin/wsdl2java.sh -s -d jaxbri -or -Ejavaversion 1.5 --
noBuildXML -o <path-to-source-code-output-dir> -uri
https://www.lendingclub.com/ws/<version>?wsdl
There are several options you may want to specify; the above options are only suggested.
Note: There is a bug in Axis2 JAXBRI codegen component that causes “/src” to be appended to
your output directory. Even if “-S“ option is specified, it is will be honored for WSDL derived
classes but not for XSD derived classes). You can either: keep the code under “src”, move the
files after generated or use one of the JAXBRI alternatives. See the bug report.
Client stub instantiation
To instantiate a client you must create a Lending Club stub, allow preemptive authentication and
set the username and password. Every time you reuse the client the credentials will be
automatically sent as a header, you don’t need to set or send them again on each request.
As created in the code example, the generated client is not thread-safe, so you should avoid
sharing the client object among threads.
For high frequency users, we encourage the use a pool of clients to reduce SSL handshaking
delays. (This requires HTTP keepAlive, to enable, set the
HTTPConstants.REUSE_HTTP_CLIENT service client option to true, see this)
Code example:
package com.lendingclub.wsexample; import org.apache.axis2.AxisFault; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.transport.http.HTTPConstants; import org.apache.axis2.transport.http.HttpTransportProperties; import com.lendingclub.ws.LendingClubStub; public class Axis2Example { public static void main(String[] args) throws AxisFault { LendingClubStub lendingClub = new LendingClubStub();
ServiceClient serviceClient = lendingClub._getServiceClient(); Options serviceClientOptions = serviceClient.getOptions(); HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator(); authenticator.setPreemptiveAuthentication(true); authenticator.setUsername("[email protected]"); authenticator.setPassword("mypwd"); serviceClientOptions.setProperty( HTTPConstants.AUTHENTICATE, authenticator); serviceClientOptions.setProperty( HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE.toString()); } }
PHP with wsdl2php
Client stub generation
There are several options for client stub generation; one suggestion is urdalen’s wsdl2php
script. This client relies on PHP’s SoapClient, so the soap extension is needed. To generate the
php classes download and extract wsdl2php pear file and run:
<php-dir>/php <wsdl2php-dir>/bin/wsdl2php.php
https://www.lendingclub.com/ws/<version>?wsdl
A file named LendingClub.php will be generated in the current directory, ensure you run the
command from the directory in which you want to have the client generated.
Client stub instantiation
To instantiate a client you just need to create a Lending Club client instance with the username
and password set among other options. Every time you reuse the client the credentials will be
automatically sent as a header, you don’t need to set or send them again on each request.
For high frequency users, if you plan to keep the script running (the same php process ) we
encourage the reuse the client and to add to the 'keep_alive' => true option to the
options array in the following example, this will reduce SSL handshaking delays.
Code example:
require_once('LendingClub.php'); $lendingClubOptions = array( 'login' => '[email protected]', 'password' => 'mypwd', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS ); $lendingClub = new LendingClub( 'https://www.lendingclub.com/ws/<version>?wsdl', $lendingClubOptions);
The SOAP_SINGLE_ELEMENT_ARRAYS feature is to avoid the default SoapClient behavior that
causes single element-arrays to be flattened. More options and details can be found here.
SoapUI
SoapUI is a tool mainly used for testing, however it’s also useful when you first deal with a web service and you want to try it or see what it provides without the hassle of coding. Get the free version of the client from http://www.soapui.org/ and install it
• Do File, New project
• Choose a name and enter https://www.lendingclub.com/ws/<version>?wsdl and accept
• Sample requests will be created. Choose one, fill the placeholders and hit submit to get the results.
Integration Steps
LC provides a staging environment for investors to test and try out the webservice integration before moving to production. The stage environment can be accessed at https://sandbox.lendingclub.com/ws/<version>. Investor accounts can be created using the normal registration process or can be setup with the help of a LC contact person. Please make sure you do not enter any real personal information on this server. The production environment is accessible at https://api.lendingclub.com/ws/<version>. Note that LC needs to enable your account to access the web service before any API/order is accepted. Also any operations submitted on the production environment are final and not reversible.
FAQ 1) What is the current active version for the webservice?
The current active version is 1.4 2) How do I get the credentials to be used in the webservice call?
The credentials to both stage and production environments are the same the login credentials that are used for logging into your account through the web portal. Please make sure you do not input any personal information while setting up the account on that environment. If you need help with setting up your account on stage, please contact LC. Before making calls on the production environment, please make sure that your account is enabled to use the API’s.
3) How do I manage multiple accounts using a single set of credentials? The webservice API’s are designed for allowing multiple accounts. However, as of version 1.4, this functionality has not been enabled. Please use different credentials for managing separate accounts
4) How do I get the aid attribute to be sent in the request for submitOrders? The aid attribute is your member id and can be retrieved by logging into your LC account through the web portal and visiting the account summary page.
5) How do I know if I have access to whole loans or fractional loans? By default, all accounts have access to the fractional part of the market. For more details, please contact LC.
6) Can I invest in whole loans while being a retail investor or vice versa? No. During the initial loan listing period, the two sets are exclusive.