LearnThatStack Ace your next interview
API Design · question
Question 11 of 110

What is the difference between URI, URL, and URN?

beginner
← All API Design questions
Re-explain

These are related but distinct concepts:

URI (Uniform Resource Identifier):

  • Generic term for any identifier that identifies a resource
  • Superset that includes both URLs and URNs
  • Example: mailto:john@example.com

URL (Uniform Resource Locator):

  • Type of URI that specifies location and method to access a resource
  • Includes protocol, domain, and path
  • Example: https://api.example.com/users/123

URN (Uniform Resource Name):

  • Type of URI that identifies a resource by name in a specific namespace
  • Location-independent identifier
  • Example: urn:isbn:0451450523

In REST APIs, we primarily work with URLs to locate and access resources over HTTP.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for API Design One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

  • Walk me through the parts of https://api.example.com:8443/users/123?active=true#bio. Name the scheme, host, port, path, query and fragment. A strong answer notes that the client never sends the fragment in the HTTP request.
  • When does a value belong in the URL path, and when in the query string? The path identifies the resource or its place in a hierarchy, like an ID. The query refines the result with filters, sort order or a page number.
  • Why can't a client fetch urn:isbn:0451450523 directly, and how would you make it fetchable? A URN has no host and no access method. Something has to resolve the name to a location, such as a catalog service that maps ISBNs to URLs.
  • Which characters must be percent-encoded in a URL, and what breaks if you forget? Reserved characters like ?, #, &, / and spaces. An unencoded & splits one query value into two parameters, and a # cuts off the rest as a fragment.

What you can say

  1. URI is the umbrella term for any string that identifies a resource, and URLs and URNs are two kinds of URI.
  2. A URL says where the resource lives and how to reach it, so it has a scheme like https, a domain and a path, for example https://api.example.com/users/123.
  3. A URN names a resource inside a namespace without saying where it is. urn:isbn:0451450523 names a book, and that name doesn't change no matter who holds a copy.
  4. So every URL and every URN is a URI, but not every URI is a URL. You can't send an HTTP request to an ISBN.
  5. In REST APIs we work with URLs almost all the time, because the client needs a location it can send HTTP requests to.
  6. In practice the line is blurry, since the URI spec lets one identifier be both a name and a locator. I say URI when I'm being precise and URL for anything I can fetch.

Weak answers to avoid

  • Says URI and URL are the same thing Every URL is a URI, but not every URI is a URL. Say that URI is the superset, then show a URN you can't fetch to prove it.
  • Says a URN tells you where the resource is A URN doesn't depend on location. urn:isbn names a book but has no host or protocol, so something else has to resolve it to a place.
  • Recites the acronyms with no examples Definitions alone blur together. One example per term, such as an https URL and a urn:isbn, makes the difference clear in seconds.
  • Claims URLs only use http or https ftp: and file: URLs also locate resources. The scheme names the access method, and HTTP is simply the one REST APIs use.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the API Design cheatsheet.

← Back to all API Design questions
Pro · $10/mo

90 of 110 API Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime