GithubHelp home page GithubHelp logo

revolut-python's Introduction

revolut-python

Travis Coveralls github PyPI License

Description

Non-official client for the Revolut Bank

I wrote a French blog post about it here

Requirements

  • Python 3
  • pip3

Installation

pip3 install -U revolut

CLI tool : revolut_cli.py

Usage: revolut_cli.py [OPTIONS]

  Get the account balances on Revolut

Options:
  -d, --device-id TEXT  your Revolut token (or set the env var
                        REVOLUT_DEVICE_ID)

  -t, --token TEXT      your Revolut token (or set the env var REVOLUT_TOKEN)
  -l, --language TEXT   language ("fr" or "en"), for the csv header and
                        separator

  -a, --account TEXT    account name (ex : "EUR CURRENT") to get the balance
                        for the account

  --version             Show the version and exit.
  --help                Show this message and exit

Example output :

Account name,Balance,Currency
EUR CURRENT,100.50,EUR
GBP CURRENT,20.00,GBP
USD CURRENT,0.00,USD
AUD CURRENT,0.00,AUD
BTC CURRENT,0.00123456,BTC
EUR SAVINGS (My vault),10.30,EUR

If you don't have a Revolut token yet, the tool will allow you to obtain one.

⚠️ If you don't receive a SMS when trying to get a token, you need to logout from the app on your Smartphone. ⚠️ You may also receive an authentication email instead of a SMS. Take note of the link on the Authenticate button. It should look like https://revolut.com/app/email-authenticate/<CODE>?scope=login. You can enter this code in the CLI.

Pulling transactions

Usage: revolut_transactions.py [OPTIONS]

  Get the account balances on Revolut

Options:
  -d, --device-id TEXT            your Revolut token (or set the env var
                                  REVOLUT_DEVICE_ID)

  -t, --token TEXT                your Revolut token (or set the env var
                                  REVOLUT_TOKEN)

  -l, --language [en|fr]          language for the csv header and separator
  -t, --from_date [%Y-%m-%d]      transactions lookback date in YYYY-MM-DD
                                  format (ex: "2019-10-26"). Default 30 days
                                  back

  -fmt, --output_format [csv|json]
                                  output format
  -r, --reverse                   reverse the order of the transactions
                                  displayed

  --help                          Show this message and exit.

Example output :

Date-time,Description,Amount,Currency
08/26/2019 21:31:00,Card Delivery Fee,-59.99,SEK
09/14/2019 12:50:07,donkey.bike **pending**,0.0,SEK
09/14/2019 13:03:15,Top-Up by *6458,200.0,SEK
09/30/2019 16:19:19,Reward user for the invite,200.0,SEK
10/12/2019 23:51:02,Tiptapp Reservation,-250.0,SEK

TODO

  • Document revolutbot.py
  • Create a RaspberryPi Dockerfile for revolutbot (to check if rates grows very often)
  • Improve coverage for revolutbot

revolut-python's People

Contributors

cosmincc avatar ferensz avatar leikoilja avatar mehdichaouch avatar odinuge avatar tducret avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

revolut-python's Issues

cannot generate token

Hi.

Thanks for your work.

I tried the pip module and the source code, both cases the same issue.
See below:

styx :: ~/_REPOS_/revolut-python » ./revolut_cli.py 
You don't seem to have a Revolut token
Would you like to generate a token [yes/no] ? yes
What is your mobile phone (used with your Revolut account) [ex : +33612345678] ? +44**********
What is your Revolut app password [ex: 1234] ? ****
Traceback (most recent call last):
  File "./revolut_cli.py", line 90, in <module>
    main()
  File "/home/antouank/.local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/antouank/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/antouank/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/antouank/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "./revolut_cli.py", line 42, in main
    get_token()
  File "./revolut_cli.py", line 65, in get_token
    password=password,
  File "/run/media/antouank/evo1/_REPOS_/revolut-python/revolut/__init__.py", line 337, in get_token_step1
    expected_status_code=204)
