How to integrate a portfolio analysis API.
A useful portfolio API does more than return a number. It resolves holdings, measures structure, exposes evidence quality, and gives your product enough detail to explain the result.
What a portfolio analysis API should do
The core input is simple: a list of securities and their values. The hard part begins after the request arrives. Tickers must be matched to the correct instruments, values normalised into weights, classifications and market evidence attached, and missing data surfaced. The result then has to separate portfolio structure from market opinion.
PORTIQA’s POST /evaluate endpoint returns the portfolio score and status, a breakdown by component, and the share of holdings that could be assessed. Give readers the evaluation date and display coverage next to the score.
1. Define the request contract
Send market values when you already calculate them. If you send amounts, the service must have a usable reference price. Use the canonical ticker format expected by the security master, keep cash separate from invested positions, and choose a risk level deliberately rather than accepting a default without telling the user.
curl -X POST https://portiqa.ai/evaluate \
-H "Authorization: Bearer $PORTIQA_KEY" \
-H "Portiqa-Response-Profile: public" \
-H "Content-Type: application/json" \
-d '{
"risk_level": "medium",
"cash_balance": 5000,
"positions": [
{"ticker": "AAPL", "market_value": 25000},
{"ticker": "MSFT", "market_value": 22000},
{"ticker": "NVDA", "market_value": 8000}
]
}'
Keep the bearer key on your server. Browser and mobile clients should call your backend, which validates the user and then calls PORTIQA. This prevents a public bundle from exposing a reusable credential.
2. Read the response in layers
- Identity: store
engine_versionwith the result. - Triage: use
scoreandstatusfor the initial summary. - Structure: inspect maximum position weight, effective positions, top sector, and its weight.
- Use
component_assessmentsto display the lower, middle or upper band for each component. Show a missing value as unavailable. - Check
analysis_coveragefor excluded holdings anddata_sourcesfor dates and availability. - Use the
score_driversexplanations to help the reader choose what to review.
3. Design for disagreement
Component disagreement is information. A portfolio can contain strong companies and still be concentrated in one sector. It can be diversified but poorly aligned with the selected risk level. Your UI should make those tensions visible with separate labels or bars. A single green score that hides a weak component creates false certainty.
4. Handle incomplete evidence
An unresolved ticker should produce a visible warning. Low factor coverage should reduce confidence in forward-looking context. A missing beta should not become zero, because zero is a real value with a different meaning. Use the response coverage and diagnostics to decide whether to show a component, mark it provisional, or ask the user to correct an identifier.
5. Make versioning explicit
Keep the evaluation time, inputs and engine_version with a user’s saved result. Label comparisons across different model versions. Existing integrations can send Portiqa-Response-Profile: public on an individual request to try the current response format.
6. Treat errors as product states
- 401: the key is missing, invalid, or revoked. Do not retry automatically.
- 400: the payload is invalid or has no evaluable positions. Show a field-level correction path.
- 429: the plan limit has been reached. Delay retries and show plan usage.
- 5xx: log a request timestamp and retry with bounded exponential backoff only when the operation is safe.
Build checklist
- Server-side secret storage and rotation
- Input validation before calling the API
- Explicit missing-ticker and low-coverage states
- Component-level explanations
- Engine-version persistence
- Timeout, retry, and rate-limit handling
- A visible informational-not-advice disclosure
Use the API reference for the field contract, the code examples for complete requests, and the methodology for calculation context.