For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Support Center
OverviewAPIResources
OverviewAPIResources
  • REST API Endpoints
    • GETGet Timestamp
    • GETO IDC User Info
      • POSTAccess Token Request
      • GETChallenge
      • POSTCountry Is Banned
      • POSTGet Product
      • GETJ WKS
      • GETMe
      • POSTO Auth Token
      • GETProducts
      • GETRenew Access Token
      • POSTSearch
      • GETWell Known Openid Configuration
Support Center
LogoLogo
REST API EndpointsAuthentication

Renew Access Token

GET
https://demo-d.tradovateapi.com/v1/auth/renewaccesstoken
GET
/v1/auth/renewaccesstoken
1const url = 'https://demo-d.tradovateapi.com/v1/auth/renewaccesstoken';
2const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
3
4try {
5 const response = await fetch(url, options);
6 const data = await response.json();
7 console.log(data);
8} catch (error) {
9 console.error(error);
10}
200Retrieved
1{
2 "errorText": "string",
3 "hibpHint": "EmailAndPasswordCompromised",
4 "accessToken": "string",
5 "expirationTime": "2024-01-15T09:30:00Z",
6 "passwordExpirationTime": "2024-01-15T09:30:00Z",
7 "userStatus": "Active",
8 "userId": 1,
9 "name": "string",
10 "hasLive": true,
11 "hasSimPlus": true
12}
### Request a renewal for an existing access token. Extends the current session without creating a new one. Using this function in a long-running application will ensure that you don't start a new session unless it is 100% necessary. This will prevent your application from kicking itself or dropping dependent services that share an Access Token. See the [`/auth/accessTokenRequest`](#operation/accessTokenRequest) operation for more details. ```js const { accessToken, expirationTime } = await fetch(TRADOVATELIVE+'/auth/accessTokenRequest', { method: 'GET', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(myCredentials) //see auth/accessTokenRequest for more info on the request body }).then(res => res.json()); sessionStorage.setItem(CURRENT_TOKEN_KEY, accessToken); sessionStorage.setItem(TOKEN_EXPIRATION_KEY, expirationTime); //in another file or function, keep the connection alive //check every 2 mins using useInterval (WARNING on a browser //this fn will be throttled. Consider using a WebWorker to maintain //a connection even when tabbed away.) setInterval(() => { const expiration = sessionStorage.getItem(TOKEN_EXPIRATION_KEY); const now = new Date().getTime(); const exp = new Date(expiration).getTime(); //if expiration is within 15 mins, renew if(exp - now < 15 * 60000) { const currentToken = sessionStorage.getItem(CURRENT_TOKEN_KEY); const renewal = await fetch(TRADOVATELIVE+'/auth/renewAccessToken', { method: 'GET', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': `Bearer ${currentToken}` //send existing non-expired token } }); //set new token and expiration sessionStorage.setItem(CURRENT_TOKEN_KEY, renewal.accessToken); sessionStorage.setItem(TOKEN_EXPIRATION_KEY, renewal.expirationTime); } }, 120 * 60000) ```
Was this page helpful?
Previous

Search

Next
Built with

Request a renewal for an existing access token.

Extends the current session without creating a new one. Using this function in a long-running application will ensure that you don’t start a new session unless it is 100% necessary. This will prevent your application from kicking itself or dropping dependent services that share an Access Token. See the /auth/accessTokenRequest operation for more details.

1const { accessToken, expirationTime } = await fetch(TRADOVATELIVE+'/auth/accessTokenRequest', {
2 method: 'GET',
3 headers: {
4 'Content-Type': 'application/json',
5 'Accept': 'application/json'
6 },
7 body: JSON.stringify(myCredentials) //see auth/accessTokenRequest for more info on the request body
8}).then(res => res.json());
9
10sessionStorage.setItem(CURRENT_TOKEN_KEY, accessToken);
11sessionStorage.setItem(TOKEN_EXPIRATION_KEY, expirationTime);
12
13//in another file or function, keep the connection alive
14//check every 2 mins using useInterval (WARNING on a browser
15//this fn will be throttled. Consider using a WebWorker to maintain
16//a connection even when tabbed away.)
17setInterval(() => {
18 const expiration = sessionStorage.getItem(TOKEN_EXPIRATION_KEY);
19 const now = new Date().getTime();
20 const exp = new Date(expiration).getTime();
21 //if expiration is within 15 mins, renew
22 if(exp - now < 15 * 60000) {
23 const currentToken = sessionStorage.getItem(CURRENT_TOKEN_KEY);
24 const renewal = await fetch(TRADOVATELIVE+'/auth/renewAccessToken', {
25 method: 'GET',
26 headers: {
27 'Content-Type': 'application/json',
28 'Accept': 'application/json',
29 'Authorization': `Bearer ${currentToken}` //send existing non-expired token
30 }
31 });
32 //set new token and expiration
33 sessionStorage.setItem(CURRENT_TOKEN_KEY, renewal.accessToken);
34 sessionStorage.setItem(TOKEN_EXPIRATION_KEY, renewal.expirationTime);
35 }
36}, 120 * 60000)

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Response

AccessTokenResponse
errorTextstring<=8192 characters

Non-empty if the request failed

hibpHintenum
EmailAndPasswordCompromised, PasswordCompromised
Allowed values:
accessTokenstring<=8192 characters
expirationTimedatetime
passwordExpirationTimedatetime
userStatusenum
Active, Closed, Initiated, TemporaryLocked, UnconfirmedEmail
Allowed values:
userIdlong
namestring<=64 characters
hasLiveboolean
hasSimPlusboolean