Author Topic: Folio API note selling  (Read 641 times)

Ran

  • Full Member
  • ***
  • Posts: 145
    • View Profile
    • Email
Folio API note selling
« on: March 07, 2018, 09:14:07 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. 

hdsouza

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: Folio API note selling
« Reply #1 on: March 10, 2018, 12:04:37 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.


Fred93

  • Hero Member
  • *****
  • Posts: 2054
    • View Profile
Re: Folio API note selling
« Reply #2 on: March 11, 2018, 06:04:49 AM »
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.

Ran

  • Full Member
  • ***
  • Posts: 145
    • View Profile
    • Email
Re: Folio API note selling
« Reply #3 on: March 11, 2018, 09:54:01 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.
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.

kuhnrl30

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • R Package for Lending Club
Re: Folio API note selling
« Reply #4 on: May 24, 2018, 03:36:40 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. 

mark78

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Folio API note selling
« Reply #5 on: July 09, 2018, 05:57:59 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.

hdsouza

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: Folio API note selling
« Reply #6 on: July 09, 2018, 06:50:47 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.

mark78

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Folio API note selling
« Reply #7 on: July 10, 2018, 04:05:34 AM »
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
>>>



hdsouza

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: Folio API note selling
« Reply #8 on: July 10, 2018, 06:28:31 PM »
Thanks Mark.

martinp2p

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Folio API note selling
« Reply #9 on: October 11, 2018, 12:14:47 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!

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.