Requesting/Generating Access Token
/wp-json/jwt-auth/v1/token
To generate token, submit a POST request to this endpoint. With username
and password
as the parameters.
It will validates the user credentials, and returns success response including a token if the authentication is correct or returns an error response if the authentication is failed.
SAMPLE OF SUCCESS RESPONSE WHEN TRYING TO GENERATE TOKEN:
{
"success": true,
"statusCode": 200,
"code": "jwt_auth_valid_credential",
"message": "Credential is valid",
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvcG9pbnRzLmNvdXZlZS5jby5pZCIsImlhdCI6MTU4ODQ5OTE0OSwibmJmIjoxNTg4NDk5MTQ5LCJleHAiOjE1ODkxMDM5NDksImRhdGEiOnsidXNlciI6eyJpZCI6MX19fQ.w3pf5PslhviHohmiGF-JlPZV00XWE9c2MfvBK7Su9Fw",
"id": 1,
"email": "[email protected]",
"nicename": "contactjavas",
"firstName": "Bagus Javas",
"lastName": "Heruyanto",
"displayName": "contactjavas"
}
}
Once you get the token, you must store it somewhere in your application.
Then you should pass this token as Bearer Authentication header to every API call. The header format is:
Authorization: Bearer your-generated-token
and here’s an example:
"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvcG9pbnRzLmNvdXZlZS5jby5pZCIsImlhdCI6MTU4ODQ5OTE0OSwibmJmIjoxNTg4NDk5MTQ5LCJleHAiOjE1ODkxMDM5NDksImRhdGEiOnsidXNlciI6eyJpZCI6MX19fQ.w3pf5PslhviHohmiGF-JlPZV00XWE9c2MfvBK7Su9Fw";
If the token is valid, the API call flow will continue.
Requesting Latest Rates
/wp-json/lirarate/v2/rates?currency=LBP
To get latest rates, submit a GET request to this endpoint. You will get a response of the latest Rates in the below format.
{
"buy": [
[1543665600000,1515],
[1543752000000,1515],
.
.
.
]
"sell": [
[1577102400000,2000],
[1577188800000,2020],
.
.
.
]
}
The “buy” and “sell” arrays are a list of all buy and sell rates with their time stamp. They include the latest rates at the last element of the array.