A script that fetches SMS messages from an Android phone and analyzes supported bank messages to produce JSON and CSV transaction data.
- Al Rajhi (
AlRajhiBank) - Alinma (
alinma)
Template samples are available in the samples/ folder.
- Pulls an SMS backup from an Android phone.
- Converts supported bank messages to JSON.
- Extracts information such as
type,ingoing/outgoing,amount,from/to, andat. - Produces a CSV file for analysis.
adb- USB debugging enabled on the Android phone
- Python 3.8+
git clone https://github.com/Muaath5/bank_sms_parser.git
cd bank_sms_parser
./script.shThe sample checker uses only the Python standard library. It parses every committed sample and fails when a parser raises an error or returns an unknown template.
python3 scripts/check_samples.pyInformational messages such as verification codes and account notices are counted as ignored. Supported financial messages are counted as parsed.
Fixed conversion rates are stored in scripts/exchange_rates.py. They are project defaults and are not live exchange rates.
In ./data/merchants.json, you can assign different merchant titles to the same company and add a three-letter classification suffix. For example, SAUDI ARABIAN and SAUDI AIRLINES can both map to saudia_trn.
The current possible classes are:
CLASSES = {
"tls": "Tools",
"mkt": "Supermarkets",
"rst": "Restaurants",
"onl": "Online",
"chr": "Donation",
"inv": "Invest",
"gov": "Gov",
"tea": "Drinks",
"gas": "Gas",
"lnd": "Laundry",
"clt": "Clothing",
"trn": "Transport",
"net": "Internet",
"srv": "Services",
"cld": "Cloud",
"idk": "Unknown"
}You can also use manual_classification.json:
{
"1780098870_abcdef": "Internet",
"1784810195_3e9fde": "Gas"
}id: unique ID in the format{unix_timestamp}_{sms_message_hash_6_letters}sms_bank: currently eitheralinmaorAlRajhiBanksms_text: original SMS textsms_date: SMS date inyyyy-mm-dd hh:MM:ssformat
Optional fields depend on the message type:
flow: eitheringoingoroutgoingtype:buy,buy_internet,transaction, or another supported typeamount: amount converted to SARfor: merchant namefrom: sourceto: destinationat: date and time included in the bank SMS
Headers:
iddateamounttypeassignedbankclassification
Copyright (C) 2026 Muaath Alqarni.
Licensed under the GNU Affero General Public License v3.0 only (AGPL-3.0-only). Distributed forks and modified versions must follow the license's source-sharing requirements. See LICENSE for the full terms.