P2P Lending / NFT Lending Forum

Lending Club Discussion => Foliofn - LC => Topic started by: Ran on March 06, 2018, 11:00:00 PM

Title: Folio API note selling
Post by: Ran on March 06, 2018, 11:00:00 PM
Anyone successfully used the latest Folio Notes API to post notes for sell?
The API document said you may POST to url https://api.lendingclub.com/api/investor/v1/secondarymarket/accounts/ACCOUNTID/orders
with JSON content like [{"noteId":"NOTEID","price":25.00, "orderType":"SELL","expirationDate":"2018-03-14"}].
I tried but only get 400 bad request which means my JSON content is rejected. Now I am wondering whether that API document simply contains error. 
Title: Folio API note selling
Post by: hdsouza on March 09, 2018, 11:00:00 PM
Yes. I have a similar problem with that API (I use the buy function)
 I have been going back and forth with LC Support for about a month now .

With the new api i tried Content-Type - application/json and Accept - application/json which failed. When I mentioned it to support they asked me to change it to text/csv. That failed too. Then they asked to change it back to application/json.. wow. now we are having funnnnnn.. and I have been sending them screenshots everytime.

They used to have a different API to buy/sell earlier which needed the "order id" and that was working fine. Now they go and change it and dont want to admit there is a problem.

Title: Folio API note selling
Post by: Fred93 on March 10, 2018, 11:00:00 PM
It is almost impossible to "engage" LC's real software people these days.  You get answers from intermediaries who don't really know, and don't really concentrate on the question, so you get a lot of muddled and quite frankly wrong answers.

I use the new buy function, but I've never switched to the new sell function, so I don't know the answer.
Title: Folio API note selling
Post by: TravelingPennies on March 10, 2018, 11:00:00 PM
I used the old api which has access point like /account/buy to buy Folio notes and it still works fine. Guess we need to wait for LC to sort the new API out. from: hdsouza on March 10, 2018, 12:04:37 PM
Title: Folio API note selling
Post by: kuhnrl30 on May 23, 2018, 11:00:00 PM
I haven't tried it yet but I wouldn't be surprised if there were bugs.  There's issues in the Orders Listing too. 
Title: Folio API note selling
Post by: mark78 on July 08, 2018, 11:00:00 PM
The new sell API works for me. I got a response 400 at first, because my expiration date was too long or too short. If you get a 400, look at the response content anyway, and you'll see the error message.

I don't know what the allowable expiration range is. Something like 1-5 days from now.

I can post code if it helps.
Title: Folio API note selling
Post by: TravelingPennies on July 08, 2018, 11:00:00 PM
Yes. if you post the code that would be great.
I am still using the old API, but it would be a good backup to have,  especially if LC forces us to use the new API.
Thanks Mark.
Title: Folio API note selling
Post by: TravelingPennies on July 09, 2018, 11:00:00 PM
import json, requests

def sell(note_id, price, exp_str):
   
    url = "https://api.lendingclub.com/api/investor/v1/secondarymarket/accounts/%d/orders" % accountnum
   
    header = {'Authorization': investorid,
              'Content-Type': 'application/json'}
   
    payload = json.dumps(
                            [
                                {
                                    'noteId':str(note_id),
                                    'price': price,
                                    'orderType': 'SELL',
                                    'expirationDate': exp_str
                                }
                            ]
                        )
       
    resp = requests.post(url, headers=header, data=payload)
    code = resp.status_code
    status = resp.json()[0]['status']
    print code, status

Various ways to screw it up:

>>> sell(123456789, 10.00, '2018-07-12')
400 NOTES_ARE_NOT_YOURS
>>>
>>> sell(123, 10.00, '2018-07-12')
400 NOTE_DOES_NOT_EXIST
>>>
>>> sell(148619010, 100.00, '2018-07-12')
400 ASKING_PRICE_IS_TOO_HIGH
>>>
>>> sell(148619010, 23.00, '2018-07-09')
400 ORDER_EXPIRE_DATE_TOO_SHORT
>>>
>>> sell(148619010, 23.00, '2018-07-30')
400 ORDER_EXPIRE_DATE_TOO_LONG
>>>
>>> sell(148619010, 23.00, '2018-07-12')
200 SUCCESS_LISTING_FOR_SALE
>>>


Title: Folio API note selling
Post by: TravelingPennies on July 09, 2018, 11:00:00 PM
Thanks Mark.
Title: Folio API note selling
Post by: martinp2p on October 10, 2018, 11:00:00 PM
Hi Ran,

The old API worked for me (after some trial and error). Here is sample code in C#:

        const string investorId = "12345678";
        const string authKey = @"xxxxxxxxxxxxxxxxxxxxxxxxxxx";

        string baseAddress = string.Format("https://api.lendingclub.com/api/investor/v1/accounts/{0}/", investorId);
        HttpClient client = new HttpClient();
        client.BaseAddress = new Uri(baseAddress);
        var result = client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", authKey);

        HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "trades/sell");
        request.Content = new StringContent(sellRequestBodyJson, Encoding.UTF8, "application/json");
        HttpResponseMessage response = await client.SendAsync(request);

        if (response.IsSuccessStatusCode)
        {
            string jsonResult = await response.Content.ReadAsStringAsync();

        }

Hope this helps!

from: Ran on March 07, 2018, 09:14:07 PM