Reputation: 659
I did a lot of google searching and none of the explanations give a really basic easy to understand explanation so I'm hoping someone here can really help me understand this.
For this question I'm going to use a project I'm working on written in Javascript. Say I have some code that's going to go into an API and pull data on a toy. The toy has several properties such as price, number of parts, colors, stores sold in, manufacturing date, etc.
I make a request to get the data from the url where this data is stored, say "myapi.com/toy/search?query?=" + toy.
What is the API doing there? What is it storing? Is it storing the data on each individual toy? Or is it just a template of what data the toy SHOULD have and then the data for each toy is stored else where?
Thanks, I'm very new to this so if you see key flaws in my question itself I'd appreciate corrections and clarifications there as well.
Upvotes: 1
Views: 1636
Reputation: 4755
Any API has its own set of rules, and you're going to need to consult the specific documentation for the API you're going to use to find out exactly what data it exposes to you and in what formats.
You're misunderstanding what's meant when it's stated than an API is a set of rules. It's not to say that there's a set of rules which a system has to meet to be considered an API.
Rather, the developer of an API provides its users with documentation explaining what one should expect when interacting with their API. That documentation provides you with an understanding of the rules which you must follow to correctly use that particular API.
In short: I could write an API associated with any kind of data I want, and I could store that data wherever I want, and move it around in any format I want.
It's the creation of a set of rules that say "This is the result I promise to serve up in this specific format when you request it in this specific manner" that makes an API.
Upvotes: 3
Reputation: 15908
It depends on the context of the API. You are speaking about a REST API. A REST API uses the concept of resources. You should dig deeper into this particular API topic: RESTful APIs.
But APIs have different contexts. Maybe it helps to read about my journey where I experienced these different contexts as concrete examples of APIs. These concrete confrontations put together the bigger picture about APIs for me.
Upvotes: 0
Reputation:
In your case, your are using the API to connect the client application (your javascript code) to the server application (where the data resides).
The server exposes a simple interface (Application Programming Interface) for any client to request an action to be executed on its behalf.
Upvotes: 1