How to Test Laravel API in Postman? (With Example)

Laravel, a dynamic PHP framework, is a premier solution for online business endeavours. Popular for its adaptability and seamless REST API integration, it’s a favoured choice across industries. 

The framework provides default web APIs for effortless integration with external services, and you can further create REST APIs to match your requirements. Testing is a critical phase which ensures both default and custom APIs perform flawlessly before launch. 

In this blog post, we’ll explore how to test Laravel APIs using Postman and explaining the process with practical examples. 

Stay tuned to master the art of Laravel API testing for robust deployments.

Test Laravel API – Getting Started with Postman

Postman is an API platform used to build, test, and document APIs. You can use web version or download and install the Postman application in your Windows/Mac from its official site.

Create your Postman account and login into the postman application.

In your dashboard ,create a new collection for test the Laravel APIs. Basically, it is a collection of saved APIs.

Step 1 :  Go to Collections,click + button and set your collection name. Like “Laravel API”.

Step 2 :  Click add a request to create and Call API under this collection.

Step 3 : You can make an API request by filling up various details.

In the below screenshot, you can find more information about each of the elements in the Postman request interface.

Let’s understand how to test the Laravel API in Postman through examples.


Steps to Test Laravel API

If we want to test login Laravel API.

You’ll need the login token.


You can get the Laravel Login token by passing the credentials via a GET request.

Let’s understand it through an example.

Example 1: Login

In Postman, create a new POST request and enter the following address:

In the Headers tab, set Content-Type = application/json as shown in the screenshot below.

Now, go to Body and select raw JSON as the body type.

Enter your admin credentials in the following format:


Click On Send button.

In the response body, you’ll get the login token which you can use for making any login-related API calls in Laravel.


Example 2: Update Product Quantity

Let’s say you want to change product attributes, for e.g., qty, using Laravel API. You can do this by making a POSTrequest and passing the ID of the product.

Here’s how to do it.

Create a new tab or request in Postman. Select POST as the request type, and enter the following in the address field:

In the Authorization tab, select Bearer Token, and enter the login token in the field.

In the Body select raw JSON as type, and enter the following:

Hit the Send button.

The response body will return the product details with the updated Quantity ! You’ve successfully tested Laravel API for Update functions.

Similarly, you can test custom Laravel APIs in Postman before deploying.Learn More About Laravel API integration.

Learn More About Laravel API integration.

Postman is an invaluable tool for crafting and testing Laravel APIs.

Follow the outlined steps to dive into seamless API integration. Don’t miss out on our comprehensive resource hub for Laravel APIs, continually updated with custom API insights.

Thank you for exploring the world of Laravel APIs with us!


Leave a Reply

Your email address will not be published. Required fields are marked *