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.8.tar.gz (5.3 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.8-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: triangle_api-0.1.8.tar.gz
  • Upload date:
  • Size: 5.3 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.8.tar.gz
Algorithm Hash digest
SHA256 6a94e0fcf88a3bf74e94d3d1c313f0bd5431535d9a552c75ae235388d2d0a435
MD5 7b1bed7e9468d328310cfe148fdebb56
BLAKE2b-256 7f1a19a0cdffea7193f56f5c600f8c7e98a6b401a7e3dd64de321141fbbc493e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: triangle_api-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9f3f1af4f7046d042ba5bdfa197824fdd1bcc3625cedc879f52c337dae231246
MD5 679a97b1b41926d76425ea21f6d6b1be
BLAKE2b-256 38897a8ca34265e6c7649845bc6d763e5f2a963c50cf62834ec42178f909aab5

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