Skip to main content
GET
/
api
/
portfolio
/
holdings
Portfolio Holdings
curl --request GET \
  --url https://api.example.com/api/portfolio/holdings \
  --header 'Content-Type: application/json' \
  --data '
{
  "symbol": "<string>",
  "holding_type": "<string>",
  "shares": 123,
  "average_cost": 123,
  "notes": "<string>"
}
'

Get All Holdings

GET /api/portfolio/holdings
Returns all holdings for the current user with current prices and calculated metrics.

Response Example

{
  "success": true,
  "holdings": [
    {
      "id": 1,
      "symbol": "AAPL",
      "holding_type": "stock",
      "shares": 100,
      "average_cost": 150.50,
      "current_price": 175.25,
      "total_cost": 15050.00,
      "current_value": 17525.00,
      "gain_loss": 2475.00,
      "return_percentage": 16.44,
      "last_updated": "2024-11-14T10:30:00Z"
    }
  ]
}

Add a Holding

POST /api/portfolio/holdings

Request Body

symbol
string
required
Stock ticker symbol (e.g., “AAPL”)
holding_type
string
required
Type: “stock”, “etf”, or “mutual_fund”
shares
number
required
Number of shares owned
average_cost
number
required
Average cost per share
notes
string
Optional notes about the holding

Example

curl -X POST https://your-domain.com/api/portfolio/holdings \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "AAPL",
    "holding_type": "stock",
    "shares": 100,
    "average_cost": 150.50,
    "notes": "Tech holding"
  }'

Update a Holding

PUT /api/portfolio/holdings/{id}

Path Parameters

id
integer
required
Holding ID to update

Request Body

shares
number
Updated number of shares
average_cost
number
Updated average cost per share
notes
string
Updated notes

Delete a Holding

DELETE /api/portfolio/holdings/{id}

Path Parameters

id
integer
required
Holding ID to delete