homelessDevOps
homelessDevOps

Reputation: 20726

Most appropriate API for URL shortening service

I've just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites).

I'm thinking about the API for developers - at the moment you can send URLs with SOAP to the service, but I am not sure if this is a good solution. What is the best practice for such a service? REST? SOAP? Both?

Upvotes: 0

Views: 1199

Answers (5)

Sameeh Ahmed
Sameeh Ahmed

Reputation: 95

If you're considering the API design for your URL shortening service, using REST is definitely a good approach. It's widely preferred due to its ease of integration for developers.

Smler uses a RESTful API that’s lightweight and developer-friendly. Here's how a typical request might look:

curl -X POST https://api.smler.com/v1/shorten \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "long_url": "https://your-long-url.com",
  "custom_alias": "optional-custom-alias"
}'

REST allows you to work with standard HTTP methods and JSON payloads, making it easier for developers to adopt and integrate into their projects. While SOAP is still used in some specific cases, REST is generally more versatile and easier to debug.

Upvotes: 0

lI' Ghun
lI' Ghun

Reputation: 41

Also voting for REST as SOAP is such a big beast and overkill for this small API. Plus all popular url shortening services use REST. You even should consider being quite next to one of the more popular services as this might help developers to more easily add you service ;)

Upvotes: 1

Ben Werdmuller
Ben Werdmuller

Reputation: 185

Definitely REST - the overhead for SOAP is unnecessary unless you're building a particularly secure enterprise URL shortening service (which I think is probably an oxymoron). The bit.ly API is pretty good and worth checking out.

Upvotes: 2

blank
blank

Reputation: 18170

In this situation I'd say REST all the way, SOAP is overkill for this and gets you nothing other than an increase in network load. The api is simple enough for a textual description to suffice although you might want to look at WADL

Upvotes: 1

user187291
user187291

Reputation: 53940

i'd limit myself to rest, because the whole "API" is just two calls (return the long url for short and vice versa).

Upvotes: 5

Related Questions