Skip to main content

Python SDK for the Koko Finance credit card intelligence API

Project description

Koko Finance Python SDK

Python SDK for the Koko Finance credit card intelligence API.

Analyze credit card portfolios, compare cards side-by-side, get spending-based recommendations, and check whether a card is worth renewing — all with a few lines of Python.

Installation

pip install koko-finance

Quick Start

from koko_finance import KokoClient

client = KokoClient(api_key="koko_your_api_key")

# Analyze your credit card portfolio
analysis = client.analyze_portfolio(
    cards=[
        {"card_name": "Chase Sapphire Preferred", "annual_fee": 95},
        {"card_name": "American Express Gold Card", "annual_fee": 250},
        {"card_name": "Citi Double Cash", "annual_fee": 0},
    ],
    spending={"dining": 500, "travel": 300, "groceries": 600, "gas": 150},
    primary_goal="travel",
)
print(analysis)

API Reference

KokoClient(api_key, base_url, timeout)

Parameter Type Default Description
api_key str required Your Koko API key (format: koko_xxxxx)
base_url str https://kokofinance.net API base URL
timeout int 30 Request timeout in seconds

analyze_portfolio(cards, spending, primary_goal, credit_tier, issuer_preferences)

Analyze 1-10 credit cards for total value, coverage gaps, and optimization strategies.

analysis = client.analyze_portfolio(
    cards=[
        {"card_name": "Chase Sapphire Preferred", "annual_fee": 95},
        {"card_name": "American Express Gold Card", "annual_fee": 250},
    ],
    spending={"dining": 500, "travel": 300, "groceries": 400},
    primary_goal="travel",
)

compare_cards(cards, spending, primary_goal)

Compare 2-3 credit cards side-by-side with fees, rewards, and a winner recommendation.

comparison = client.compare_cards(
    cards=[
        {"card_name": "Chase Sapphire Preferred", "annual_fee": 95},
        {"card_name": "Capital One Venture X", "annual_fee": 395},
    ],
    spending={"dining": 400, "travel": 500},
    primary_goal="travel",
)

recommend_card(category, spending, primary_goal, credit_tier, portfolio_card_names)

Get the best card recommendations for a spending category.

# From the full market
recs = client.recommend_card(
    category="dining",
    spending={"dining": 600},
    credit_tier="excellent",
)

# From your existing portfolio
recs = client.recommend_card(
    category="dining",
    portfolio_card_names=["Chase Sapphire Preferred", "Citi Double Cash"],
)

check_renewal(card, spending, primary_goal)

Check if a card is worth keeping at annual fee renewal time.

renewal = client.check_renewal(
    card={"card_name": "Chase Sapphire Preferred", "annual_fee": 95},
    spending={"dining": 400, "travel": 300},
)
# renewal["verdict"] is "RENEW", "DOWNGRADE", or "CANCEL_AND_REPLACE"

health()

Check API health status (no authentication required).

status = client.health()

Error Handling

The SDK raises typed exceptions for API errors:

from koko_finance import KokoClient, RateLimitError, AuthenticationError

client = KokoClient(api_key="koko_your_api_key")

try:
    result = client.analyze_portfolio(cards=[...])
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds.")
Exception HTTP Status When
AuthenticationError 401 Invalid or missing API key
RateLimitError 429 Rate limit exceeded (60 req/min)
ValidationError 400, 422 Invalid request parameters
ServerError 500 API server error
KokoError other Base exception for all API errors

Spending Categories

The spending parameter accepts monthly dollar amounts for these categories:

Category Key Example
Groceries groceries 600
Dining dining 400
Travel travel 200
Gas gas 150
Streaming streaming 45
Shopping shopping 300
Other other 200

Links

License

MIT

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

koko_finance-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

koko_finance-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file koko_finance-0.1.0.tar.gz.

File metadata

  • Download URL: koko_finance-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for koko_finance-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a8a9c2a4c172c029b2a6bb5a5efd1873b2170593b5e81c550f7e65404b8f133e
MD5 884e8715d9076956df8b3424d9484f7a
BLAKE2b-256 55c96c0a99e7e80084c9c844d7ffabbdcbc4e8e067fdbb1cd4805ff6efcbbba6

See more details on using hashes here.

File details

Details for the file koko_finance-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: koko_finance-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for koko_finance-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce74d4b6f229a585341c18eba7a319d78741d0c498c931b892fd986b7b379cf5
MD5 4885a83efae99cee16deaed74e26cbec
BLAKE2b-256 4f65ca39510037d5372068487f68e0dd77f0c8389d77fe03c9b4f10f2ebc63ab

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