How to Retrieve list of Product attribute groups Magento 2?

Product attribute groups used to manage multiple Product attributes to specific Groups in creating or update Products in the Magento admin panel.

Get a list of Product attribute groups programmatically in Magento 2 using Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface.

Magento stores the Product attribute group in the eav_attribute_group database table. When you access this table you can find out the information about the attribute group.

If you want to retrieve all the attribute groups, First create SearchCriteria Builder Object and assigned the object to the getList() method from the above interface.

namespace Jesadiya\ProductAttributeGroup\Model;

use Exception;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface;
use Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface;

class ProductAttributeGroup
     * @var ProductAttributeGroupRepositoryInterface
    private $productAttributeGroup;

     * @var SearchCriteriaBuilder
    private $searchCriteriaBuilder;

    public function __construct(
        ProductAttributeGroupRepositoryInterface $productAttributeGroup,
        SearchCriteriaBuilder $searchCriteriaBuilder
    ) {
        $this->productAttributeGroup = $productAttributeGroup;
        $this->searchCriteriaBuilder = $searchCriteriaBuilder;

     * Product Attribute Group
     * @return AttributeGroupSearchResultsInterface
    public function getAttributeGroupList()
        $searchCriteria = $this->searchCriteriaBuilder->create();
        try {
            $productAttributeGroup = $this->productAttributeGroup->getList($searchCriteria);
        } catch (Exception $exception) {
            throw new Exception($exception->getMessage());

        return $productAttributeGroup;

Call from the template or any PHP class,
echo $countryName = $this->getAttributeGroupList();


array (size=7)
  'attribute_group_id' => string '1' (length=1)
  'attribute_set_id' => string '1' (length=1)
  'attribute_group_name' => string 'General' (length=7)
  'sort_order' => string '1' (length=1)
  'default_id' => string '1' (length=1)
  'attribute_group_code' => string 'general' (length=7)
  'tab_group_code' => null
array (size=7)
  'attribute_group_id' => string '2' (length=1)