Clicky

  • Welcome to P2P Lending / NFT Lending Forum.
 

ETH.LOAN

News:

This was the original Lend Academy peer-to-peer lending forum, since forensically restored by deBanked and now reintroduced to eth.loan.

To restore access to your user account, email [email protected]. We apologize for errors you may experience during the recovery.

Main Menu
NEW LOANS:   | 870.eth 2.500 Ξ | 804.eth 2.500 Ξ | remoraid.eth 0.299 Ξ | ALL

Lending Club API questions.

Started by Peter, April 22, 2015, 11:00:00 PM

Previous topic - Next topic

ernst20020530

I have really confused about the new API. I am new guy for python, then I tried following


 req = urllib2.Request('https://api.lendingclub.com/api/investor/v1/accounts/111111/summary" class="bbc_link" target="_blank">https://api.lendingclub.com/api/investor/v1/accounts/111111/summary')  #111111 is my account ID
    try: response = urllib2.urlopen(req)
    except urllib2.URLError as e:
        print e.reason

But the code always failed with error code  "Unauthorized ".

what's wrong with the code.

Fred93


kbenson99

Since you are using python, I'd suggest using the "requests" module; install using "pip install requests".

Use a requests.Session instance, add the authorization header {''Authorization': 'your api key'} to the session header and then call the get method on the session instance with the url value.



Booleans

My C# code looks something like this.

Code: [Select]

TravelingPennies

s = requests.Session()
s.headers.update({'Authorization':'zCdTrv+LoQ5w2J2Z5Y5BYRo22eM='})
r = s.get('https://api.lendingclub.com/api/investor/v1/accounts/910322/summary',auth=('[email protected]','huahua1QA2WS3ED" class="bbc_link" target="_blank">https://api.lendingclub.com/api/investor/v1/accounts/910322/summary',auth=('[email protected]','huahua1QA2WS3ED'))
    print(r.status_code)

I tried this, but the error code is 401. I cannot figure out the reason.

TravelingPennies

With the authorization header added to the request Session instance, you do not need the "auth" parameter to be passed to the session instance's get method.  I "think", not sure, if you pass the auth parameter, it overrides the authorization header.

For your session instance, with no auth param, s.get(url) should work.  With the response instance from the session get call, the json() method will return your result.   https://forum.lendacademy.com/Smileys/default/smiley.gif" alt=":)" title="Smiley" class="smiley" />

jheizer

I'd get a new auth code since you just gave everyone the code and your account number.

NEW LOANS:   | 870.eth 2.500 Ξ | 804.eth 2.500 Ξ | remoraid.eth 0.299 Ξ | ALL