Skip to content

Concept :: API

Alex Tan Hong Pin edited this page Apr 25, 2018 · 1 revision

Creating an API is easy - each API should have the following lifecycle:

send request 
-> validate request 
-> call store 
-> get response 
-> validate response
  • Let's say we have a Job API, and we want to get a job by ID.
  • We send a request to the API with an ID.
  • The server will first have to validate the ID - if the ID is invalid or does not exist, we need to handle it.
  • If it exist, make a call to our store. store is basically our storage - it can be a remote storage, a mysql, a sqlserver, we don't need to know about it.
  • The store will then return a response, which would be the job we are looking for with the details.
  • It is best practice to validate the response to be returned - this is to ensure we only return what is needed, and not additional details (stuff like password, confidential details etc) can leak.
Clone this wiki locally