Reading list Switch to dark mode

    How to Integrate Shopware 6 Admin API

    Updated 24 August 2023

    Introduction

    Shopware 6 offers a powerful Admin API integration. Manage your store efficiently, retrieve product data, handle orders, and enhance shopping experiences. Our step-by-step guide helps you integrate Shopware 6 Admin API effortlessly, unleashing your e-commerce potential.

    Prerequisites

    Before we dive into the integration process, ensure you have the following prerequisites ready:

    • A running instance of Shopware 6 with API access enabled.
    • Basic knowledge of RESTful APIs and HTTP methods.
    • API credentials (API key or OAuth tokens) to authenticate API requests.

    Enable API Access in Shopware 6

    To enable API access and integrate Shopware 6 Admin API, you must add the Integration in the backend. Please follow the steps below:

    1. Log in to Shopware Admin: Access your Shopware 6 backend by logging in with your admin credentials.
    2. Navigate to Settings: In the Shopware Admin, go to “Settings” from the left-hand sidebar.
    3. Choose System: Under the “Settings” section, select “System” from the dropdown menu.
    4. Open Integrations: In the “System” settings, click on “Integrations” to manage integration settings.
    5. Add Integration: On the Integrations page, click on the “Add integration” button to create a new integration.
    6. Fill in Integration Details: Provide a name for the integration and any additional information required for identification purposes. make sure you have enabled the administration role.
    How to Integrate Shopware 6 Admin API

    Understanding the Shopware 6 Admin API Endpoints

    The first step is to know about various Admin API endpoints offered by Shopware 6. These endpoints manage store aspects like products, customers, orders, and categories. To gain a complete understanding of how to integrate Shopware 6 Admin API, refer to the official documentation.

    Authentication & Security

    The Shopware 6 Admin API implements OAuth 2.0, a widely used standard for user authentication. In this blog, we’ll delve into the various grant types supported by the Admin API and guide you through the process of obtaining access tokens for secure API interactions.

    Searching for an experienced
    Shopware Company ?
    Find out More

    OAuth 2.0 Grant Types

    Shopware 6 Admin API supports two major grant types:

    1. Client Credentials Grant: This grant type involves obtaining an access token that remains valid for 10 minutes. To utilize it, you need to set up an integration and acquire an Access Key ID and Secret Access Key.
    2. Resource Owner Password Grant: This grant type requires a username and password for user-based authentication. It yields an access token with a 10-minute lifespan along with a refresh token for administrative actions.

    Obtaining Access Tokens for Shopware 6 API Integration

    Client Credentials Grant: To acquire an access token using this grant type:

    POST /api/oauth/token
    
    Content-Type: application/json
    
    {
      "grant_type": "client_credentials",
      "client_id": "<client-id>",
      "client_secret": "<client-secret>"
    }

    This request will generate an access token response. For a clearer understanding, please refer to the image below in Postman.

    How to Integrate Shopware 6 Admin API

    Resource Owner Password Grant: To obtain an access token using this grant type:

    POST /api/oauth/token
    
    Content-Type: application/json
    
    {
      "client_id": "administration",
      "grant_type": "password",
      "scopes": "write",
      "username": "<user-username>",
      "password": "<user-password>"
    }

    This request will generate an access token and refresh token response. For a clearer understanding, please refer to the image below in Postman.

    How to Integrate Shopware 6 Admin API

    Utilizing Refresh Tokens in Shopware 6 API Requests:
    Available after using the Resource Owner Password Grant, this allows the exchange of a refresh token for another short-lived (10 minutes) access token.

    POST /api/oauth/token
    
    Content-Type: application/json
    
    {
      "grant_type": "refresh_token",
      "client_id": "<client-id>",
      "refresh_token": "<refresh-token>"
    }

    Making API Requests

    Now that we have successfully obtained the access token, we’re all set to start making API requests to interact with your store’s data. The next step involves knowing the specific API endpoints to target. Let’s kick things off by focusing on the product entity endpoint.

    Retrieving Product Data

    One of the primary use cases for integrating the Shopware 6 Admin API is to fetch product lists. You can use the GET /api/product endpoint to retrieve a list of products or fetch individual product details using the GET /api/product/{productId} endpoint.

    To illustrate, we’ll delve into an example of retrieving a list of products using the access token we obtained earlier.

    HTTP Method: GET
    Endpoint: {{baseUrl}}/api/product
    
    Query Parameters:
    
    - `limit`: 10 (An integer defining the maximum resources to be returned in a page.)
    - `page`: 1 (The page number you want to retrieve.)
    
    Headers:
    
    - `Authorization`: Bearer {{accessToken}}

    “Enhance Your Understanding with Visuals: An Image View of the Process”

    How to Integrate Shopware 6 Admin API
    Image sent with query parameters
    How to Integrate Shopware 6 Admin API
    Image sent with authorization in the header.

    Conclusion

    Integrate Shopware 6 Admin API to elevate e-commerce management. This guide enables product retrieval, order handling, and more. Optimize store operations for seamless shopping. Get ready to unlock a new realm of efficiency and customer satisfaction. Happy integrating!

    If you need custom Shopware Development Services then feel free to reach us and also explore our exclusive range of Shopware Plugins.

    !!Have a Great Day Ahead!!

    . . .

    Leave a Comment

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


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home