DEV Community

Cover image for How SDKs can save you hours when working with URL Shortening APIs
Den N
Den N

Posted on

How SDKs can save you hours when working with URL Shortening APIs

When developers integrate a URL shortening service, they often start with direct HTTP requests.

At first glance it seems simple enough:

import requests

response = requests.post(
    "https://example.com/api/links",
    headers={"X-Api-Key": "your_api_key"},
    json={
        "url": "https://example.com"
    }
)

print(response.json())
Enter fullscreen mode Exit fullscreen mode

However, as the integration grows, things become more complicated.

You need to:

  • Handle authentication
  • Process API errors
  • Validate responses
  • Work with pagination
  • Maintain DTOs and models
  • Keep up with API changes

This is where SDKs become valuable.

The Problem With Raw API Calls

Let's say you need to create links, manage groups, retrieve analytics and work with user profiles.

Without an SDK, every operation requires:

  • Building requests
  • Parsing JSON
  • Handling exceptions
  • Maintaining boilerplate code

This quickly becomes repetitive.

Using an SDK Instead

With a well-designed SDK, the same operation becomes much simpler.

For example:

from lix_sdk import Client

client = Client("your_api_key")

result = client.links().create(
    "https://example.com"
)

print(result.link.short_url)
Enter fullscreen mode Exit fullscreen mode

The SDK handles:

  • Authentication
  • HTTP requests
  • Error handling
  • DTO mapping
  • API response parsing

allowing developers to focus on business logic instead of infrastructure.

Benefits of Typed SDKs

Modern SDKs provide:

Better Developer Experience

Instead of working with raw JSON objects, you work with typed models.

profile = client.profile().me()

print(profile.user.email)
print(profile.plan.name)
Enter fullscreen mode Exit fullscreen mode

Consistent Error Handling

try:
    client.links().create("https://example.com")
except ValidationException:
    print("Validation error")
except UnauthorizedException:
    print("Invalid API key")
Enter fullscreen mode Exit fullscreen mode

Easier Maintenance

When the API evolves, the SDK can encapsulate changes without requiring modifications throughout the application.

Supporting Multiple Languages

One challenge for API providers is supporting developers across different ecosystems.

A PHP developer expects Composer packages.

A JavaScript developer expects npm packages.

Python developers prefer PyPI.

Go developers typically install packages directly from GitHub.

Providing official SDKs for multiple languages significantly lowers the adoption barrier.

Building Developer-Friendly APIs

While building Lix.li, I spent considerable time not only designing the API itself, but also creating SDKs for:

  • PHP
  • JavaScript
  • Python
  • Go

The goal was simple: make common tasks like creating and managing short links require as little code as possible.

You can explore the project here:

https://lix.li

Final Thoughts

A good API is important.

A good SDK is what makes developers actually want to use it.

If you're building an API product, investing in SDKs, documentation and developer experience can often have a bigger impact than adding another feature.

Top comments (0)