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

  1. Send a Login Request:

    • Make a POST request to /api/v1/authenticate with the user's email and password in the request body.

  2. Receive the JWT Token:

    • Upon successful authentication, the response will include a JWT token in the access_token field. Store this token securely; you will need it for all subsequent authenticated API requests.

  3. Include the JWT Token in Subsequent Requests:

    • For endpoints that require authentication, include the JWT token in the Authorization header 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_here

  • Content-Type: application/json

Response

Success (HTTP Status: 200):

Failure (HTTP Status: 401):

Usage Instructions

  1. Authenticate:

    • Use the /api/v1/authenticate endpoint to obtain a JWT token.

  2. Send a Request to Fetch Dwarfs Data:

    • Make a GET request to /api/v1/users/<user_id>/dwarfs with the JWT token included in the Authorization header.

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?