Get User Data
curl --request GET \
--url https://api.example.com/api/user/dataimport requests
url = "https://api.example.com/api/user/data"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/user/data', 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/user/data",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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.example.com/api/user/data"
req, _ := http.NewRequest("GET", url, nil)
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/user/data")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/user/data")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"success": true,
"user": {
"_id": "user_2abc123def456",
"name": "John Doe",
"email": "john.doe@example.com",
"imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy...",
"enrolledCourses": [
"60d5ec49f1b2c72b8c8e4f1a",
"60d5ec49f1b2c72b8c8e4f1b"
]
}
}
User API
Get User Data
Retrieve authenticated user’s profile information and enrolled courses list
GET
/
api
/
user
/
data
Get User Data
curl --request GET \
--url https://api.example.com/api/user/dataimport requests
url = "https://api.example.com/api/user/data"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/user/data', 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/user/data",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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.example.com/api/user/data"
req, _ := http.NewRequest("GET", url, nil)
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/user/data")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/user/data")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"success": true,
"user": {
"_id": "user_2abc123def456",
"name": "John Doe",
"email": "john.doe@example.com",
"imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy...",
"enrolledCourses": [
"60d5ec49f1b2c72b8c8e4f1a",
"60d5ec49f1b2c72b8c8e4f1b"
]
}
}
Authentication
This endpoint requires authentication via Clerk. TheuserId is automatically extracted from the authentication token.
Response
boolean
required
Indicates whether the request was successful
object
string
Error message if success is false
Response Examples
{
"success": true,
"user": {
"_id": "user_2abc123def456",
"name": "John Doe",
"email": "john.doe@example.com",
"imageUrl": "https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy...",
"enrolledCourses": [
"60d5ec49f1b2c72b8c8e4f1a",
"60d5ec49f1b2c72b8c8e4f1b"
]
}
}
{
"success": false,
"message": "User Not Found"
}
{
"success": false,
"message": "An unexpected error occurred"
}
Error Codes
| Status Code | Description |
|---|---|
| 200 | Success or user not found (check success field) |
| 401 | Unauthorized - Invalid or missing authentication token |
| 500 | Internal server error |
⌘I