estimate

What something would cost a month before you make it: an app, its database and bucket, a repo, live editing.

Each charge comes back on its own line with the unit it's billed by, the unit price NoClick charges for it (what the service costs NoClick, nothing added), the quantity a month and the dollars, priced for your account's plan. Leave usage out and a modest default is assumed, and the line says so. Nothing is made or charged by asking.

est = noclick.estimate([
    {"kind": "project", "runtime": "edge", "usage": {"requests": 100_000}},
    {"kind": "database", "engine": "sqlite"},
    {"kind": "bucket"},
])
print(f"${est.monthly_usd:.2f} a month")
noclick.estimate(items, *, user=..., client=None) -> Estimate

What items would cost a month, before you make any of them. Each item is a dict naming its kind (project, durable_objects, database, bucket, repo or live_editing), its options (a project's runtime, region and framework, a database's engine), an optional name of your own, and the usage you expect a month by name (noclick.Estimate.kinds() lists each kind's). Usage you leave out is assumed from the kind's defaults, and so is an option you leave out whose default changes a price (an edge app's framework picks its build machine); every line a default decided says so (assumed). Prices are what each service costs NoClick, nothing added, priced for your account's plan. Needs the usage scope; nothing is made, held or charged.

Parameters
itemsSequence[Mapping[str, Any]]required
userAny

Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).

(defaults to the current user)
clientClient | None

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

(default None)
Returns
Estimate

An Estimate: monthly_usd, every charge in lines (its unit, unit_usd, quantity and usd), the items each with its own total, and your plan with the usage it includes a month. A kind, option or usage it can't price raises noclick.InvalidRequest naming the field.

Usage

A small site on the edge with a SQLite database and a bucket, at 100,000 requests a month:

est = noclick.estimate([
    {"kind": "project", "runtime": "edge", "usage": {"requests": 100_000}},
    {"kind": "database", "engine": "sqlite"},
    {"kind": "bucket"},
])
print(f"${est.monthly_usd:.2f} a month")
for line in est.lines:
    note = " (assumed)" if line.assumed else ""
    print(f"{line.kind} {line.charge}: {line.quantity:g} {line.unit} x ${line.unit_usd:g} = "
          f"${line.usd:.4f}{note}")

A Postgres database awake 200 hours a month, at its smallest size:

est = noclick.estimate([{"kind": "database", "engine": "postgres",
                         "usage": {"active_hours": 200, "compute_units": 0.25, "storage_gb": 2}}])

Estimate

class Estimate

What the items would cost a month: a usage-based estimate, priced for your account's plan.

Attributes
monthly_usdfloat
estimatedbool

Always true: these charges are by usage, so what's charged is what's used.

itemslist[EstimateItem]
lineslist[EstimateLine]

Every item's lines, in order.

plandict[str, Any] | None

Your account's plan, as GET /v1/status names it (None for a key acting for one of your users).

included_usd_per_monthfloat | None

The usage the plan includes a month, in dollars, which every charge to the account draws from (None without a plan). plan says whether a day's share of it is capped too.

rawdict[str, Any]

The response JSON exactly as the API sent it.

kindsstaticasync

noclick.Estimate.kinds(*, region=None, user=..., client=None) -> list[EstimateKind]

What noclick.estimate takes: each kind and variant, the usage it's priced by with the default assumed for any you leave out, and each charge's unit price. A container app's prices depend on its region (default: where a new app of yours would go). Needs the usage scope.

Parameters
regionstr | Nonedefault None
userAny

Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).

(defaults to the current user)
clientClient | None

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

(default None)
Returns
list[EstimateKind]

Each EstimateKind: its kind and options (a project's runtime, a database's engine), its usage fields with their defaults, and its prices.

Usage
for kind in noclick.Estimate.kinds():
    print(kind.kind, kind.options, [(u.name, u.default) for u in kind.usage])
    for price in kind.prices:
        print(f"  {price.charge}: ${price.unit_usd} per {price.unit}")

EstimateItem

class EstimateItem

One thing you asked about, priced: its options, the usage it was priced at, and its lines.

Attributes
kindstr
labelstr

For people, e.g. App on the edge.

namestr | None
optionsdict[str, Any]

What it was priced as: a project's runtime, region and framework, a database's engine.

usagedict[str, float]

Every usage it was priced at, by name: what you gave and the defaults for the rest.

assumedlist[str]

The usage names you left out, and the options you left out whose default changes a price.

monthly_usdfloat
lineslist[EstimateLine]
not_includedlist[str]

What its meters also charge that no usage here prices (an app's calls to AI, say), in words.

rawdict[str, Any]

The response JSON exactly as the API sent it.

EstimateLine

class EstimateLine

One charge of an estimate: what is billed, by which unit, at what price, and how much of it a month.

Attributes
kindstr

The kind of the item it's for: project, durable_objects, database, bucket, repo or live_editing.

itemstr | None

The name you gave the item, if any.

chargestr

Which charge it is, e.g. front_door, rows_written or storage.

descriptionstr

What it charges for, in words.

unitstr

The unit it's billed by, e.g. million requests or GB-month.

unit_usdfloat

The price of one unit, in US dollars.

quantityfloat

How many units a month.

usdfloat

What it would cost your account a month, in US dollars.

assumedbool

Whether a default decided it: its quantity came from usage you left out, or its price from an option you left out (an edge app's framework, a container's region).

rawdict[str, Any]

The response JSON exactly as the API sent it.

EstimateKind

class EstimateKind

Something an estimate takes: the usage it's priced by and the charges it makes.

Attributes
kindstr

What kind an item names; a project and a database come in variants (options).

labelstr
descriptionstr
optionsdict[str, Any]

What this variant is priced as: a project's runtime and region, a database's engine.

usagelist[EstimateUsageField]
priceslist[EstimatePrice]
not_includedlist[str]
rawdict[str, Any]

The response JSON exactly as the API sent it.

EstimateUsageField

class EstimateUsageField

A usage a kind takes: what it counts, and the default assumed when you leave it out.

Attributes
namestr
unitstr
descriptionstr
defaultfloat
mostfloat | None

The most it can be (a share is at most 1), else None.

EstimatePrice

class EstimatePrice

A charge a kind makes, at its unit price.

Attributes
chargestr
descriptionstr
unitstr
unit_usdfloat
usage_fieldslist[str]

The usage names its quantity comes from.