February 4, 2025

Fetching Order Data Using Magento 2 REST API with Integration Method in Postman

February 4, 2025

Fetching Order Data Using Magento 2 REST API with Integration Method in Postman

Learn how to fetch Magento 2 order data using REST API and Postman. This step-by-step guide covers creating an API integration, obtaining access tokens, and testing API endpoints for efficient data retrieval.

Introduction

Magento 2 is a powerful e-commerce platform offering extensive API capabilities to integrate with external systems.

One essential aspect of working with Magento 2 is retrieving order data programmatically using the REST API. 

This guide will walk you through the steps to fetch order data using Postman with an integration method.

Step-by-Step Guide

Step 1: Create API Integration in Magento 2 Admin Panel

  1. Log in to your Magento 2 Admin Panel.
  2. Navigate to System > Integrations.

  3. Click Add New Integration.

  4. Provide a name for the integration (e.g., “Postman Order API Integration”).

  5. Enter your email address.

  6. Set up API permissions by clicking API, then selecting Sales > Orders (or selecting All for broader access).

  7. Click Save and Activate.

Magento 2 API Integration

Step 2: Get the Access Token

  1. After saving, click Activate on your integration.

  2. Confirm the activation by clicking Allow.

  3. Copy the below displayed token and keys: 

    1. Consumer Key
    2. Consumer Secret
    3. Access Token
    4. Access Token Secret
  4. You will use this in Postman for API authentication.

Step 3: Check store configuration

  1. Navigate to Store > Configuration > SERVICES > Magento Web API > JWT Authentication

  2. Check the Algorithm to sign/encrypt JWTs used for authentication
Magento 2 web api configuration

Step 4: Set Up Postman

  • Download and install Postman if you haven’t already from https://www.postman.com/.

  • Open Postman and create a new request.

  • Set the request type to GET.

  • Enter the API endpoint URL for order data:

    https://your-magento-site.com/rest/V1/orders/<order_id>
  • Go to the Authorization tab and setup the following things:

      1. Type : OAuth 1.0
      2. Add authorization data to : Request Headers
      3. Signature Method: HMAC-SHA256 

        => Should be the same in the magento store configuration – JWT Authentication

Postman header configuration

Step 5: Example JSON Response Structure

{
    {
      "entity_id": 1,
      "increment_id": "000000001",
      "status": "complete",
      "customer_firstname": "John",
      "customer_lastname": "Doe",
      "grand_total": 120.00
    },
    ...
}
Fetch order data

Conclusion

Retrieving order data from Magento 2 using the REST API in Postman is a straightforward process that empowers developers to access vital sales information programmatically. 

By following this guide, you can seamlessly integrate Magento 2 with external applications and automate order management tasks efficiently

Thank you for reading this article.

Share on:
Share on:
LinkedIn
Email
Facebook
Reddit
Twitter
WhatsApp
Skype
Print

Leave a Reply

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

Post comment

Recent posts

LogicRays Blogs

Read other latest blogs on technology, trending, Web & Mobile App, E-Commerce related etc.
We recommend
Featured posts

Table of Contents