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

Uploaded Python 3

File details

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

File metadata

  • Download URL: triangle_api-0.1.7.tar.gz
  • Upload date:
  • Size: 5.7 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.7.tar.gz
Algorithm Hash digest
SHA256 28e3cdba5281f514daf4339ae9b7175060447ce713e166efcb22494612eac955
MD5 49e3a356d648bc9048db57336ae3808f
BLAKE2b-256 9d135de7125323da5f4de311d9aa7a7f69a183c10ae1cb87c97bdc31523e4a6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: triangle_api-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9dda5f6f724c0cb7d677b0b097c40161fec5c93cad9d718ea443814712a988a4
MD5 10f9f0778b3f34061d543c55a4ea7f39
BLAKE2b-256 ae32d6748782a9ad71be20e26d5e6631b174fd3cb990b8917e0ea4db7dfc8eb2

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