Beginner’s Guide to Web APIs

Beginner’s Guide to Web APIs

API – these days, it’s a term that startups throw around all the time. Whether it’s machine learning, photo editing, taking credit card payments, or creating Sniply links, there’s an API for that. But what does that actually mean? And why should you even care what it means?

The acronym API actually stands for “Application Programming Interface”, but it basically just means that it’s a way that an external programmer can interact with a piece of software without caring about the inside implementation details. This becomes a powerful tool because you can build on top of software to make something that performs some advanced functionality without writing major libraries of code.

It’s like when you drive your car: you can turn the steering wheel, step on the gas, or slam it into reverse but (unless you’re an automotive engineer) you don’t really know (or care) how it works on the inside. This means that you can ignore a lot of the complexity that happens inside the car and just enjoy the drive. In the same way, a software developer can use an API to get all of the functionality of a piece of software without having to look at all of the internal complexities of a problem.

APIs are particularly popular online, where programmers can access functionality over the internet. This is even more powerful than a simple API that runs on a single machine (like the API to a library of code) because all of a sudden, you can have thousands of computers doing calculations the instant that an API call gets made. For example, you can access the 76 million GB (ie. 76 PB) stored in Youtube’s database annually through their API. This is exactly what we did when we built covr.fm, one of our side projects – feel free to check it out if you like cover music ;-)

Online APIs work by providing a set of URLs to developers where they can send data to a website’s servers. The servers accept the data, perform any necessary calculations and data crunching, and provide a response to the developer. For example, using the Sniply API, you can automatically create customizable Sniply links without having to manually click through the Sniply creator over and over again. This is really handy in two cases: when you are creating a large number of links or when you are creating links on behalf of someone else. If you would like to create something similar to Sniply to share your message (or your users’ messages), using the Sniply API will allow you to access all of the power of Sniply in as little as a single line of code. In fact, I’ll even write the Pythonic code for you right here:

sniply_link = requests.post(
    "http://snip.ly/api/snips/",
    data = {
        "url":"snip.ly",
        "message":"Sniply is the best!"
    },
    headers = {
        "Authorization":"Bearer my_access_token"
    }
)

If you run that code with a valid access token, you will create a Sniply link that looks just like this one! Cool right? It’s really simple and I’d gladly walk you through the basic steps to integrate Sniply into your app or workflow.

To get access to the API, send me an email at nigel@snip.ly and I would be happy to get you started developing something awesome! If you would like to take a peak at our supporting documentation, you can look at the technical information at http://snip.ly/api/.


 

About the Author

Nigel Gutzmann, Tech Guy at Sniply

nigel-p

If you’re into soccer and indie music, then you’ll be Nigel’s best friend. Probably the healthiest in the team, Nigel actually moves around and stuff. 
Nigel has won more scholarships than most of us have earned in our life time. He’s pretty smart.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s