XtraVision GraphQL API Reference

GraphQL (https://graphql.org/) is a query language for APIs. GraphQL allows you to specify exactly what data you need from APIs.

How do I use XtraVision's GraphQL API?
To begin, connect to Xtra Team and obtain credentials, including an organization-id, an application-id, and the application's secret key. Once you have this, follow our instructions to create an authentication token, and you can start querying the API.

Contact

API Support

info@xtraininglive.com

API Endpoints
# Production:
https://saasapi.xtravision.ai/api/v1/graphql
Headers
# JWT token put here
Authorization: Bearer <YOUR_TOKEN_HERE>
Version

v1

AuthToken

Auth token for new user registration. (Use by Client Server and Xtra Server Communication)

  const payload = { 
    appId: appId, 
    orgId: orgId,
  };  
  const authToken = jwt.sign(payload, appSecret, { expiresIn: '2h' });

Auth token for retrieving users’ data and communicating between Client-App and Xtra Server

  const payload = { 
    appId: appId, 
    orgId: orgId,
    userId: userId, 
  };  
  // 2h => 2 hours, 30d => 30 days, 1y => 1 year, 
  const authToken = jwt.sign(payload, appSecret, { expiresIn: '2h' });

Queries

getUserAssessmentResults

Description

Fetch specific user's old stats.

Response

Returns a UserAssessmentResponse

Arguments
Name Description
userAssessmentFilter - userAssessmentFilter! Specific filter options like get specific session data, start/end date etc.
offset - Int Limit start from.
limit - Int Total records in result

Example

Query
query getUserAssessmentResults(
  $userAssessmentFilter: userAssessmentFilter!,
  $offset: Int,
  $limit: Int
) {
  getUserAssessmentResults(
    userAssessmentFilter: $userAssessmentFilter,
    offset: $offset,
    limit: $limit
  ) {
    total
    userAssessmentResult {
      ...UserAssessmentFragment
    }
  }
}
Variables
{
  "userAssessmentFilter": userAssessmentFilter,
  "offset": 987,
  "limit": 123
}
Response
{
  "data": {
    "getUserAssessmentResults": {
      "total": 123,
      "userAssessmentResult": [UserAssessment]
    }
  }
}

Mutations

createUserSession

Description

Create session and get session-id before starting assessment session.

Response

Returns a UserSession

Example

Query
mutation createUserSession {
  createUserSession {
    id
    userId
    createdAt
  }
}
Response
{
  "data": {
    "createUserSession": {
      "id": "xyz789",
      "userId": "abc123",
      "createdAt": "2007-12-03"
    }
  }
}

registerUser

Description

Using this API, you will register your user on Xtra Server. This is important and first API for user registration. If user's is already register, still you can call this API.

Response

Returns an IdentifyOrgAppUserResp

Arguments
Name Description
firstName - String User's First Name.
lastName - String User's Last Name.
email - String! User's email-id.

Example

Query
mutation registerUser(
  $firstName: String,
  $lastName: String,
  $email: String!
) {
  registerUser(
    firstName: $firstName,
    lastName: $lastName,
    email: $email
  ) {
    id
    firstName
    lastName
    email
    createdAt
  }
}
Variables
{
  "firstName": "abc123",
  "lastName": "abc123",
  "email": "abc123"
}
Response
{
  "data": {
    "registerUser": {
      "id": "xyz789",
      "firstName": "abc123",
      "lastName": "abc123",
      "email": "xyz789",
      "createdAt": "2007-12-03"
    }
  }
}

Types

Boolean

Description

The Boolean scalar type represents true or false.

Example
true

Date

Example
"2007-12-03"

DateTime

Description

Date custom scalar type

Example
"2007-12-03T10:15:30Z"

IdentifyOrgAppUserResp

Fields
Field Name Description
id - String! User id
firstName - String User's first name.
lastName - String User's last name.
email - String User's email.
createdAt - Date User's registration date
Example
{
  "id": "abc123",
  "firstName": "xyz789",
  "lastName": "abc123",
  "email": "xyz789",
  "createdAt": "2007-12-03"
}

Int

Description

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Example
987

JSON

Description

The JSON scalar type represents JSON values as specified by ECMA-404.

Example
{}

String

Description

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Example
"abc123"

UserAssessment

Fields
Field Name Description
id - String!
results - JSON Concluded response of user's assessment. It's last response from Websocket-communication.
savedDate - DateTime Date when assessment is stored
assessmentName - String Assessment name
Example
{
  "id": "abc123",
  "results": {},
  "savedDate": "2007-12-03T10:15:30Z",
  "assessmentName": "xyz789"
}

UserAssessmentResponse

Fields
Field Name Description
total - Int! Total count of result as per requested filter
userAssessmentResult - [UserAssessment]!
Example
{"total": 987, "userAssessmentResult": [UserAssessment]}

UserSession

Fields
Field Name Description
id - String! Session Id
userId - String! User-id
createdAt - Date! Session creation date
Example
{
  "id": "abc123",
  "userId": "abc123",
  "createdAt": "2007-12-03"
}

userAssessmentFilter

Fields
Input Field Description
startDate - DateTime! From Date
endDate - DateTime! To Date
Example
{
  "startDate": "2007-12-03T10:15:30Z",
  "endDate": "2007-12-03T10:15:30Z"
}