Package: revolut-python
A Python wrapper for Revolut API, Python 3.x compatible.Latest releaseRelease 0.10.1, a working beta.Notes for 0.10.xdropped top-level classes in favor ofbusinessandmerchantsubmodulesMerchantClientthrows exceptions on failuresdroppedMerchantClient.update_orderNotes for 0.9.xaddedrevolut.merchantandMerchantClientwithin, which supports very basic Merchant
API functionality (creating and retrieving simple orders)therevolut.Clientclass has been renamed torevolut.business.BusinessClient; the old
import will remain valid in0.9.x, however it will issue warning and the resulting object
will fail on type checks, likeisinstancemoved other classes likeClient,Transaction, etc. to therevolut.businesssubmodule; top level import is deprecated, like above.What is supported?The module supports most of Business API features and some basic elements of the Merchant API.Business APIAs listed inRevolut Business API docs:AccountsGet AccountsyesGet AccountyesGet Account DetailsyesCounterpartiesAdd Revolut CounterpartyyesAdd non-Revolut CounterpartyyesDelete CounterpartyyesGet CounterpartyyesGet CounterpartiesyesPaymentsTransferyesCreate PaymentyesSchedule PaymentnoCheck Payment StatusyesCancel PaymentnoGet TransactionsyesMerchant APIAs described inRevolut Merchant API docs:OrdersCreate an orderyes, withcapture_mode = AUTOMATIConlyRetrieve an order listyesRetrieve an orderyesUpdate an orderpartiallyCapture an ordernoCancel an ordernoRefund an ordernoConfirm an ordernoCustomersnoWebhooksRetrieve all webhooksnoSet a webhook URLyesRetrieve webhook detailsnoUpdate webhook detailsnoDelete a webhooknoOthernoAuthorizationIn September 2019 Revolut introduced much more complex authorization system based on OAuth2.
Since version 0.6 this module supports only the new authorization model and old access keys
become obsolete.The flowThis description should help you get through the auth mess. It assumes you want to run the module
in a non-interactive way (e.g. as a backend for a web service). Mobile applications will require
some additional research on your side.Make sure you have OpenSSL installed.Run$ revolut_genkey.shto generate key pair. Answer questions about your organization.Two files will be generated:prvkey.pemandpubkey.pem. Store them in a safe place.
The script will also print the contents ofpubkey.pemto the console. This is yourX509 public key.In Revolut panel go toSettings / APIand clickSet up API access.Paste the public key into the form field.If you don’t know whatOAuth redirect URImeans and why you need it, enter some
bullshit URL there. It’d be better, however, if it pointed to your domain. Submit the form.You’ll land back in API settings, this time you will be presented withclient_idandissvalues needed in further steps.ClickEnable API access to your account, continue withAuthorize.Confirm with SMS code.After a couple of seconds you’ll be redirected to the URL you have provided asOAuth
redirect. Check the address bar. It will contain acodeparameter. This is yourauth_code.Run$ revolut_getjwt.py prvkey.pem <iss> <client_id>. The output will be yourjwt.Run$ revolut_gettokens.py <auth_code> <client_id> <jwt>. The script will returnaccess_token(with expiration time) andrefresh_token.
(If you do it too slowly, the auth code expires and you get “unauthorized_client” error.
Return to step 8.)Now you’re almost done, with some pieces of data on your hand. There are two ways to continue:Createrevolut.session.TemporarySessionwith theaccess_tokenand use it until
the token expires.Createrevolut.session.RenewableSessionwithrefresh_token,client_idandjwt. It will be more durable, creating freshaccess_tokeneach time.However, it seems thatafter 90 days your API access expires anywayand you’d have to clickRefresh accessin the panel and restart the above process from point 8. Or whatever the EU
shitheads invented in PSD2.CopyrightsReleased under the BSD 3-Clause License. SeeLICENSE.txt.Copyright (c) 2018-2022:Michał Sałaban <michal@salaban.info>Rafał Fuchs <r.fuchs@useme.com>Nikita Grygoriev <n.grygoriev@useme.com>