DEV Community

RastaDeeDee
RastaDeeDee

Posted on • Edited on

API Difficulties

If you understand APIs then you understand the title of this blog post. First lets get into what an API is, API stands for application programming interface. API essentially talks to a program for you. You still need to know and understand the language to communicate with the API and the code so they can work hand and hand.

Lets break down the inter workings of a API. An API has three parts. First part is the User, the person who makes a request. Then there is the client,the computer that sends the request to the server. Last but not least the Server, the computer that responds to the request. With out all three parts working in junction the API or the code you have nothing.

Some will build a server because the server holds all the data need for the API. Once all the data that is need for the API is stored on the server most programmers will document the structure of the API and give anyone that wants to access the API. The how the what and the where to find or access and search the data on the server. This allows whoever is writing the code to search and query information that is needed.

While working with the API for my Harry Potter Character search I had the most difficult time understand the documentation for it and how to get it to work with my code. After a while I had to understand that it was a certain type of API and with that being said I have to let you know that there are millions of API’s and here are a few First API is the manipulating the DOM. Then are API’s that fetch data from the server. Next is the API’s that draw and manipulate graphics and Audio. Then there are API’s that work with device hardware and Client side storage as well just to name a few API’s.

After understanding the type of API I was working with, I then understand the simplistic aspect of the API I was using and how complex an API could get. I broke down what I want the the API, I was using to and found the Fetch concept to understand the fetch concept in my words after reading ( https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API ) The Fetch concept lets you use the request and response objects which means you can send a request and get a response but you can display this response or the request in single string HTML format or code the response into a display attribute. Heres and Example

Some will build a server because the server holds all the data need for the API. Once all the data that is need for the API is stored on the server most programmers will document the structure of the API and give anyone that wants to access the API. The how the what and the where to find or access and search the data on the server. This allows whoever is writing the code to search and query information that is needed.
While working with the API for my Harry Potter Character search I had the most difficult time understand the documentation for it and how to get it to work with my code. After a while I had to understand that it was a certain type of API and with that being said I have to let you know that there are millions of API’s and here are a few First API is the manipulating the DOM. Then are API’s that fetch data from the server. Next is the API’s that draw and manipulate graphics and Audio. Then there are API’s that work with device hardware and Client side storage as well just to name a few API’s.

After understanding the type of API I was working with, I then understand the simplistic aspect of the API I was using and how complex an API could get. I broke down what I want the the API, I was using to and found the Fetch concept to understand the fetch concept in my words after reading ( https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API ) The Fetch concept lets you use the request and response objects which means you can send a request and get a response but you can display this response or the request in single string HTML format or code the response into a display attribute. Heres and Example

fetch(url) .then(response => { // handle the response }) .catch(error => { // handle the error });

This is a simple fetch() and .then code snippet with the right API this will grab data and bring it back to your program or application. This was the best lesson I have learned in a long time and I had to share it with everyone I know.

Top comments (0)