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>"
}
'import requests
url = "https://api.example.com/api/portfolio/holdings"
payload = {
"symbol": "<string>",
"holding_type": "<string>",
"shares": 123,
"average_cost": 123,
"notes": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
symbol: '<string>',
holding_type: '<string>',
shares: 123,
average_cost: 123,
notes: '<string>'
})
};
fetch('https://api.example.com/api/portfolio/holdings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/portfolio/holdings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'symbol' => '<string>',
'holding_type' => '<string>',
'shares' => 123,
'average_cost' => 123,
'notes' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/portfolio/holdings"
payload := strings.NewReader("{\n \"symbol\": \"<string>\",\n \"holding_type\": \"<string>\",\n \"shares\": 123,\n \"average_cost\": 123,\n \"notes\": \"<string>\"\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/portfolio/holdings")
.header("Content-Type", "application/json")
.body("{\n \"symbol\": \"<string>\",\n \"holding_type\": \"<string>\",\n \"shares\": 123,\n \"average_cost\": 123,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/portfolio/holdings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"symbol\": \"<string>\",\n \"holding_type\": \"<string>\",\n \"shares\": 123,\n \"average_cost\": 123,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyPortfolio
Portfolio Holdings
Get, add, update, or delete portfolio holdings
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>"
}
'import requests
url = "https://api.example.com/api/portfolio/holdings"
payload = {
"symbol": "<string>",
"holding_type": "<string>",
"shares": 123,
"average_cost": 123,
"notes": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
symbol: '<string>',
holding_type: '<string>',
shares: 123,
average_cost: 123,
notes: '<string>'
})
};
fetch('https://api.example.com/api/portfolio/holdings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/portfolio/holdings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'symbol' => '<string>',
'holding_type' => '<string>',
'shares' => 123,
'average_cost' => 123,
'notes' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/portfolio/holdings"
payload := strings.NewReader("{\n \"symbol\": \"<string>\",\n \"holding_type\": \"<string>\",\n \"shares\": 123,\n \"average_cost\": 123,\n \"notes\": \"<string>\"\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/portfolio/holdings")
.header("Content-Type", "application/json")
.body("{\n \"symbol\": \"<string>\",\n \"holding_type\": \"<string>\",\n \"shares\": 123,\n \"average_cost\": 123,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/portfolio/holdings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"symbol\": \"<string>\",\n \"holding_type\": \"<string>\",\n \"shares\": 123,\n \"average_cost\": 123,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyGet All Holdings
GET /api/portfolio/holdings
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
string
required
Stock ticker symbol (e.g., “AAPL”)
string
required
Type: “stock”, “etf”, or “mutual_fund”
number
required
Number of shares owned
number
required
Average cost per share
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"
}'
const response = await fetch('/api/portfolio/holdings', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
symbol: 'AAPL',
holding_type: 'stock',
shares: 100,
average_cost: 150.50,
notes: 'Tech holding'
})
});
const data = await response.json();
Update a Holding
PUT /api/portfolio/holdings/{id}
Path Parameters
integer
required
Holding ID to update
Request Body
number
Updated number of shares
number
Updated average cost per share
string
Updated notes
Delete a Holding
DELETE /api/portfolio/holdings/{id}
Path Parameters
integer
required
Holding ID to delete
Was this page helpful?
⌘I