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.
Before you can use the API, you need an API key:
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.
Use this endpoint to create short links:
POST https://gothis.link/?api=create
{
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY"
}
{
"url": "https://example.com"
}
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>
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.
{
"status": "success",
"short_url": "https://gothis.link/abc123"
}
{
"status": "error",
"message": "Invalid URL"
}
If you have questions, contact support@gothis.org.
Effective Date: March 2026
HOME