API Reference

UpgradeChat

class upgradechat.UpgradeChat(client_id: str, client_secret: str, session: Optional[aiohttp.client.ClientSession] = None)

A wrapper around the UpgradeChat v1 API.

__init__(client_id: str, client_secret: str, session: Optional[aiohttp.client.ClientSession] = None)
Parameters
  • client_id (str) – A valid client ID from your account.

  • client_secret (str) – A valid client secret from your account.

  • session (aiohttp.ClientSession, optional) – A session to use when making requests.

async get_access_token() str

Get an access token from their Oauth endpoint.

Returns

The aquired access token.

Return type

str

async get_orders(limit: int = 100, offset: int = 0, discord_id: Optional[int] = None, type: Optional[Union[upgradechat.models.UpgradeChatItemType, str]] = None) List[upgradechat.models.UpgradeChatOrder]

Get a list of order objects that adhere to the request parameters given.

Parameters
  • limit (int, optional) – The number of responses to get.

  • offset (int, optional) – The offset that you want to get.

  • discord_id (int, optional) – The ID of the Discord user that you want to look up.

  • type (Union[UpgradeChatItemType, str], optional) – The item type that you want to search for.

Returns

A list of purchases that the user has made.

Return type

List[UpgradeChatOrder]

Raises

UpgradeChatError – If the Upgrade.Chat API is down for any reason.

UpgradeChatOrder

class upgradechat.UpgradeChatOrder(uuid: str, purchased_at: datetime.datetime, user: upgradechat.models.UpgradeChatUser, subtotal: float, discount: float, total: float, type: upgradechat.models.UpgradeChatItemType, is_subscription: bool, cancelled_at: datetime.datetime, order_items: List[upgradechat.models.UpgradeChatOrderItem], deleted: Optional[datetime.datetime] = None, payment_processor: Optional[upgradechat.models.UpgradeChatPaymentProcessor] = None, payment_processor_record_id: Optional[str] = None, coupon_code: Optional[str] = None, coupon: Optional[upgradechat.models.UpgradeChatCoupon] = None, **kwargs)

An order object from the UpgradeChat API.

uuid

The UUID of the order

Type

str

purchased_at

A timestamp of when the order was placed.

Type

datetime.datetime

user

The user who placed the order.

Type

UpgradeChatUser

subtotal

A subtotal of the items at checkout.

Type

float

discount

The discount applied to the items.

Type

float

total

The total that the user paid.

Type

float

coupon_code

The coupon code that was used with the order, if any.

Type

string

type

The type of item that was ordered.

Type

UpgradeChatItemType

is_subscription

Whether or not the order was a subscription.

Type

bool

cancelled_at

The time when the order was cancelled

Type

datetime.datetime

order_items

A list of items that were included in the order.

Type

List[UpgradeChatOrderItem]

deleted

When the order was deleted.

Type

datetime.datetime, optional

payment_processor

The payment processor for the order.

Type

UpgradeChatPaymentProcessor, optional

payment_processor_record_id

The record ID that the payment processor used.

Type

str, optional

order_item_names

A list of item names that were ordered.

Type

List[str]

order_item_uuids

A list of item UUIDs that were ordered.

Type

List[str]

classmethod from_api(data)

Makes an instance of the object using a response from the API.

UpgradeChatUser

class upgradechat.UpgradeChatUser(discord_id: str, username: str)

A user object from the UpgradeChat API.

discord_id

The ID of the user.

Type

int

username

The uername of the user.

Type

str

UpgradeChatCouponType

UpgradeChatCouponDuration

UpgradeChatCoupon

UpgradeChatOrderItem

class upgradechat.UpgradeChatOrderItem(price: float, quantity: int, interval: upgradechat.models.UpgradeChatInterval, interval_count: int, free_trial_length: int, is_time_limited: bool, product: dict, discord_roles: List[dict], product_types: List[upgradechat.models.UpgradeChatProductType], payment_processor: upgradechat.models.UpgradeChatPaymentProcessor, payment_processor_record_id: str, product_uuid: Optional[str] = None, **kwargs)

An order item from the UpgradeChat API.

price

The price of the item.

Type

float

quantity

The amount of the item that was purchased.

Type

int

interval

The interval that the item is billed at.

Type

UpgradeChatInterval

interval_count

The number of times that the user will be billed.

Type

int

free_trial_length

The length of the free trial available with the item.

Type

int

is_time_limited

Whether or not the item is time-limited.

Type

bool

product

The product payload.

Type

dict

discord_roles

A list of Discord roles that are attached to this order item.

Type

List[dict]

product_types

A list of product types that this order item is.

Type

List[UpgradeChatProductType]

payment_processor

The payment processor used to purchase this item.

Type

UpgradeChatPaymentProcessor

payment_processor_record_id

The record ID that the payment processor used for this purchase.

Type

str

classmethod from_api(data)

Makes an instance of the object using a response from the API.

UpgradeChatInterval

class upgradechat.UpgradeChatInterval(value)

A subscription interval enum for Upgrade.Chat role subscriptions.

day
week
month
year

UpgradeChatProduct

class upgradechat.UpgradeChatProduct(uuid: str, checkout_uri: str, name: str, account_id: int, price: float, interval: upgradechat.models.UpgradeChatInterval, interval_count: int, free_trial_length: int, description: str, image_link: str, variable_price: bool, is_time_limited: bool, limited_inventory: bool, available_stock: int, shippable: bool, paymentless_trial: bool, product_types: List[upgradechat.models.UpgradeChatProductType], created: datetime.datetime, updated: datetime.datetime, deleted: Optional[datetime.datetime] = None, **kwargs)

A product from the UpgradeChat API.

uuid

The UUID of the product.

Type

str

checkout_uri

The checkout link.

Type

str

name

The name of the product.

Type

str

account_id

The ID of the account that the product is attached to.

Type

int

price

The price of the product.

Type

float

interval

How often the product is billed at.

Type

UpgradeChatInterval

interval_count

How many times the product will be billed for.

Type

int

free_trial_length

The number of days that the product is free.

Type

int

description

The description for the product.

Type

str

The URL of the image that the product uses.

Type

str

variable_price

Whether or not the price is variable.

Type

bool

is_time_limited

Whether or not the product is only available for a given amount of time.

Type

bool

limited_inventory

Whether or not the product has a limited inventory.

Type

bool

available_stock

How many of the product is still available.

Type

int

shippable

Whether or not the product is shippable.

Type

bool

paymentless_trial

Whether or not the trial period for this product is paymentless.

Type

bool

product_types

The types attached to this product.

Type

List[UpgradeChatProductType]

created

When this product was created.

Type

datetime.datetime

updated

When this product was updated.

Type

datetime.datetime

deleted

When this product was deleted.

Type

datetime.datetime, optional

classmethod from_api(data)

Makes an instance of the object using a response from the API.

UpgradeChatItemType

class upgradechat.UpgradeChatItemType(value)

An item type enum to allow you to query the Upgrade.Chat API.

UPGRADE
SHOP

UpgradeChatPaymentProcessor

class upgradechat.UpgradeChatPaymentProcessor(value)

A payment processor enum for Upgrade.Chat purchases.

PAYPAL
STRIPE

UpgradeChatProductType

class upgradechat.UpgradeChatProductType(value)

A product type enum for internal responses from the Upgrade.Chat API - this is not for querying with.

DISCORD_ROLE
SHOP_PRODUCT

UpgradeChatError

class upgradechat.UpgradeChatError