A URL is a Universal Resource Locator, identifying the web address where a specific resource can be found on the world wide web, and how to access the resource. This resource can be an HTML web page, a CSS document, an image, etc.. They are used in REST APIs to address resources to developers using an API. You may have seen URIs, URLs, URNs, and domain names in networking discussions before, but how do we tell them apart?
A URL is an identifier with syntax that looks like this: `scheme:[//authority]path[?query][#fragment]`. Let's have a look at the parts of the URL.
In an API endpoint, the URL is relative to the base URL. For example, in the URL `https://exchange-rates.abstractapi.com/v1/historical`, the `/historical` endpoint refers to `https://exchange-rates.abstractapi.com/v1/historical`. Servers have a slightly different URL syntax, but the high-level idea is the same: it is an address where a resource can be found.
URLs are common resource locations in REST APIs, so naming them descriptively is considered a best practice. A developer using your REST API may not know what a resource does or what it contains, so naming it a string of letters and numbers is not helpful to them. Consider naming it descriptively, for example, the above endpoint is called `https://exchange-rates.abstractapi.com/v1/historical`. This endpoint allows us to access historical exchange rate data. We can also convert currency at `https://exchange-rates.abstractapi.com/v1/convert`, or view live currency exchange rates at `https://exchange-rates.abstractapi.com/v1/live`. This follows the URL syntax above, and gives new users a clear path to follow.
URLs display where a resource is available and how it is accessed. If you click one of the links in this article, it will carry you away to exactly where the resource is located. If you call the exchange rate API, you send your request to the URL and receive resources back. URLs are the address of a resource, found in the address bar of your web browser- not the IP address, which is a unique number attached to your hardware connected to a network.