How to create custom module api get category list without access token in Spryker

Blog
Spread the love

To create a custom API for fetching a category list without requiring an access token in a Spryker-based project, you can follow these steps to create the necessary files and structure for your custom module. Below is a detailed guide for each part of the module and its purpose.

Step 1: Create Custom Category API Module

Your module will be located in the src/Pyz/Glue/CustomCategoryApi directory. The goal is to create a module that exposes an API endpoint for fetching the category list. Here’s how to structure it.

  1. CustomCategoryApiFactory.php
  2. This file is the factory class for your custom API module. It will be responsible for creating instances of the processors and plugins required for the API functionality.

  3. CustomCategoryApiDependencyProvider.php
  4. This file will define the dependencies that your API will rely on. It allows you to define things like services and other modules that your custom API depends on.

  5. CustomCategoryReader.php
  6. This file will handle the logic of fetching categories. It will interact with the business layer and return the response.

  7. CustomCategoryApiResourcePlugin.php
  8. This file is a plugin for the Glue application, responsible for formatting the response from the CustomCategoryReader.

  9. CustomCategoryResourceController.php
  10. This file will define the controller for the custom category API resource. It will use the plugin to handle incoming requests and return responses.

  11. custom_category.transfer.xml
  12. This file defines the structure of the transfer objects used for categories. It will include attributes like id, name, and others that you wish to include.

  13. GlueApplicationDependencyProvider.php
  14. This file is where you register the necessary resources for the Glue application to use. If your custom category API uses any specific services or dependencies, you can add them here.

    src/Pyz/Glue/GlueApplication/GlueApplicationDependencyProvider.php

Step 8: Generate Transfer Objects and Clear Cache

Run the following command to clear caches:

docker/sdk cli

console transfer:generate

console cache:empty-all

img

Step 9: Custom Category API

Api Endpoint:

http://glue.eu.spryker.local/custom-category-trees

Method

GET

Response

img

Step 10: No Access Token

Since you requested that the API should not require an access token, ensure that your controller or resource doesn’t enforce authentication middleware. If the default authentication mechanisms are enabled, you’ll need to override or disable them for this specific API endpoint.

Conclusion

Once you’ve created these files and registered them in your Spryker application, you can access the custom category list via an endpoint like /custom-category without requiring an access token. You may also customize the category response format and logic to meet the requirements of your application.

bluethinkinc_blog

bluethinkinc_blog

2025-03-28

0

Leave a Reply

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

Find More Blogs

Custom API to Fetch Customer Data by Customer ID in Spryker

Spread the love Introduction In this blog post, we will

Creating a Custom Module for a Custom Frontend Page in Spryker

Spread the love To create a custom module for a custom

How to create custom module api get category list without access token in Spryker

Spread the love To create a custom API for fetching a

Creating a Custom Glue API in Spryker

Spread the love Spryker’s Glue API is a powerful tool

Get AI Generated 360-Degree View of Account Summary in Dynamics 365 Sales

Spread the love Navigating the demanding landscape of sales

Enhancing Productivity with Dynamics 365: The Power of Session Restore

Spread the love Enhancing Productivity with Dynamics 365:

Salesforce Admin

Spread the love In our last blog, we discussed common

Unlocking AI with Spring Boot: Real-World Use Cases and Solutions

Spread the love Artificial Intelligence (AI) has moved from

Enhancing Performance with Reactive Java: A Beginner-Friendly Guide

Spread the love In today’s fast-paced software

Integrating Azure Function with Dynamics 365

Spread the love Signup on azure portal and make sure to

bluethinkinc Blogs