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.3.tar.gz (6.8 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.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: triangle_api-0.1.3.tar.gz
  • Upload date:
  • Size: 6.8 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.3.tar.gz
Algorithm Hash digest
SHA256 ebc6cb0db7474c3ebc46f7d2dfe551c638fca63e51ae1348a3f6227cb7caefd9
MD5 67f72de2eeba4af5338fb661551501ad
BLAKE2b-256 e6c5557baae25396adf91ac65b276be36202c7fcb48471740eb583bedaf01be8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: triangle_api-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8f1d2743a3f8fa466ec04979f7cec94e67668865f466013a51d4ffb6eecf9bb2
MD5 426912ac02eef3d1358ec20083641ba2
BLAKE2b-256 d5133e3206f3028aa8fe960665a0647461f7f0144929d263c7bfd32b532a9e62

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