PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 13, 2022

[FIXED] What is the difference between an API and routes/endpoints?

 July 13, 2022     rest, routes, web-deployment     No comments   

Issue

I am new to the web world and I just read the difference between a route and an endpoint.

I know the definition of an API. But what is the difference between an API and routes (endpoints)?

It seems to me, when somebody says "build an API" or according to the YouTube tutorials that I have watched, they simply build a route using web frameworks like Express.js or Flask like '/hello', which returns "hello".

If that is an API, are an API and a route interchangeable? Like, if I have, for example, 3 routes: '/hello', '/users', '/users/<userId>'. Can I say I have 3 APIs?


Solution

In short to my mind:

  • API is about working with data using JSON or XML (as a rule) for input/output data (CRUD operations without any UI). API should follow some rules and structure. Ex.: GET /{entity_type}/{entity_id} means that this method will try to get entity with passed type and id
  • endpoint may be an API (they often are spelled together like "API endpoint") but at the same time it may be just an URL that leads somewhere without explicit manipulation with any data, for instance, trigger/webhook/gateway etc.
  • route is a path to some website/page/controller with a meaningful name to interact with the user. Route receives some user input (handles user actions) and represents some results in a convenient way (for example, render markup).


Answered By - Slava
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing