Quickstart
Get a key, look up a quote, then work out the probability of profit on a call spread.
- Get an API key
Sign up and add a card with Stripe. The Free plan (1,000 requests a month) is never charged. Confirm your email, then copy your key from your account page. Keys start with
opc_live_.Keep it out of your code: put it in an environment variable.
export OPC_API_KEY="opc_live_..." - Look up a quote
/quoteworks without a key, a few times a day, so you can try it right now.curl "https://www.optionsprofitcalculator.com/api/v1/quote?symbol=AAPL"import os import requests r = requests.get( "https://www.optionsprofitcalculator.com/api/v1/quote", params={"symbol": "AAPL"}, ) data = r.json() if not data["success"]: raise RuntimeError(data["error"]["message"]) print(data["data"])const params = new URLSearchParams({"symbol": "AAPL"}); const res = await fetch(`https://www.optionsprofitcalculator.com/api/v1/quote?${params}`); const { success, data, error } = await res.json(); if (!success) throw new Error(error.message); console.log(data);function callOpcApi() { const url = 'https://www.optionsprofitcalculator.com/api/v1/quote?symbol=AAPL'; const res = UrlFetchApp.fetch(url, { muteHttpExceptions: true, }); const json = JSON.parse(res.getContentText()); if (!json.success) throw new Error(json.error.message); return json.data; }{ "success": true, "data": { "symbol": "AAPL", "price": 344.87, "last": 344.87, "bid": 344.8, "ask": 345, "close": 342.56, "iv30": 30.077, "delayed": true } } - Calculate probability of profit
Send the legs of a position. Leave out prices and we use the current market.
curl -X POST https://www.optionsprofitcalculator.com/api/v1/pop \ -H "Authorization: Bearer $OPC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "symbol": "AAPL", "legs": [ {"type": "call", "action": "buy", "strike": 345, "expiry": "2026-12-18"}, {"type": "call", "action": "sell", "strike": 360, "expiry": "2026-12-18"} ] }'import os import requests r = requests.post( "https://www.optionsprofitcalculator.com/api/v1/pop", json={ "symbol": "AAPL", "legs": [ {"type": "call", "action": "buy", "strike": 345, "expiry": "2026-12-18"}, {"type": "call", "action": "sell", "strike": 360, "expiry": "2026-12-18"} ] }, headers={"Authorization": "Bearer " + os.environ["OPC_API_KEY"]}, ) data = r.json() if not data["success"]: raise RuntimeError(data["error"]["message"]) print(data["data"])const res = await fetch("https://www.optionsprofitcalculator.com/api/v1/pop", { method: "POST", headers: { Authorization: `Bearer ${process.env.OPC_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "symbol": "AAPL", "legs": [ {"type": "call", "action": "buy", "strike": 345, "expiry": "2026-12-18"}, {"type": "call", "action": "sell", "strike": 360, "expiry": "2026-12-18"} ] }), }); const { success, data, error } = await res.json(); if (!success) throw new Error(error.message); console.log(data);function callOpcApi() { const key = PropertiesService.getScriptProperties().getProperty('OPC_API_KEY'); const body = { "symbol": "AAPL", "legs": [ {"type": "call", "action": "buy", "strike": 345, "expiry": "2026-12-18"}, {"type": "call", "action": "sell", "strike": 360, "expiry": "2026-12-18"} ] }; const res = UrlFetchApp.fetch('https://www.optionsprofitcalculator.com/api/v1/pop', { method: 'post', contentType: 'application/json', headers: { Authorization: 'Bearer ' + key }, payload: JSON.stringify(body), muteHttpExceptions: true, }); const json = JSON.parse(res.getContentText()); if (!json.success) throw new Error(json.error.message); return json.data; }You get the probability of profit, breakevens, max profit and loss, and a
calculatorUrlthat opens the trade in the calculator. See the reference for every field.
Tip
Pick a language tab once and every code sample on the site follows it.