thicccat688 / peerberrypy Goto Github PK
View Code? Open in Web Editor NEWPeerberry API wrapper (Updated for 2023)
License: MIT License
Peerberry API wrapper (Updated for 2023)
License: MIT License
Hi,
First off, thanks for this nice little wrapper. Works great.
Here is my use case:
1 - List available loans
2 - Buy loans in a loop
This quickly causes the server to block me with a 429 response ("too many requests").
I want to be able to identify this response code and act accordingly (log it, wait and/or try to relogin).
As of now, RequestHandler.request()
takes an Exception class as argument and raises an instance of that exception if the response code is => 400, no matter what the problem is.
So at a higher level, the only way for me to find out what happened is to read the exception message. But this message comes straight from the server, and in the case of a 429, it is not very explicit and may not be specific to this error: {'rules': 'wq7te'}
.
Instead, I suggest creating and raising a TooManyRequests exception in RequestHandler.request()
when the response code is 429. Or maybe there is a better way to handle it, such as using requests.raise_for_status()
.
In addition to that, for my use case, the InsufficientFunds
exception that is passed by purchase_loan()
to RequestHandler.request()
covers too many cases. I counted at least 2 cases that cause this exception to be raised while my funds are sufficient, but there may be more:
I'm not sure what the best solution would be. I would either remove the exception_type
argument from RequestHandler.request()
, only raise "technical" exceptions in RequestHandler.request()
and let higher level functions process the response (and let them raise "business" exceptions).
I can drop a PR but would like to know your opinion beforehand.
Exception has occurred: TypeError 'int' object is not iterable File "\peerberrypy\api.py", line 211, in get_loans for idx, type_ in enumerate(loan_types): File "main.py", line 20, in <module> pd = api_client.get_loans(quantity=100, min_interest_rate= 9, loan_types=1) TypeError: 'int' object is not iterable
Hello, I think there's a little problem with the loan type filter, can you check if it works for you ? thanks.
Good afternoon, first of all, I wanted to thank you for this magnificent API. I must say that I'm a beginner, I noticed that after a while of using the API from my account, no loans were visible, even though I hadn't set any filters (although in reality, 5-6 long loans were present). How could I solve the problem? I found another way to invest with the API, but I'm not sure if it will last long. Thank you very much for your work.Good afternoon, first of all, I wanted to thank you for this magnificent API. I must say that I'm a beginner, and I noticed that after a while of using the API from my account, no loans were visible, even though I hadn't set any filters (although in reality, 5-6 long loans were present). How could I solve the problem? I found another way to invest with the API, but I'm not sure if it will last long. Thank you very much for your work.
In API.get_loans()
method, the following parameters are booleans with default value: group_guarantee
, exclude_invested_loans
.
However they are not correctly checked:
if group_guarantee is not None:
loan_params['groupGuarantee'] = 1
if exclude_invested_loans is not None:
loan_params['hideInvested'] = 1
These conditions are never matched.
It should be:
if group_guarantee:
loan_params['groupGuarantee'] = 1
if exclude_invested_loans:
loan_params['hideInvested'] = 1
Hi!
First of all, thanks for the work :)
I have launched the examples of "Usage" (Readme file):
"print(api_client.get_loans(quantity=100, originators=['Smart Pozyczka PL']))" and it returns this error:
>>> print(api_client.get_loans(quantity=100, originators=['Smart Pozyczka PL']))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Nacho\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\peerberrypy\api.py", line 185, in get_loans
loans_data = do_get_loans_page(page_num)['data']
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: API.get_loans_page() got multiple values for argument 'self'
I have tested without "originators" parameter and the result is the same.
The other functions works fine (get_profile and get_investments)
A project manager would make it simpler to publish new versions and manage dependencies, including handling a lock file.
Poetry is a probably the most popular, but I think a simple one like pdm would suffice.
Hello, nothing works for me. I always have Exception has occurred: JSONDecodeError
Hi,
The tests on github CI are invariably failing. That's not very useful and causes error report fatigue.
I see now they're failing due to missing credentials. Not sure if you want to keep your PB password at GH. If not, a reasonable step would be disabling GH actions.
IMO The only good way to test such a remote API client would be recording real responses and mocking the HTTP requests, so not making any remote API calls. Optionally real tests (against live API) could be run manually.
Hi,
I would like to use the "get_profit_overview" function. Unfortunately, I don't know how to write the start and end dates. I wrote "api_client.get_profit_overview(start_date="2022-02-01", end_date="2023-02-01", periodicity="day")". I wanted to know in which format to write the dates.
Can you please help me? Thank you in advance.
Hey,
firstly I very much enjoy using this project, it's of great help to me.
Now I'm not a professional dev so it might also be a lack of understanding, but I did quite some digging and experimenting.
I am getting the following error when trying to get loans:
INFO Exception in getLoans function, error: API.get_loans_page() got multiple values for argument 'self'
Now the strange thing is, I have one poetry virtual environment where the same exact code works, but I am not able to get it running again with a fresh setup.
I am trying to build a docker container to run as Google Run Job, however it also fails locally. I got some feeling it might have to do with the pandas version on the system, but I was also not able to downgrade that as well trying for hours. In the working environment I have pandas 2.0.3 which seems to work but cannot be installed anymore (tried on Windows locally and in a docker container).
I also got this warning, not sure if that's related:
FutureWarning: Passing bytes to 'read_excel' is deprecated and will be removed in a future version. To read from a byte string, wrap it in a BytesIO
object.
investment_data = pd.read_excel(
Hi,
since a few days the get_loans function does not return anything for me anymore besides the Lithuanian loans that are always available (e.g. real estate).
I have checked this while there were loans available in the morning, e.g. PL or KZ that sit for a minute or two. Still got no returns. I also removed all parameters except for the quantity to check if anything changed there, but still no results.
It's not an account ban, since web and mobile app work fine, also same IP.
They might have changed sth. on their end - could you verifiy this as well and is there any way around?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.