TypeError: _post() got an unexpected keyword argument 'json'

History file missing

Hi.. Great work.!

I could generate my token and see my current balances using CLI. However, I couldn't run the bot. I'm getting historyfile missing error

Usage: revolutbot.py [OPTIONS]
Try "revolutbot.py --help" for help.

Error: Missing option "--historyfile" / "-f".

Thanks,
Ajay

Revolutbot.py still usable ?

Hello,
I was trying to use the revolut bot but got python errors :

01:/opt/revolut-python# revolutbot.py --historyfile=exchange_history.csv --device-id=XXXXXXXXXXXX --token=XXXXXXXXXXXXXXXXXXXXXXXX
Traceback (most recent call last):
  File "/usr/local/bin/revolutbot.py", line 140, in <module>
    main()
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/bin/revolutbot.py", line 70, in main
    forceexchange=forceexchange)
  File "/usr/local/bin/revolutbot.py", line 82, in to_buy_or_not_to_buy
    filename=filename)
  File "/usr/local/lib/python3.6/dist-packages/revolut_bot/__init__.py", line 69, in get_last_transactions_from_csv
    return list(map(dict_transaction_to_Transaction, last_transactions))
  File "/usr/local/lib/python3.6/dist-packages/revolut_bot/__init__.py", line 80, in dict_transaction_to_Transaction
    real_amount=float(tr_dict["from_amount"]),
TypeError: float() argument must be a string or a number, not 'NoneType'

I don't know where to check first. any help ?

Status code 401 : The request should be authorized

Hello,

Since a few days, I got a 401 from api.revolut.com. I tried to regenerate a new token but even with one I still got a 401.
Does the issue is on my side or revolut ?

