Skip to main content

Unofficial Python wrapper for Canadian Tire Triangle Mastercard API

Project description

Triangle Mastercard API (Unofficial) 🇨🇦

Python Version License: MIT Maintenance

A Python wrapper for the private Triangle Mastercard (Canadian Tire Financial Services) API.

This project reverse engineers the official web portal to extract balance, limit, and transaction information, allowing you to integrate your financial data into your own apps, bots, or spreadsheets.


⚠️ Legal Notice (Disclaimer)

This project is not affiliated with, maintained, authorized, endorsed, or sponsored by Canadian Tire Financial Services (CTFS) or any of its affiliates.

This is independent software for educational and personal use. Using automation to access banking accounts may violate the institution's Terms of Service. Use responsibly and at your own risk.


✨ Features

  • Automated Authentication: Performs login with Playwright while handling bot protection.
  • MFA Support: Detects and prompts for SMS/Security code input in the terminal.
  • Session Persistence: Stores cookies locally to avoid frequent logins and reduce blocking risk.
  • Account Summary: Current balance, available credit, total limit, and due date.
  • Transaction History: (In development)
  • Triangle Rewards: Canadian Tire Money balance (In development)

🚀 Installation

  1. Clone the repository:
git clone https://github.com/diogobas/triangle-api.git
cd triangle-api
  1. Install dependencies: pip install -r requirements.txt

  2. Install the browser required by Playwright: playwright install chromium

💻 Usage Example

from triangle_api.client import TriangleClient
import os

# Using environment variables is recommended for security
USER = "your_email@example.com"
PASSWORD = "your_secret_password"

# Instantiate the client
client = TriangleClient(username=USER, password=PASSWORD)

# Log in (opens browser on first run, uses cookies on next runs)
# headless=False lets you watch browser activity
data = client.login(headless=True)

print(f"Current Balance: $ {client.get_balance()}")
print(f"Available Credit: $ {data.get('availableCreditAmt')}")

🔒 Security and Persistence

To avoid raising suspicion from multiple logins, this wrapper uses Playwright's storage_state feature.

  • After the first successful login, an auth_state.json file is created.
  • On subsequent runs, the script tries to use these cookies to access the Dashboard directly.
  • Important: Never commit auth_state.json to GitHub (it should already be in .gitignore).

🛠️ Development

If you want to contribute by mapping new endpoints (such as transactions or offers), follow these steps:

  1. Log in to the CTFS website with Inspect mode (F12) open.
  2. Filter by XHR/Fetch calls.
  3. Look for endpoints such as retrieveTransactions or retrieveLoyalty.
  4. Map the response JSON in the TriangleClient class.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

triangle_api-0.1.4.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

triangle_api-0.1.4-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file triangle_api-0.1.4.tar.gz.

File metadata

  • Download URL: triangle_api-0.1.4.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for triangle_api-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b9680c953cfcfc6e52bac60b67ab2e12cdd820440056c058f0ce1e6363fde792
MD5 b05fe5d334449aabcfb4a3db5a012333
BLAKE2b-256 d2557aca208b836832f9a2d102f9acabe2b39bb6f4f3ad2e0678b8b9633f1db0

See more details on using hashes here.

File details

Details for the file triangle_api-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: triangle_api-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for triangle_api-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6c1da670de8fd4322c20a38e880eaa64368e20b98b38e3769cb1b2f38593587d
MD5 c91b147328eeb9317bfaad9fca1666ee
BLAKE2b-256 6bdce48c56fceb57b4fe59843e454da3d47f83e801877807925f2fc64c3839a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page