API Documentation

Welcome to the API documentation for QwkLink! This guide will walk you through the steps of authenticating and creating shortened URLs via our API.

Authentication

Our API uses Laravel Sanctum for authentication, which allows users to create API tokens for secure access. Follow the steps below to authenticate and start shortening URLs.

1. Creating an API Token

To use the API, you'll need an API token. Follow these steps to generate one:

2. Authenticating Requests

Once you have your API token, you can authenticate API requests by including the token in the Authorization header as a Bearer token.

Example

              
                  curl -X POST "https://qwkl.ink/api/shorten" \
                  -H "Authorization: Bearer YOUR_API_TOKEN" \
                  -H "Content-Type: application/json" \
                  -d '{
                      "original_url": "https://example.com"
                  }'
              
          

API Endpoint: Shorten URL

POST /api/shorten

This endpoint allows you to create a shortened URL from a given original URL.

Request

URL

POST https://qwkl.ink/api/shorten

Headers

Body Parameters

Parameter Type Description Required
original_url string The full URL to be shortened Yes

Example Request

              
                  curl -X POST "https://qwkl.ink/api/shorten" \
                  -H "Authorization: Bearer YOUR_API_TOKEN" \
                  -H "Content-Type: application/json" \
                  -d '{
                          "original_url": "https://example.com"
                      }'
              
          

Response

If the request is successful, the API will return the shortened URL.

Example Response (200 OK)

              
                  {
                      "shortened_url": "https://qwkl.ink/abc123"
                  }
              
          

Error Responses

Validation Error (400 Bad Request)

              
                  {
                      "message": "The given data was invalid.",
                      "errors": {
                          "original_url": [
                              "The original_url must be a valid URL."
                          ]
                      }
                  }
              
          

Unauthorized (401 Unauthorized)

              
                  {
                      "message": "Unauthenticated."
                  }
              
          

Rate Limiting

We may impose rate limits on API requests to prevent abuse. If you exceed the limit, you will receive a 429 status code.

Common Issues

Support

If you encounter any issues or have questions, please contact our support team at [email protected].