root@01:/opt/revolut-python# python3 revolutbot.py --historyfile=/opt/revolut-python/exchange_history.csv --token==  --verbose --simulate 
Last transaction : (05/10/2020 16:30:00) X EUR => X BTC
Traceback (most recent call last):
  File "revolutbot.py", line 140, in <module>
    main()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "revolutbot.py", line 67, in main
    to_buy_or_not_to_buy(revolut=rev,
  File "revolutbot.py", line 90, in to_buy_or_not_to_buy
    current_balance_in_other_currency = revolut.quote(
  File "/opt/revolut-python/revolut/__init__.py", line 221, in quote
    ret = self.client._get(url_quote)
  File "/opt/revolut-python/revolut/__init__.py", line 148, in _get
    raise ConnectionError(
ConnectionError: Status code 401 for url https://api.revolut.com/quote/BTCEUR?amount=XX&side=SELL
{"message":"The request should be authorized."}

get_account_transactions looping infinitely over the same transaction

Hi @tducret ,

First of all, thanks for the great library! :-)

I was using your library to load historical transactions from last 2 years, when I noticed that get_account_transactions is getting stuck in a specific case.

In my example:

  1. first run of the loop
  • from 2019-03-01 to 2019-03-15, returned 47 transactions
  • algorithm takes startedDate from the oldest transactions and sets it as a new to parameter
  1. second run of the loop
  • from 2019-03-01 to 2019-03-01 09:29:38, returned 1 transaction - the same transaction which was present in first run
  • algorithm takes startedDate from the oldest transactions - which is the same as before
  1. step #2 is repeated endlessly

I worked around it by manually subtracting 1 second from the timestamp, as below.

    def get_account_transactions(self, from_date=None, to_date=None):
        """Get the account transactions."""
        raw_transactions = []
        params = {}
        if to_date:
            params['to'] = int(to_date.timestamp()) * 1000
        if from_date:
            params['from'] = int(from_date.timestamp()) * 1000

        while True:
            ret = self.client._get(_URL_GET_TRANSACTIONS_LAST, params=params)
            ret_transactions = ret.json()
            if not ret_transactions:
                break
            params['to'] = ret_transactions[-1]['startedDate']-1000 # fixed, because this loop was endlessly fetching the same transaction
            raw_transactions.extend(ret_transactions)
        
        return AccountTransactions(raw_transactions)

I'm not sure if it is possible to have more than one transaction with the same startedDate, but if yes, then this is not a proper solution.

Did you encounter case like that with your account?

Regards,

Email-based authentication

When I tried to authenticate, instead of receiving an SMS, I received an email.

The email contained an "Authenticate" button which had a link to https://revolut.com/app/email-authenticate/<code was here>?scope=login. When I took the code and entered it, everything worked. Perhaps the instructions can be updated?

Chat Support

The that seems to be a quit simple chat. Their is only a possibility to upload and to write text. Also their say that they got UI Problems so their is no reason until now that the chat got a huge load of new UI features.

Infinite loop in get_account_transactions

Hey,

I have a script using your wonderful library which has been working great so far.
When i ran it earlier this day, i got an unexpected result; it hang.

I had to dig to find out why it got into this state.

The issue comes from the method get_account_transactions.
https://github.com/tducret/revolut-python/blob/master/revolut/__init__.py#L186

get_account_transactions never breaks from the infinite loop because the revolut api always returns a transaction.
To be more precise, the first call to the api (so first loop) returns N transactions, to param is updated with the datetime of the last retrieved transaction, then the second loop (and those after) always return 1 transaction => stuck in loop.

I don't understand the need for the loop here, are there any specific cases ?

Right now, i just removed the loop to solve the issue because the first api call returns the requested transactions.

Thanks in advance.

Token

Hi, I have a problem with creating of Revolut token. I try to run revolut_cli.py and then fill the phone number and application pin. Subsequently, the application gets unknown error:

An unknown error has occurred: Status code 400 for url https://api.revolut.com/signin
{"message":"Please upgrade the app to the latest version to use this functionality","code":2000}

Are this application and library still ready for use?

Restore Dialog

Their is restore dialog after enter the revolut password. It would be nice to see this in action here. Their is also a backfall to the chat so better implement the chat first.

get full card digits

Is it not possible to get the full digits on the revolut card? I have looked into their api. And when you are displaying the full digits they are sending a /image-data response. But it's not easy translatable into json data.

Token generation

I have a problem generating Revolut token:

What is your mobile phone (used with your Revolut account) [ex : +33612345678] ? +371XXXXXXXX
What is your Revolut app password [ex: 1234] ?
An unknown error has occurred: Status code 204 for url https://api.revolut.com/signin

As I understand, script should ask me for verification code, but I get unknown error.
Is there a solution?

Downloading Transactions

Hi,
Nice tool.
It would be awesome to download historic transactions. How did you discover the API urls?
Kind regards
Christian

Is there a way to intercept the SSL traffic on an Android?

I am trying to see if there are any new changes to their API, but I can't seem to intercept the SSL traffic with Charles.
Some notes: I have a rooted android, installed the certificate and some SSL Unpinning tools but I had no luck.
Even tried with the version this reppo uses, 6.34.3 but still no luck.
Any tips? Or do you mind sharing how did you intercept the traffic?
Thanks in advance!

it asks for a selfie.png file

When trying ot login it asks for a selfie.png file. It doesn't matter if you're logged in our logged out of your smartphone, it always asks it. Instructions on README.md do not mention this nor what to do about it.

[FEATURE REQUEST] Trading endpoints

Can we add trading endpoints?

Revolut app seems protected with SSL pinning, and prevent me to reverse engineer the application to find endpoints.

Did you face same issue?

How can I use a unique X-Device-Id?

We used this Revolut API for many users and after that the accounts of our users get locked, because Revolut thought there was a DDoS attack because every user had the same X-Device-Id.
Do you know how to generate a unique device id that is accepted by the API?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.