reading-notes

APIs

RESTful web API design

A primary advantage of REST over HTTP is that it uses open standards, and does not bind the implementation of the API or the client applications to any specific implementation.

Here are some of the main design principles of RESTful APIs using HTTP:

HTTP : link

{

"orderID":3,
"productID":2,
"quantity":4,
"orderValue":16.60,
"links": [
    {"rel":"product","href":"https://adventure-works.com/customers/3", "action":"GET" },
    {"rel":"product","href":"https://adventure-works.com/customers/3", "action":"PUT" }
] `}`

Define API operations in terms of HTTP methods

The HTTP protocol defines a number of methods that assign semantic meaning to a request. The common HTTP methods used by most RESTful web APIs are:

Filter and paginate data

Exposing a collection of resources through a single URI can lead to applications fetching large amounts of data when only a subset of the information is required.

Instead, the API can allow passing a filter in the query string of the URI, such as /orders?minCost=n. The web API is then responsible for parsing and handling the minCost parameter in the query string and returning the filtered results on the server side.

Framework vs library vs package vs module: The debate

Module

Is the smallest piece of software. A module is a set of methods or functions ready to be used somewhere else.

Package

Is a collection of modules. This may sound funny, but usually what a package does, is gather a number of modules holding in general the same functional purpose.

Library

Library is a collections of packages. It’s purpose is to offer a set of functionalities ready to use without worrying about the subsequent packages.

Framework

It’s a set of libraries. But this time, the framework does not just offer functionalities, but it also provides an architecture for the development work.