Skip to main content

cardapi

Official Python SDK for the CardAPI — the most comprehensive credit card data API for the US and Canada.

Install

pip install cardapi

Or install from source:

pip install /path/to/sdk-python

Quick Start

from cardapi import CardAPI

client = CardAPI(api_key="ck_live_xxxxx")

# List Canadian cards: {"data": [...], "total": ..., "limit": ..., "offset": ...}
cards = client.get_cards(country="CA")
print(cards["total"])

# Get a specific card
card = client.get_card("chase-sapphire-preferred-credit-card")["data"]

# Search, optionally within one country
results = client.search_cards("sapphire")
canadian = client.search_cards("visa", country="CA")

# Best cards for a spending category
best = client.get_best_cards("dining", country="US", limit=5)

# Compare cards side by side
compared = client.compare_cards(["chase-sapphire-preferred-credit-card", "american-express-gold-card"])

# Issuers
issuers = client.get_issuers(country="US")
issuer = client.get_issuer("chase")

# Spending categories and point valuations
categories = client.get_categories()
valuations = client.get_reward_valuations()

# Issuer application rules (e.g. Chase 5/24) and product change paths
rules = client.get_application_rules(issuer="chase")
paths = client.get_product_changes(issuer="chase")

# Starter plan and above
perks = client.get_card_perks("american-express-gold-card")
credits = client.get_card_credits("american-express-gold-card")

# Pro plan and above
history = client.get_card_history("citi-custom-cash-card")
transfers = client.get_card_transfers("american-express-gold-card")
partners = client.get_transfer_partners(currency="MR")
notable = client.get_notable_offers(country="US")

# Database stats and your API usage
stats = client.get_stats()
usage = client.get_usage()

A runnable version is in examples/quickstart.py:

CARDAPI_API_KEY=ck_live_... python examples/quickstart.py

Options

client = CardAPI(
    api_key="ck_live_xxxxx",
    base_url="http://localhost:3100",  # default: cardapi.client.DEFAULT_BASE_URL
    timeout=(5, 30),                   # (connect, read) seconds; the default
)

Error Handling

from cardapi import CardAPI, CardAPIError

client = CardAPI(api_key="ck_live_xxxxx")

try:
    card = client.get_card("nonexistent-card")
except CardAPIError as e:
    print(e.status_code)  # 404
    print(e.code)         # "not_found"
    print(str(e))         # "Card not found"
    print(e.retry_after)  # seconds, when the server sent Retry-After (e.g. on 429)

Every HTTP error response raises CardAPIError, including ones whose body isn't JSON (their code is "unknown"). Connection failures and timeouts raise the usual requests exceptions, such as requests.exceptions.Timeout.

API Reference

All methods return the API's JSON response as a Python dict.

Method Description
get_cards(country, issuer, limit, offset, network, card_type, max_annual_fee, no_annual_fee, credit_score, include_discontinued) List cards with optional filters, 25 per page unless you pass limit
get_card(slug) Get a single card by slug
search_cards(query, country, limit, offset) Search card and issuer names
compare_cards(slugs) Side-by-side comparison of 2-5 cards
get_best_cards(category, country, limit, max_annual_fee, no_annual_fee) Best cards for a spending category
get_card_history(slug) Tracked field changes for a card (Pro+)
get_card_perks(slug) Companion perks for a card (Starter+)
get_card_credits(slug) Statement credits for a card (Starter+)
get_card_transfers(slug) Transfer partners for a card (Pro+)
get_issuers(country) List issuers
get_issuer(slug) Get a single issuer
get_categories() List spending categories
get_transfer_partners(currency) Transfer partner directory (Pro+)
get_application_rules(issuer) Issuer application restrictions
get_reward_valuations() Cents-per-point valuations
get_product_changes(issuer) Product change paths
get_notable_offers(country) Recent notable offer changes (Pro+)
get_offer_history(card_slug) Offer change history for a card (Pro+)
create_webhook(url, events) / list_webhooks() / delete_webhook(id) Webhooks (Enterprise)
get_stats() Database stats
get_usage() Your account's usage (all keys) and limits

Get an API Key

Sign up at cardapi.dev/portal — free tier includes 100 requests/day.

Metadata

Release files for cardapi 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cardapi 0.3.0
File Size Uploaded
cardapi-0.3.0.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cardapi 0.3.0
File Interpreter ABI Platform
cardapi-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / cardapi-0.3.0.tar.gz

Download URL cardapi-0.3.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
36cd720a4ba94d603af784a93a85fb9f651214d0cf848dc460d41bbe709c1a1c
BLAKE2b-256 checksum
How to use checksums
ef64421c202ef08530090234398d19fd9adcefc780eaac36aa225dab12cf8792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / cardapi-0.3.0-py3-none-any.whl

Download URL cardapi-0.3.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0f8215039a9de277c286cf94e8059816b6826d329587ae370e13ff0b1cdeed7
BLAKE2b-256 checksum
How to use checksums
aaa2cc69237e1194d2a52aec079d26a43b6bb1627ac738f5dc1d23140b29fe79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.3.1

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page