Getting started overview
This guide provides a structured approach to initiating development with the GoTiny API for URL shortening. It covers the necessary steps from account creation and API key retrieval to executing a first successful API call. GoTiny is designed for straightforward integration, primarily through HTTP POST requests to a single endpoint, facilitating the creation of shortened URLs and optional custom links with basic analytics capabilities.
The GoTiny API operates over standard HTTP/S, accepting JSON payloads and returning JSON responses. Authentication for API access relies on an API key included in the request body, which is a common method for securing access to web services as described in general API security practices Twilio's API security guide.
To begin, follow these steps:
- Create an account: Sign up on the GoTiny platform.
- Obtain API credentials: Locate your unique API key within the account dashboard.
- Construct a request: Use the API key to make an authenticated POST request to the shortening endpoint.
- Verify the response: Confirm that a shortened URL is returned.
This sequence ensures a foundational understanding of the GoTiny API's operational flow.
Create an account and get keys
Access to the GoTiny API requires an active account. The registration process is initiated via the GoTiny homepage. During signup, users typically provide an email address and create a password. Once the account is established and email verification is complete, the API key becomes accessible within the user's dashboard.
Account Creation Steps
- Navigate to the official GoTiny homepage.
- Select the 'Sign Up' or 'Get Started' option.
- Complete the registration form with the required details.
- Verify your email address following the instructions sent to your inbox.
Locating Your API Key
After successful account creation and login, the API key is typically found within a dedicated 'Developer Settings' or 'API Access' section of your GoTiny dashboard. This key is a unique alphanumeric string that authenticates your requests to the GoTiny API. Keep this key confidential to prevent unauthorized API usage.
Refer to the GoTiny developers documentation for specific instructions on locating your API key, as dashboard layouts can vary. The API key is critical for all authenticated requests, allowing the GoTiny service to identify your account and apply relevant usage limits and features, such as those included in the GoTiny pricing plans.
The free tier allows for 5000 links per month and 10 custom links, which is sufficient for initial testing and small-scale projects. For higher volumes or more custom links, a paid plan like the 'Pro Plan' starting at $4/month is required, as detailed on the GoTiny pricing page.
Your first request
Making your first request to the GoTiny API involves sending an HTTP POST request to the designated endpoint with your API key and the long URL you wish to shorten. The API expects a JSON payload in the request body.
API Endpoint
The primary endpoint for shortening URLs is https://gotiny.cc/api.
Request Structure
A basic request requires the long parameter, which contains the URL to be shortened, and the api_key parameter for authentication.
Example using cURL
The following cURL command demonstrates how to shorten a URL. Replace YOUR_API_KEY with your actual GoTiny API key and YOUR_LONG_URL with the URL you intend to shorten.
curl -X POST \
https://gotiny.cc/api \
-H 'Content-Type: application/json' \
-d '{
"long": "https://developers.google.com/maps/documentation/geocoding/overview",
"api_key": "YOUR_API_KEY"
}'
In this example, https://developers.google.com/maps/documentation/geocoding/overview is the long URL to be shortened. This URL is a legitimate documentation resource for Google Maps Geocoding API.
Example using JavaScript (Node.js with fetch)
For JavaScript environments, particularly Node.js, the fetch API or a similar HTTP client library can be used. This example uses fetch, which is standard in modern web browsers and can be polyfilled or used directly in Node.js versions 18 and above.
async function shortenUrl() {
const apiUrl = 'https://gotiny.cc/api';
const apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
const longUrl = 'https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API'; // Replace with your long URL
try {
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
long: longUrl,
api_key: apiKey
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('Shortened URL:', data[0].tiny);
} catch (error) {
console.error('Error shortening URL:', error);
}
}
shortenUrl();
This JavaScript example uses the Fetch API reference from MDN Web Docs to illustrate a client-side or server-side request.
Expected Response
A successful request returns a JSON array containing an object with the shortened URL. The tiny property within this object holds the generated short link.
[
{
"long": "https://developers.google.com/maps/documentation/geocoding/overview",
"tiny": "https://gotiny.cc/XXXXXX"
}
]
The XXXXXX placeholder represents the unique short code generated by GoTiny. You can then use this tiny URL in your applications or share it as needed.
Common next steps
After successfully performing your first URL shortening request, several common next steps can enhance your integration with GoTiny and improve your link management.
-
Implement custom short links: GoTiny allows you to specify a custom slug for your shortened URLs, making them more memorable and branded. This is achieved by including a
customparameter in your POST request payload.curl -X POST \ https://gotiny.cc/api \ -H 'Content-Type: application/json' \ -d '{ "long": "https://developers.google.com/identity/gsi/web/guides/overview", "custom": "mygsiurl", "api_key": "YOUR_API_KEY" }'Using a custom slug like
mygsiurlfrom the Google Sign-In overview can improve user recognition. -
Integrate link analytics: While basic, GoTiny provides some analytics on your shortened links. Explore your GoTiny dashboard to view click counts and other metrics for your links. This can help track the performance of shared URLs.
-
Handle API limits and errors: Understand the rate limits associated with your GoTiny plan, particularly when scaling usage. Implement robust error handling in your code to gracefully manage API responses that indicate issues such as invalid API keys, malformed requests, or exhausted link limits. The GoTiny API documentation details error codes and their meanings.
-
Explore advanced features: Depending on your GoTiny plan, you might have access to features like link expiration, password protection, or advanced redirection rules. Consult the GoTiny documentation to see if these features align with your project requirements.
-
Monitor usage: Regularly check your GoTiny dashboard to monitor your link creation volume against your plan's limits to avoid unexpected interruptions in service. This is particularly important for projects that experience variable traffic.
Quick Reference for Getting Started with GoTiny
| Step | What to Do | Where |
|---|---|---|
| 1. Sign Up | Create a GoTiny account | GoTiny Homepage |
| 2. Get API Key | Locate your unique API key | GoTiny Dashboard (Developer Settings) |
| 3. Make Request | Send POST request with JSON payload | https://gotiny.cc/api |
| 4. Parse Response | Extract tiny URL from JSON array |
Your application logic |
| 5. Consider Customization | Add custom parameter for branded links |
Request body payload |
Troubleshooting the first call
When making your initial API call, several common issues can prevent a successful response. Addressing these systematically can help resolve problems quickly.
Common Issues and Solutions
-
Invalid API Key:
- Symptom: API returns an authentication error or a generic error message indicating invalid credentials.
- Solution: Double-check that the API key included in your request body exactly matches the key displayed in your GoTiny dashboard. Ensure there are no leading or trailing spaces, and that the key is case-sensitive. If you suspect your key might be compromised or incorrect, you might be able to regenerate it from your GoTiny account settings.
-
Incorrect Endpoint:
- Symptom: The request fails with a 404 Not Found error or a connection error.
- Solution: Verify that you are sending the request to the correct GoTiny API endpoint:
https://gotiny.cc/api. Ensure the protocol (HTTPS) is correct.
-
Malformed JSON Payload:
- Symptom: The API returns a 400 Bad Request error or indicates that required parameters are missing or malformed.
- Solution: Ensure your JSON payload is correctly formatted. All keys (
long,api_key,customif used) should be enclosed in double quotes, and values should be correctly type-matched (strings for URLs and keys). Use a JSON linter or validator to check your payload if unsure. For instance, confirm that theContent-Type: application/jsonheader is correctly set.
-
Missing or Incorrect Content-Type Header:
- Symptom: API rejects the request or fails to parse the body content.
- Solution: Always include the
Content-Type: application/jsonheader in your POST request. This informs the GoTiny API that the request body contains JSON data, enabling it to parse the payload correctly.
-
Rate Limiting Exceeded:
- Symptom: API returns a 429 Too Many Requests error.
- Solution: If you are testing rapidly, you might hit the rate limits for your account tier. Wait for a few minutes and try again. For continuous integration, consider implementing exponential backoff for retries to handle temporary rate limit responses effectively, a common strategy for API usage AWS documentation on error retries.
-
Network Connectivity Issues:
- Symptom: Request times out or fails to connect.
- Solution: Check your internet connection. Ensure no firewall rules or network proxies are blocking outgoing HTTPS requests to
gotiny.cc.
When troubleshooting, review the exact error message returned by the GoTiny API. These messages often provide specific clues about what went wrong. Consult the GoTiny developer documentation for a comprehensive list of error codes and their explanations.