Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJoshua Chapman
839 PointsIs an API the same as a Library?
As far as I am aware, a library is a set of predefined methods and classes that can be imported into a program to make life easier for the programmer.
I've recently come across API's and they appear to do the same thing.
Are 'library' and 'API' two words for the same thing, or are there differences?
1 Answer
Kevin Korte
28,149 PointsYou know, in a way, you're right, and I never thought about it that way - which lead me to this, lol:
Here is where I think the distinction lies. Libraries are things that give you the ability to do things. API's are a way to interact with data from another website. Both give you this programming interface to use, but only API's allow you to read, write, modify, or delete data that exists on another website.
Take for instance the twitter API. The twitter api gives us the ability to create, ready, delete, search for, filter and do all kinds of other stuff on your twitter account, and you can do all of that stuff without ever even going on the site itself.
Another example, we have Hubot in our Slack channel. Hubot is a library, I download it, and than host it on my own server, and it gives me a set of commands that Hubot will respond to in our slack channel.
One thing that Hubot does for us, is post to twitter. So anyone in our slack channel, from within slack can says hubot tweet I am the greatest
and than on twitter you'll see the tweet I am the greatest
. Hubot uses the twitter's api to post the message on Twitter.
Here is the Hubot account, we named him Jean: https://twitter.com/jeantweetsome
These posts are made from someone logging into twitter, the're made from various users in our slack channel.
Joshua Chapman
839 PointsJoshua Chapman
839 PointsThanks for your help, that makes a lot of sense.
However, I asked this question after discovering an API called bluecove which does not help you access information from a website or external source and instead provides methods and classes which can be used to help developers to make devices communicate via Bluetooth. Why is this being called an API rather than a Library?
Thanks again!!
EDIT: bluecove is in fact a Library! The website which first introduced it to me obviously made a mistake by referring to it as an API
Kevin Korte
28,149 PointsKevin Korte
28,149 PointsAhh gottcha, I googled it and came up with this: http://bluecove.org
Yep, sounds like source got it wrong. Just remember, API's are typically two servers talking to each other, libraries typically just bring in extra functionality.