The Goto Website API
Welcome to the Go2.ws API documentation! Here you'll find everything you need to start creating sleek short URLs using our powerful API. Our service is designed to be intuitive and user-friendly, enabling you to integrate short URL functionality into your applications seamlessly.
API Endpoint
Create a Short URL
Endpoint:
POST https://api.go2.ws/short-urls
Free Use
Anyone can create short URLs with Go2.ws for free. However, free URLs will direct users to a gateway landing page before reaching the final destination. This is to prevent misuse and ensure security.
Features
- Gateway Landing Page: All free short URLs will redirect through a landing page.
- No API Key Required: Anyone can create short URLs without authentication.
- Limited Link Management: Free users cannot manage links in an account.
cURL Example
curl -X POST https://api.go2.ws/short-urls \
-H "Content-Type: application/json" \
-d '{"url": "www.example.com"}'
JavaScript Example
async function createShortUrl() {
const url = "https://api.go2.ws/short-urls";
const data = {
url: "www.example.com"
};
try {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.message || "Failed to create short URL");
}
const result = await response.json();
console.log("Short URL created:", result.shortUrl);
} catch (error) {
console.error("Error creating short URL:", error.message);
}
}
Python Example
import requests
def create_short_url():
url = "https://api.go2.ws/short-urls"
data = {
"url": "www.example.com"
}
try:
response = requests.post(url, json=data)
if response.status_code == 200:
result = response.json()
print("Short URL created:", result["shortUrl"])
else:
error_data = response.json()
print("Error creating short URL:", error_data.get("message", "Unknown error occurred"))
except requests.exceptions.RequestException as e:
print("Request failed:", e)
create_short_url()
Authorized Use
Users with a Go2.ws account can generate short URLs that bypass the gateway landing page and link directly to their desired destination. This requires an API key.
Features
- Direct Links: Short URLs created with an API key link directly to the target URL.
- API Key Required: Users must include their API key in requests.
- Full Link Management: Authorized users can manage their links and access detailed analytics in their accounts.
How to Obtain an API Key
- Sign Up: Create an account on Go2.ws.
- Generate Key: Navigate to the account settings and generate an API key.
- Secure Your Key: Keep your API key safe and never share it publicly.
cURL Example
curl -X POST https://api.go2.ws/short-urls \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{"url": "www.example.com"}'
JavaScript Example
async function createAuthorizedShortUrl() {
const url = "https://api.go2.ws/short-urls";
const data = {
url: "www.example.com"
};
try {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "your-api-key"
},
body: JSON.stringify(data)
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.message || "Failed to create short URL");
}
const result = await response.json();
console.log("Short URL created:", result.shortUrl);
} catch (error) {
console.error("Error creating short URL:", error.message);
}
}
Python Example
import requests
def create_authorized_short_url():
url = "https://api.go2.ws/short-urls"
api_key = "your-api-key"
"url": "www.example.com"
}
headers = {
"Content-Type": "application/json",
"X-API-Key": api_key
}
try:
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
result = response.json()
print("Short URL created:", result["shortUrl"])
else:
error_data = response.json()
print("Error creating short URL:", error_data.get("message", "Unknown error occurred"))
except requests.exceptions.RequestException as e:
print("Request failed:", e)
create_authorized_short_url()
Error Handling
All error responses from the Go2.ws API follow a consistent format with a descriptive message to help you identify and resolve issues quickly.
Here’s an example of an error response:
{
"message": "some error"
}
Common Errors
- 400 Bad Request: The request was invalid. Check the input data.
- 401 Unauthorized: Missing or invalid API key.
- 500 Internal Server Error: Something went wrong on our end. Try again later.
Manage Your Links
Every URL created with your API key will appear in your Go2.ws account, where you can manage and track your links. This gives you full control over your URLs and the ability to make adjustments as needed.
By using the Go2.ws API, you're tapping into a world of possibilities for creating sleek short URLs and beautiful QR codes that enhance your brand's digital presence. Let us know if you have any questions or need further assistance!