This week we talked a lot about APIs and to my surprise I thought APIs did much more than they actually do. Another peculiarity is that the only sort of programmatic process they support are the ones provided by HTTP calls, which again is also something I never had to deal with outside of cluelessly browsing the web. Nevertheless, they are very important and incredibly intricate in the form of versatility offered to a variety of operations. This is all very new to me, and this blog may show not only useful things I’ve learned but also crude misconceptions I may have formed by mistake, in the ladder case please disregard or give me a heads up and I’ll make corrections.
HTTP calls are GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE and PATCH my knowledge in the subject prevents me from saying that this is all of it or if there are more, use this site to refer to them https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods it has comprehensive descriptions. From the most recent assignment we had we utilized GET, POST, PUT, and DELETE. I would like to summarize their function for my own benefit.
- The GET request is used to retrieve data from the server, and it can only receive it may never change the data in the server
- The PUT method is used to send and change or create data in the server it is different from post because it is idempotent, (big word) please refer to the URL https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.2
- The POST method is similar to PUT but it is not idempotent, I think the simpler way to put it, oh sorry, post it is that POST creates a new instance every time it is used and PUT would replace it, this article shows good old English we can understand explanation about it https://reqbin.com/Article/HttpPost.
- The DELETE request will do as it says, it deletes the requested data from the server and unlike GET and HEAD, which we are not mentioning, it may change the state of the server. A cool thing I get from it is that some servers may reject a DELETE request which makes sense, deleting data should be a restricted action.
Something else I’ve learned from this assignment has to do with the YAML file which I looked up in order to know where it comes from and what it stands for. There are other things I wanted to talk about related to APIs, but too many to fit here, so I’ll end with YAML. YAML is a superset of JSON which is a java like way of representing and structuring data. YAML can do anything JSON does and some more. JSON is formatted using braces and brackets while YAML uses colon and two space indentation. In my opinion I think conventions like this such as in python makes for messy nesting which leads to code hard to visualize. YAML is like JSON, language-independent making it a good tool to use. https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/