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.
Terms of Service
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
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
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
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]}