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.6.tar.gz (5.5 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.6-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: triangle_api-0.1.6.tar.gz
  • Upload date:
  • Size: 5.5 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.6.tar.gz
Algorithm Hash digest
SHA256 c97d55e98439f55bbabd27714a53a939494c21a5e5162c1eb8ed3b8845e23bed
MD5 0df8f4f3ead545726d43fa9c53f28d26
BLAKE2b-256 8fedf075c1387dd1540585572d64c5eb5faabffd6444438910c917248bd3d3ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: triangle_api-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.8 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 42f3a3bcea823e9b8c493694d2dc6f9e03ee317ab0528cd875f88a68b0187ec6
MD5 5c5b6d79e6502a061b939b8a376843b6
BLAKE2b-256 671e6d3ea34e1a9d43e1db970e331d3638d51947c252bb0bde8918b276ea9b11

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