Skip to Content

User API

⚡ 5 min read

The transcodes.user object provides methods to retrieve user information.


Methods

get()

Retrieves user information from the server.

transcodes.user.get(params: { projectId?: string; userId?: string; email?: string; fields?: string; }): Promise<ApiResponse<User[]>>

Parameters:

ParameterTypeRequiredDescription
projectIdstringNoProject ID
userIdstringNoUser ID to fetch
emailstringNoEmail address to search
fieldsstringNoComma-separated fields to return

Returns: Promise<ApiResponse<User[]>>

Example - Get user by ID:

const result = await transcodes.user.get({ projectId: 'proj_xxx', userId: 'user_xxx', }); if (result.success) { const user = result.payload[0]; console.log('User:', user.name, user.email); } else { console.error('Failed to get user:', result.error); }

Example - Get user by email:

const result = await transcodes.user.get({ projectId: 'proj_xxx', email: 'user@example.com', }); if (result.success && result.payload.length > 0) { const user = result.payload[0]; console.log('Found user:', user.id); }

Example - Get specific fields:

const result = await transcodes.user.get({ projectId: 'proj_xxx', userId: 'user_xxx', fields: 'id,email,name', });

Type Definitions

User

interface User { id?: string; projectId?: string; name?: string; email?: string; roles?: string; metadata?: Record<string, string | number | boolean | null | undefined>; createdAt?: Date | string; updatedAt?: Date | string; }

ApiResponse<T>

interface ApiResponse<T> { success: boolean; payload: T; error?: string; message?: string; }

Usage Examples

Fetch User After Login

async function handleLogin() { const result = await transcodes.openAuthLoginModal({ projectId: 'proj_xxx', }); if (result.success) { const userId = result.payload[0].user.id; // Fetch full user details const userResult = await transcodes.user.get({ projectId: 'proj_xxx', userId: userId, }); if (userResult.success) { const user = userResult.payload[0]; console.log('Welcome,', user.name || user.email); } } }

Last updated on