Get a user's portfolio
curl --request GET \
--url https://api.stockly.com/v1/users/{userId}/portfolio \
--header 'x-api-key: <api-key>'import requests
url = "https://api.stockly.com/v1/users/{userId}/portfolio"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.stockly.com/v1/users/{userId}/portfolio', 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.stockly.com/v1/users/{userId}/portfolio",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.stockly.com/v1/users/{userId}/portfolio"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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.stockly.com/v1/users/{userId}/portfolio")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stockly.com/v1/users/{userId}/portfolio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"value": 4.26,
"costBasis": 3.93,
"change": "+8.4%",
"holdings": [
{
"asset": "AAPL",
"quantity": 0.00427,
"value": 1.24,
"costBasis": 1.15,
"change": "+7.8%"
},
{
"asset": "NVDA",
"quantity": 0.0006,
"value": 0.87,
"costBasis": 0.8,
"change": "+8.8%"
},
{
"asset": "TSLA",
"quantity": 0.0072,
"value": 2.15,
"costBasis": 1.98,
"change": "+8.6%"
}
]
}{
"error": {
"code": "conflict",
"message": "idempotencyKey was already used with a different payload",
"details": {
"idempotencyKey": "order-1001-reward"
},
"requestId": "f0e1d2c3-4b5a-6789-0abc-def012345678"
}
}{
"error": {
"code": "conflict",
"message": "idempotencyKey was already used with a different payload",
"details": {
"idempotencyKey": "order-1001-reward"
},
"requestId": "f0e1d2c3-4b5a-6789-0abc-def012345678"
}
}Portfolio
Get a user's portfolio
The user’s live stock portfolio — current holdings valued at market prices. change is the return versus cost basis (the total USD you’ve given for the stock they hold). Holdings are aggregated by stock symbol. change is null when there’s no cost basis yet.
GET
/
v1
/
users
/
{userId}
/
portfolio
Get a user's portfolio
curl --request GET \
--url https://api.stockly.com/v1/users/{userId}/portfolio \
--header 'x-api-key: <api-key>'import requests
url = "https://api.stockly.com/v1/users/{userId}/portfolio"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.stockly.com/v1/users/{userId}/portfolio', 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.stockly.com/v1/users/{userId}/portfolio",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.stockly.com/v1/users/{userId}/portfolio"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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.stockly.com/v1/users/{userId}/portfolio")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stockly.com/v1/users/{userId}/portfolio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"value": 4.26,
"costBasis": 3.93,
"change": "+8.4%",
"holdings": [
{
"asset": "AAPL",
"quantity": 0.00427,
"value": 1.24,
"costBasis": 1.15,
"change": "+7.8%"
},
{
"asset": "NVDA",
"quantity": 0.0006,
"value": 0.87,
"costBasis": 0.8,
"change": "+8.8%"
},
{
"asset": "TSLA",
"quantity": 0.0072,
"value": 2.15,
"costBasis": 1.98,
"change": "+8.6%"
}
]
}{
"error": {
"code": "conflict",
"message": "idempotencyKey was already used with a different payload",
"details": {
"idempotencyKey": "order-1001-reward"
},
"requestId": "f0e1d2c3-4b5a-6789-0abc-def012345678"
}
}{
"error": {
"code": "conflict",
"message": "idempotencyKey was already used with a different payload",
"details": {
"idempotencyKey": "order-1001-reward"
},
"requestId": "f0e1d2c3-4b5a-6789-0abc-def012345678"
}
}Authorizations
Your Stockly API key. Identifies your app; you never pass an app id.
Path Parameters
⌘I