Pricing 
API Pricing

Try For Free Now

Dark

Light

AUTHENTICATION
JWT Request
You can request for a JWT from the Rozetta API for authentication. You can also generate a JWT, please refer to here.
Endpoint
Request details
POST
Header
Header
Description
Content-Type
application/json
Body
Key
Required
Description
accessKey
O
Specify your access key.
secretKey
O
Specify your secret key.
duration
The valid period of the token. If this field is not specified, the default valid period is 30 minutes. The unit is "second". Maximum is 9007199254740991. (However, long shelf life is not recommend.)
Response
Key
Description
status
For successful request, success will be specified for this field, otherwise failure will be specified.
data
Encoded Json Web Token

/api/v1/token
Use the this API to request for a JWT.

01

/

Request for a JWT.

JavaScript

/**
 * Demo program for requesting a JWT from the Rozetta API.
 */

const fetch = require('node-fetch');

const URL = 'https://translate.rozetta-api.io/api/v1/token';

const data = {
  accessKey: 'my-access-key',
  secretKey: 'my-secret-key',
  duration: 300
};

const getJWT = async () => {
  const response = await fetch(URL, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)
  });
  const responseJSON = await response.json();
  console.log(`JWT: ${responseJSON.data.encodedJWT}`);
};

getJWT();

02

/

Send API request with JWT.

JavaScript

/**
 * Demo prorgram of authentication by JWT.
 */

const fetch = require('node-fetch');

const token = 'my-jwt';

const sampleRequest = async () => {
  const url = 'https://translate.rozetta-api.io/api/v1/hello';
  const response = await fetch(url, {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
  const responseJSON = await response.json();
  console.log(responseJSON);
};

sampleRequest();
When sending a request, you should add the `Authorization` header in the request. The value is `Bearer <jwt-token>` where `<jwt-token>` is the JWT you generated above.
The sample above uses `/api/v1/hello` API as an example, other Rozetta APIs also accept authentication using JWT.
©️ 2019 Rozetta API  ・  Powered by Rozetta

Rozetta Corp.

^