Authenticated API Documentation for Developers using the y.gy API

In order to call authenticate routes, you will first need to authenticate and obtain either an api-key or an access_token.

Developers are encouraged to utilize API keys to access authenticated routes, as they are straightforward to generate and manage. They facilitate quick implementation ensuring a smooth and uncomplicated experience for developers. Access tokens on the other hand involve a more complex authentication flow, including token acquisition and renewal.


API Key

Developers can generate and use API keys to access authenticated routes in this API by including the API Key in the request header as follows:

Request Using API Key

curl --request POST \
  --url https://api.y.gy/api/v1/user \
  --header 'api-key: 1968aa57ccd72d208dbac95d6679e6389ecfd60e59f31163506474a9c766fb6d'

Steps to Generate an API Key

  1. Navigate to "My Account" on the left side of your dashboard and scroll down to the API Keys Section. API Key Section in Dashboard
  2. Click on the "Add API Key", which will then prompt you to provide a desirable name to your key. API Key Name Modal
  3. Click on the "Create API Key" button to finally generate an API Key. The generated API key will now be available in the table records. API keys do not expire and must be manually deleted to be revoked. API Key Record

POST/api/v1/auth/create_tokens

Access Token

Create an access_token and a refresh_token. You can use the access_token to call other routes in this authenticate API.

Required Attributes

  • Name
    email
    Type
    string
    Description

    The email address for your y.gy account.

  • Name
    password
    Type
    string
    Description

    The password for your y.gy account.

Response

  • Name
    access_token
    Type
    string
    Description

    The access token. This lasts for three days before it needs to be refreshed via /api/v1/auth/refresh_access_token.

  • Name
    refresh_token
    Type
    string
    Description

    The refresh token. This lasts for thirty days before you need to either re-authenticate using this route, or obtain a new one via /api/v1/auth/refresh_access_token.

Request

POST
/api/v1/auth/create_tokens
curl --request POST \
  --url https://api.y.gy/api/v1/auth/create_tokens \
  --header 'Content-Type: application/json' \
  --data '{
  "email": "[email protected]",
  "password": "password1234"
}'

Authentication Response Example

{
  "access_token": "qwertyuiop1234567890",
  "refresh_token": "asdfghjkl098765321"
}

GET/api/v1/auth/refresh_access_token

Refresh Access Token

Obtain a new access_token and refresh_token pair using your existing refresh_token.

Required Headers

  • Name
    Authorization
    Type
    string
    Description

    Example: Bearer {my_refresh_token}

Response

  • Name
    access_token
    Type
    string
    Description

    A new access token. This lasts for three days before it needs to be refreshed via this route.

  • Name
    refresh_token
    Type
    string
    Description

    A new refresh token that is distinct from the one submitted in the request. This lasts for thirty days before you need to either re-authenticate using /api/v1/auth/create_tokens or refresh via this route.

Request

GET
/api/v1/auth/refresh_access_token
curl --request GET \
    --url https://api.y.gy/api/v1/auth/refresh_access_token \
    --header 'Authorization: Bearer zxcvbnm1234567890' \
    --header 'Content-Type: application/json'

Refresh Response Example

{
  "access_token": "qwertyuiop1234567890",
  "refresh_token": "asdfghjkl098765321"
}