Tips for working with our API
SUMMARY
- Start slowly and cautiously to get an API feel.
- We recommend Postman and RESTED as “feel your way” platforms.
- Springboard off the starter options to begin coding.
- Channel your API efforts through our Testing Console.
Baby steps pay big dividends when dealing with APIs. So, stay patient without overtaxing yourself. For example, start with:
- The RESTED browser extension for Google Chrome. What's that?
- The optimal solution tab management solution on Chrome.
- It allows you to rest your tabs without closing them.
- Keep your browsing session clutter-free while preserving your valuable websites.
- Access your rested tabs seamlessly as needed.
- Postman is an API platform that helps beginner and intermediate users build and use APIs. It does this by taking users through the API lifecycle step by step, consolidating collaboration for speedier results.
After learning to make successful API calls through the above options, attempt to write your own code. An extension can help you troubleshoot by separating client-code bugs from network issues.
- Always check HTTP and our internal API error codes (described in API docs). No HTTP response signifies something's faulty on the client side.
- Play with our Testing Console (launched from the API docs page). It provides several examples of what works and what doesn't. The console shows how the actual header would look.
- Observe correct formatting for JSON encoding and "urlencoded" encoding of "long_url." Also, don't forget to encode the "user:password" part of the header with base64 encoding. See the description of HTTP Basic authentication.
- "long_url" should be part of the POST payload. And not simply attached to the URL.
Use PHP exception handling to see actual error messages, like this:
try{
$surl = $client->shorten($url, $data);
}catch(\Exception $e){
print $e->getMessage();
}
Set Content-Type header for HTTP requests. So headers part would look like this:
headers: {
'Authorization': 'Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'Content-Type': 'application/json',
'Content-Length': message.length
}