URL Composition of REST API




A RESTful API needs to have one and exactly one entry point. The URL of the entry point needs to be communicated to API clients so that they can find the API.

The endpoint URL consists of a base URL, a resource path, and query parameters. The base URL is the internet host name for the REST API.

Each URL is called a request while the data sent back to you is called a response.


The endpoint (or route) is the url you request for. It follows this structure:

root-endpoint/?


The root-endpoint is the starting point of the API you’re requesting from. The root-endpoint of Github's API is https://api.github.com while the root-endpoint Twitter's API is https://api.twitter.com


The path determines the resource we are requesting for.

We can access paths just like we can link to parts of a website.


The endpoint to get a list of my repos on Github is this:

https://api.github.com/users/zellwk/repos


The final part of an endpoint is query parameters. Query parameters gives the option to modify request with key-value pairs. They always begin with a question mark (?). Each parameter pair is then separated with an ampersand (&) like this


https://www.amazon.com/s?k=windows+10+pro+laptop&ref=nb_sb_ss_sc_6_10


23 views0 comments

Recent Posts

See All