Users - Retrieve
  • 06 Feb 2024
  • 1 Minute to read
  • Dark
    Light

Users - Retrieve

  • Dark
    Light

Article summary

The retrieve Users endpoint will return a user object for the given user ID.

Field

Example

Definition

user_id string

"2ke2daisdflkj"

The unique ID of the user to be retrieved.

GET /1/users/{user_id}
Host: https://api.cogniac.io

Example: Retrieve a User

curl -X GET https://api.cogniac.io/1/users/2ke2daisdflkj \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz"\
-H "Content-Type: application/json"
import requests
import json
from pprint import pprint

url_prefix = 'https://api.cogniac.io'
api_version = "1"
user_id = '2ke2daisdflkj'
token = ''  # add your token here
headers = {'Authorization': f'Bearer {token}',
           'Content-Type': 'application/json'}

url = f'{url_prefix}/{api_version}/users/{user_id}'
res = requests.get(url, headers=headers)

if res.status_code == 200:
    response_data = json.loads(res.content)
    pprint(response_data)
else:
    print(f"Error: {res.status_code}, {res.text},{res.headers}")
{
  "user_id": "2ke2daisdflkj",
  "given_name":"Jack",
  "surname":"Petterson",
  "email":"test@cogniac.co",
  "created_at": 1474939966,
  "modified_at": 1506630313
}


Was this article helpful?