Every calculation in ColdCalc is a request you can make yourself: from Python, from JavaScript, from a shell, or from a cell in Excel. The API runs the same engine as the calculator, so the same inputs give the same numbers, with every intermediate value and equation number in the result. It comes with the Pro and Business plans.
Create a key on API keys and usage, put it in the COLDCALC_API_KEY environment variable, and run one of these. They check a 600S162-54 stud in compression, 10 ft long and braced at 4 ft about its weak axis and for torsion.
Python
"""Wall stud 600S162-54 in compression
Reproduces the calculation with the ColdCalc API. Units: kip, inch, ksi.
The value after each print is what the calculator got.
Docs: https://www.coldcalc.com/docs/api
"""
import os
import requests
API = "https://api.coldcalc.com/v1"
API_KEY = os.environ["COLDCALC_API_KEY"] # from your account's API page
def coldcalc(function, args):
"""Calls one API function, e.g. "design.compression", and returns its result."""
response = requests.post(
f"{API}/{function.replace('.', '/')}",
headers={"Authorization": f"Bearer {API_KEY}"},
json=args,
timeout=120,
)
if not response.ok:
raise SystemExit(f"{function}: {response.status_code} {response.json()['error']['message']}")
return response.json()
compression = coldcalc("design.compression", {
"section": {"shape": "lipped-channel", "D": 6, "B": 1.625, "d": 0.5, "t": 0.0566, "R": 0.0849},
"material": {"Fy": 50, "Fu": 65},
"method": "LRFD",
"approach": "DSM",
"KxLx": 120,
"KyLy": 48,
"KtLt": 48,
})
print("Available strength:", compression["availableStrength"], "kip") # 9.49614 kip
print("Nominal strength:", compression["nominal"], "kip") # 11.1719 kip
print("Governing limit state:", compression["governing"]["limitState"]) # Local buckling interacting with global buckling (DSM)
print("Specification section:", compression["governing"]["section"]) # E3.2
print("Local buckling, elastic:", compression["buckling"]["Pcrl"]["value"], "kip") # 7.80023 kip
print("Distortional buckling, elastic:", compression["buckling"]["Pcrd"]["value"], "kip") # 12.7134 kip
print("Global buckling, elastic:", compression["buckling"]["Pcre"]["value"], "kip") # 22.8091 kip
JavaScript
// Wall stud 600S162-54 in compression
//
// Reproduces the calculation with the ColdCalc API. Units: kip, inch, ksi.
// The value after each line is what the calculator got.
// Docs: https://www.coldcalc.com/docs/api
const API = "https://api.coldcalc.com/v1"
const API_KEY = process.env.COLDCALC_API_KEY // from your account's API page
/** Calls one API function, e.g. "design.compression", and returns its result. */
async function coldcalc(fn, args) {
const response = await fetch(`${API}/${fn.replace(".", "/")}`, {
method: "POST",
headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify(args),
})
const body = await response.json()
if (!response.ok) throw new Error(`${fn}: ${response.status} ${body.error.message}`)
return body
}
const compression = await coldcalc("design.compression", {
section: { shape: "lipped-channel", D: 6, B: 1.625, d: 0.5, t: 0.0566, R: 0.0849 },
material: { Fy: 50, Fu: 65 },
method: "LRFD",
approach: "DSM",
KxLx: 120,
KyLy: 48,
KtLt: 48,
})
console.log("Available strength:", compression.availableStrength, "kip") // 9.49614 kip
console.log("Nominal strength:", compression.nominal, "kip") // 11.1719 kip
console.log("Governing limit state:", compression.governing.limitState) // Local buckling interacting with global buckling (DSM)
console.log("Specification section:", compression.governing.section) // E3.2
console.log("Local buckling, elastic:", compression.buckling.Pcrl.value, "kip") // 7.80023 kip
console.log("Distortional buckling, elastic:", compression.buckling.Pcrd.value, "kip") // 12.7134 kip
console.log("Global buckling, elastic:", compression.buckling.Pcre.value, "kip") // 22.8091 kip
cURL
#!/bin/sh
# Wall stud 600S162-54 in compression
#
# Reproduces the calculation with the ColdCalc API. Units: kip, inch, ksi.
# Set COLDCALC_API_KEY to a key from your account's API page.
# Docs: https://www.coldcalc.com/docs/api
# design.compression
curl -sS "https://api.coldcalc.com/v1/design/compression" \
-H "Authorization: Bearer $COLDCALC_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<'JSON'
{
"section": {
"shape": "lipped-channel",
"D": 6,
"B": 1.625,
"d": 0.5,
"t": 0.0566,
"R": 0.0849
},
"material": {
"Fy": 50,
"Fu": 65
},
"method": "LRFD",
"approach": "DSM",
"KxLx": 120,
"KyLy": 48,
"KtLt": 48
}
JSON
The numbers above were computed by the engine when this page was built. You rarely need to write a request by hand: every result in the calculator has an Export button that writes this script, or an Excel workbook, for the design on screen.
Keys
Send your key in the Authorization header as Bearer cc_live_… (an X-Api-Key header works too). A key belongs to you or to one of your organizations and spends that account's credits. In an organization, admins create and revoke keys and every member can see the usage.
ColdCalc shows a key once, when you create it, and stores only a hash of it. Keep keys out of source control and out of files you share. If one leaks, revoke it on the keys page and it stops working at once. GET https://api.coldcalc.com/v1/me tells you which account a key belongs to and how many credits are left, without spending any.
Requests and responses
A calculation is a POST to https://api.coldcalc.com/v1/<group>/<function> with a JSON body of that function's arguments (spreadsheets use a GET form, under Excel). The response body is the result itself. Units are kip, inch and ksi throughout: moments in kip-in, bimoments in kip-in². Unknown fields are rejected, so a misspelled option fails loudly and never runs with a default you did not intend.
Response header
What it tells you
X-Request-Id
An id for this call. Quote it if you write to us about a result.
The requests allowed each minute, how many are left, and the seconds until the count resets.
Retry-After
On a 429, how many seconds to wait.
GET https://api.coldcalc.com/v1 lists every function and GET https://api.coldcalc.com/v1/openapi.json is an OpenAPI 3.1 description with the full schema of each argument, for generating a client. Neither needs a key. The API allows requests from any origin, but a key in a web page is visible to everyone who opens it, so call the API from a server, a script or Excel.
Calls and limits
Every call counts once against the month's allowance (one credit, in the X-Credits-Used and X-Credits-Remaining headers), whatever function it runs. Pro includes 1,000 calls a month; a Business organization's keys share 5,000. The allowance resets every month, also on annual billing, and extra calls are not sold. Work in the calculator itself is never counted.
A call that fails because of its input, or because of a fault on our side, is refunded. A key may make 120 requests a minute and run 4 at once. The usage page shows the last 30 days by day and by function, and the latest calls with their status and time.
Errors
An error is a JSON object with a stable code, a message written for a person, and for invalid requests a details list naming each field.
The body is not JSON, or does not match the function's arguments. details lists each problem with the path of the field.
No
401
missing_key, invalid_key, revoked_key
No key was sent, or the key is wrong or has been revoked.
No
402
no_credits
The account has used this month's API calls. The allowance resets at the start of the next month.
No
403
plan_required
The key's account is not on a plan that includes the API.
No
404
unknown_function
There is no function at this path.
No
405
method_not_allowed
Calculations are POST requests, or GET requests with their inputs in the query.
No
413
body_too_large
The request body is larger than 1 MB.
No
422
input_error
The engine rejected an input, for example dimensions that cannot form the section. The message says which.
Refunded
429
rate_limited, too_many_concurrent
Too many requests in a minute, or too many running at once. Wait for the seconds in Retry-After.
No
500
internal_error
Something failed on our side. Send us the X-Request-Id.
Refunded
Sections and materials
Most functions take a section and a material. A section is an object whose shape picks the form and whose other fields are its dimensions in inches, out to out, with R the inside bend radius. Corners are true circular arcs.
shape
Fields
lipped-channel
D, B, d, t, R, lipAngle?, B2?, d2?
unlipped-channel
D, B, t, R, B2?
zed
D, B, d, t, R, lipAngle?, B2?, d2?
hat
D, B, bf, t, R, d?
angle
A, B, t, R, dA?, dB?
rectangular-tube
D, B, t, R
round-tube
D, t
back-to-back-channel
D, B, d, t, R, lipAngle?, B2?, d2?, unlipped?
polyline
points[], t, R, closed?
cfs-elements
t, dimensions, elements[], closed?
A material is { Fy, Fu, E?, G?, nu? } in ksi, with E = 29,500 and G = 11,300 ksi unless you say otherwise. The OpenAPI description has every field of both.
Functions
23 functions, each the one the calculator itself calls. A ? marks an optional argument. Where an argument is an object, its fields are listed in braces; the OpenAPI description has their types.
Member and connection checks
One limit state or one interaction of AISI S100-24 from a section, a material and the forces or lengths you give.
POST /design/compressionCompression member strengthS100-24 E2, E3, E4 · 1 credit
Every result has an Export button beside Print, and an API tab that shows the exact requests behind the numbers on screen. From either you can take the design out in two forms.
Code in Python, JavaScript or cURL: a script that makes the same requests and prints the headline results, each followed by the value the calculator got, so a difference is obvious.
An Excel workbook: the inputs in a table you can edit and the results beside them, recalculated through the API by formulas that are already in the cells. Nothing to install. See Excel.
Neither file contains your key when you download it. The script reads it from the environment; the workbook has a cell you paste it into.
Excel
Excel can call the API by itself, with no add-in and no macros. Its built-in WEBSERVICE function fetches a URL and FILTERXML reads a value out of the answer. WEBSERVICE cannot send a JSON body or a header, so every function also answers a GET request with the key and the inputs in the URL.
Workbooks exported from the calculator
The quickest way to see it work is to export a design: Export, Excel workbook on any result. Open the file in Excel for Windows and paste your key into the cell on the first sheet. The Inputs sheet lists every field of the request, the Results sheet shows each headline number beside the value the calculator got, and changing an input recalculates the results through the API. Every formula is in its cell for you to read and copy into your own workbooks.
Writing the formulas yourself
Inputs are written as field paths, the same names as the JSON: section.D, material.Fy, KxLx. Items of a list take an index in brackets, as in members[0].section.D. Result paths work the same way. This is the compression check from the quick start:
Excel
B1 your API key
B2 =WEBSERVICE("https://api.coldcalc.com/v1/design/compression?key="&B1&"§ion.shape=lipped-channel§ion.D=6§ion.B=1.625§ion.d=0.5§ion.t=0.0566§ion.R=0.0849&material.Fy=50&material.Fu=65&method=LRFD&approach=DSM&KxLx=120&KyLy=48&KtLt=48&select=availableStrength,governing.limitState")
B3 =VALUE(FILTERXML(B2,"//v[@p='availableStrength']"))
B4 =FILTERXML(B2,"//v[@p='governing.limitState']")
B5 =IFERROR(FILTERXML(B2,"//error"),"OK")
What WEBSERVICE gets back
<result>
<v p="availableStrength" t="n">9.496144550551518</v>
<v p="governing.limitState" t="s">Local buckling interacting with global buckling (DSM)</v>
<credits><used>1</used><remaining>4999</remaining></credits>
</result>
In a real sheet, build the URL from cells: "§ion.D="&ENCODEURL(C4). Each value carries t, which is n for a number, s for text and b for true or false.
Query parameter
What it is
key
Your API key.
select
The result paths you want, separated by commas: availableStrength,governing.limitState. Required, unless a template supplies them.
any field
One input of the function by its path: section.D=6, material.Fy=50, members[0].end=144. A blank value leaves an optional field out.
dec
Send a comma (dec=,) from an Excel that writes decimals with a comma, and numbers come back the same way. Numbers in the inputs are read either way.
template
The name of a request saved by an exported workbook (t_…). Its inputs are used for every field the URL does not give.
What to know
Excel for Windows only.WEBSERVICE and FILTERXML exist in Excel 2013 and later for Windows, and the exported workbook also uses CONCAT and TEXTJOIN from Excel 2019 and Microsoft 365. Excel for Mac and Excel on the web do not have them; there the workbook still shows the design as it was exported.
Errors arrive as text.WEBSERVICE shows #VALUE! for anything but a successful answer, so the GET form always answers 200 and puts <error code="…"> with the reason inside. The codes are the ones in Errors.
URLs stop at 2,048 characters. A member analysis has more inputs than that. When you export one, ColdCalc saves the request and the workbook's URL names it with template and sends only the inputs you change.
The key is in the file. A key in a cell is saved with the workbook and travels in the URL. Make a key just for spreadsheets, clear the cell before you send the file outside your company, and revoke the key if it gets out.
Credits. Each change to an input is one call. Excel may keep an answer for a day, so reopening a workbook does not spend credits again. The exported workbook has a Calculate switch to pause calls while you edit several inputs.