Status Codes in API Testing

Successive Digital
3 min readOct 21, 2021

--

What is API?

API is an Application Programming Interface. It is an interface among software and within the software. To understand it we must go through a basic example as a user.

To get to know the API, follow the below steps:

  • Let us suppose a user is on ‘You Tube’ and observes the URL field on the screen. If a user enters any keyword for which the user wishes to view the video, say ‘Hello’ and click on the search button. The API of the videos related to’ hello ‘will get hit and users may observe the part after youtube.com/{This}.
  • If the user clicks any video from the page again, he/she will observe the API’s being hit at that moment. So, what is basically happening here?
  • The user is requesting a request from a provider and it is giving back the required response. Some of the times it happens that there is a working site say ‘www.ABC.com users search it and its API gets hit, it opens.

What are Status Codes?

  • Now if the company ‘ABC’ changes its name to ‘ABD’ and the user enters the same old URL which has not yet been redirected to the new company name it will show an error ‘Page not found‘.
  • How can users view it? For more understanding, right-click on the screen, Select ‘inspect’ and click on the ‘console’ tab. It will display a 404 page not found. These results tell us the responses are known as status codes.

Status Codes are the HTTP RESPONSE standard status code.

What are some common API status codes?

Status codes are divided into 5 categories:

  • 1xx — Informational messages
  • 2xx — Success messages
  • 3xx — Redirection messages
  • 4xx — Client error
  • 5xx — Server error

To understand categories of status codes in API’s testing, let us think of a way the user can easily catch. Consider a website, the screen user can view with the eyes is the user interface.

On this website, there is a page where the user can add its details to create the account.

Users enter fields such as ‘Name’,’ DOB’ (and other personal details) and click on ‘Submit’. Now considering the above scenario, we can understand status codes.

  • If during the submit request, which was received and understood. It requests the response consuming resource to wait for a final response. Just an information message while the request continues to proceed are Information messages.
  • When the request is requested by the client was received, understood and accepted. It states as Success messages.
  • If while entering the Name field which has a validation to accept only 15 alphabets, user-entered more than that and submit the request. On the UI, an error message is displayed. Now, this error was caused by the client. hence Client error.
  • If during the submit request, the server is unable to perform the request due to any situation, that is known as Server-side error.
  • For a Redirection message, the website name changes its name to ‘www.AND.com’ and you enter the same old URL which has not yet been redirected to the new website name, this is the case for redirection found.

Conclusion

APIs are a means by which two different programs can communicate within the software and among software’s and status codes are the responses that are the results of the requests sent.

--

--

Successive Digital

A next-gen digital transformation company that helps enterprises transform business through disruptive strategies & agile deployment of innovative solutions.