How to Use GoThis API

The GoThis API allows developers to shorten URLs and generate QR codes easily. This guide explains step by step for beginners how to use it and integrate it into a webpage or PHP script.

1. Generate Your API Key

Before you can use the API, you need an API key:

  1. Go to the GoThis homepage.
  2. Click on the "Generate API Key" button.
  3. Copy the generated key. Some pages allow you to automatically copy it to your clipboard.
  4. Keep this key safe. It will be needed in your code to authorize API requests.

2. Insert Your API Key in Your Code

In the examples below, replace YOUR_API_KEY with the key you generated. You can embed this code in an HTML file or a PHP file that outputs HTML.

3. API Endpoint

Use this endpoint to create short links:

POST https://gothis.link/?api=create

4. Request Structure

Headers

{
  "Content-Type": "application/json",
  "X-API-KEY": "YOUR_API_KEY"
}

Body

{
  "url": "https://example.com"
}

5. JavaScript Example

You can put this code in an HTML file. It will create a simple input box and button to shorten URLs.

<input type="text" id="url" placeholder="Enter the URL">
<button onclick="shorten()">Shorten</button>
<div id="result"></div>
<script>
function shorten(){
    const url = document.getElementById("url").value;
    const result = document.getElementById("result");
    if(!url){ result.innerHTML = "Enter a valid URL."; return; }
    result.innerHTML = "Processing...";
    fetch("https://gothis.link/?api=create", {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "X-API-KEY": "YOUR_API_KEY"  // Replace with the key you generated
        },
        body: JSON.stringify({ url: url })
    })
    .then(res => res.json())
    .then(data => {
        if(data.status === "success"){
            result.innerHTML = `Link: <a href='${data.short_url}' target='_blank'>${data.short_url}</a>`;
        } else {
            result.innerHTML = data.message;
        }
    })
    .catch(() => { result.innerHTML = "Error connecting to the API."; });
}
</script>

6. Using in PHP

If you want to include the API in a PHP page, you can use file_get_contents or cURL to send the POST request. Make sure to include your API key in the headers.

7. API Response

Success

{
  "status": "success",
  "short_url": "https://gothis.link/abc123"
}

Error

{
  "status": "error",
  "message": "Invalid URL"
}

8. Best Practices for Beginners

9. Support

If you have questions, contact support@gothis.org.

Effective Date: March 2026

HOME