{"openapi":"3.1.0","info":{"title":"Linear Regression API","version":"1.0.0","description":"Linear least-squares regression as an API, computed locally and deterministically. The linear endpoint fits the best straight line y = a + b·x through a set of x/y data points by ordinary least squares, returning the slope b = Σ((x−x̄)(y−ȳ))/Σ(x−x̄)², the intercept a = ȳ − b·x̄, the ready-to-use equation, the Pearson correlation r and the coefficient of determination R² (the fraction of variance the line explains), and the residual and slope standard errors — the points (1,2),(2,4),(3,5),(4,4),(5,5) fit to y = 2.2 + 0.6·x with R² = 0.6, and a perfectly linear set returns R² = 1. Pass a predict_x and it also extrapolates the fitted value at that point. The predict endpoint evaluates y = intercept + slope·x for a known line. The x and y lists may be given as comma-separated values (x=1,2,3&y=2,4,5) or as JSON arrays in a POST body and must be equal length. Everything is computed locally and deterministically, so it is instant and private. Ideal for data-science, analytics, BI, forecasting, machine-learning-preprocessing and statistics-education app developers, trend-line and best-fit tools, and dashboards. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 2 endpoints. This is the regression line; for the Pearson correlation alone or descriptive statistics use a statistics API and for probability distributions a probability API.","contact":{"name":"PremiumApi","url":"https://www.oanor.com/by/premiumapi"}},"servers":[{"url":"https://api.oanor.com/regression-api","description":"oanor gateway"}],"tags":[{"name":"Regression"},{"name":"Meta"}],"components":{"securitySchemes":{"oanorKey":{"type":"apiKey","in":"header","name":"x-oanor-key","description":"Get your key at https://www.oanor.com/developer/keys"}}},"security":[{"oanorKey":[]}],"paths":{"/v1/linear":{"get":{"operationId":"get_v1_linear","tags":["Regression"],"summary":"Fit a regression line","description":"","parameters":[{"name":"x","in":"query","required":true,"description":"x values (comma-separated or array)","schema":{"type":"string"},"example":"1,2,3,4,5"},{"name":"y","in":"query","required":true,"description":"y values","schema":{"type":"string"},"example":"2,4,5,4,5"},{"name":"predict_x","in":"query","required":false,"description":"Optional x to predict","schema":{"type":"string"},"example":"6"}],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"r":0.77459667,"note":"Ordinary least-squares fit y = a + b·x. b = Σ((x−x̄)(y−ȳ))/Σ(x−x̄)², a = ȳ − b·x̄, R² is the fraction of variance explained.","slope":0.6,"inputs":{"n":5},"equation":"y = 2.2 + 0.6·x","intercept":2.2,"r_squared":0.6,"prediction":{"x":6,"y":5.8},"slope_std_error":0.28284271,"residual_std_error":0.89442719},"meta":{"timestamp":"2026-06-05T19:50:22.616Z","request_id":"8b93fb5f-c609-4e80-9684-6a614553fc76"},"status":"ok","message":"Linear regression","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}},"/v1/predict":{"get":{"operationId":"get_v1_predict","tags":["Regression"],"summary":"Predict from a line","description":"","parameters":[{"name":"slope","in":"query","required":true,"description":"Slope b","schema":{"type":"string"},"example":"0.6"},{"name":"intercept","in":"query","required":true,"description":"Intercept a","schema":{"type":"string"},"example":"2.2"},{"name":"x","in":"query","required":true,"description":"x value","schema":{"type":"string"},"example":"6"}],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"y":5.8,"note":"y = intercept + slope·x.","inputs":{"x":6,"slope":0.6,"intercept":2.2}},"meta":{"timestamp":"2026-06-05T19:50:22.725Z","request_id":"9c451dac-5225-4771-8f61-d358f3c85930"},"status":"ok","message":"Predict from line","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}},"/v1/meta":{"get":{"operationId":"get_v1_meta","tags":["Meta"],"summary":"Spec","description":"","parameters":[],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"notes":"Pass x and y as comma-separated lists (x=1,2,3&y=2,4,5) or JSON arrays in a POST body; they must be equal length. This is the regression line; for the Pearson correlation alone or descriptive stats use a statistics API.","service":"regression-api","endpoints":{"GET /v1/meta":"This document.","GET /v1/linear":"Fit a line through x/y data; returns slope, intercept, R² and (optionally) a prediction.","GET /v1/predict":"Predict y from a slope, intercept and x."},"description":"Linear least-squares regression: fit y = a + b·x, goodness of fit (R², standard errors), and prediction."},"meta":{"timestamp":"2026-06-05T19:50:22.832Z","request_id":"dbd468bb-5076-40d1-85e8-ed08b9d4ded0"},"status":"ok","message":"Meta","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}}},"x-oanor-pricing":[{"slug":"free","name":"Free","price_cents_month":0,"monthly_call_quota":5600,"rps_limit":2,"hard_limit":true},{"slug":"starter","name":"Starter","price_cents_month":570,"monthly_call_quota":56000,"rps_limit":6,"hard_limit":true},{"slug":"pro","name":"Pro","price_cents_month":1680,"monthly_call_quota":260000,"rps_limit":15,"hard_limit":true},{"slug":"mega","name":"Mega","price_cents_month":5300,"monthly_call_quota":1480000,"rps_limit":40,"hard_limit":true}],"x-oanor-marketplace-url":"https://www.oanor.com/api/regression-api"}