V1 Authentication
Login the user to get the access_token
To interact with the Chrono Shift API, you need to authenticate using the provided /api/v1/authenticate endpoint. This endpoint allows you to log in using your email and password, and it returns a JWT token that you will use for authenticated requests to other endpoints.
Endpoint: /api/v1/authenticate
Method: POST
Description: Authenticates a user and returns a JWT token if the login is successful.
Request
URL: /api/v1/authenticate
Method: POST
Headers:
Content-Type:application/json
Body:
code{
"email": "[email protected]",
"password": "your_password"
}Response
Success (HTTP Status: 200):
Failure (HTTP Status: 400):
Failure (HTTP Status: 401):
Usage Instructions
Send a Login Request:
Make a POST request to
/api/v1/authenticatewith the user's email and password in the request body.
Receive the JWT Token:
Upon successful authentication, the response will include a JWT token in the
access_tokenfield. Store this token securely; you will need it for all subsequent authenticated API requests.
Include the JWT Token in Subsequent Requests:
For endpoints that require authentication, include the JWT token in the
Authorizationheader of your requests:
Example Code in JavaScript
Below is an example of how you might use the /api/v1/authenticate endpoint in JavaScript using the fetch API:
Fetch Dwarfs by User ID
The Chrono Dwarfs API also provides an endpoint to fetch dwarfs data by user ID. This endpoint requires authentication via the JWT token obtained from the /api/v1/authenticate endpoint.
Endpoint: /api/v1/users/<user_id>/dwarfs
Method: GET
Description: Fetches all dwarfs data associated with the specified user ID.
Request
URL: /api/v1/users/<user_id>/dwarfs
Method: GET
Headers:
Authorization:Bearer jwt_token_hereContent-Type:application/json
Response
Success (HTTP Status: 200):
Failure (HTTP Status: 401):
Usage Instructions
Authenticate:
Use the
/api/v1/authenticateendpoint to obtain a JWT token.
Send a Request to Fetch Dwarfs Data:
Make a GET request to
/api/v1/users/<user_id>/dwarfswith the JWT token included in theAuthorizationheader.
Example Code in JavaScript
Below is an example of how you might use the /api/v1/users/<user_id>/dwarfs endpoint in JavaScript using the fetch API:
Last updated
Was this helpful?