> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XStoreQueryProductsAsync

> XStoreQueryProductsAsync

# XStoreQueryProductsAsync

Returns listing information for the specified products that are associated with the current game, regardless of whether the products are available for purchase within the game.

## Syntax

```cpp theme={null}
HRESULT XStoreQueryProductsAsync(  
         const XStoreContextHandle storeContextHandle,  
         XStoreProductKind productKinds,  
         const char** storeIds,  
         size_t storeIdsCount,  
         const char** actionFilters,  
         size_t actionFiltersCount,  
         XAsyncBlock* async  
)  
```

### Parameters

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

The store context handle for the user returned by [XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext).

*productKinds*   \_In\_\
Type: [XStoreProductKind](/reference/system/xstore/enums/xstoreproductkind)

The types of products to return.

*storeIds*   \_In\_z\_count\_(storeIdsCount)\
Type: char\*\*

The store identifiers for the products to retrieve.

*storeIdsCount*   \_In\_\
Type: size\_t

The number of products in the list of **storeIds**.
This number shouldn't exceed 100.

*actionFilters*   \_In\_opt\_z\_count\_(actionFiltersCount)\
Type: char\*\*

Restricts the results by some action stored in the product document.
By default, this API returns all products, even if they aren't purchasable, but you can use action filters to restrict results.
For example, use "Purchase" if you only want purchasable products, or "License" if you only want licensable products.
Other action filters include "Fulfill", "Browse", "Curate", "Details", and "Redeem".

*actionFiltersCount*   \_In\_\
Type: size\_t

The number of filters in **actionFilters**.

*async*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

An [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) defining the asynchronous work being done.
Use the [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) to check the call's status and get the results.
For more information, see [XAsyncBlock](/reference/system/xasync/structs/xasyncblock).

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

Call [XStoreQueryProductsResult](/reference/system/xstore/functions/xstorequeryproductsresult) to retrieve the listing information and the execution result of this function.

This API fails if you provide more than 100 storeIDs in the request.
If you're working with a large catalog, limit each query to fewer than 100 products.

To get details for all products that players can purchase within the current game, use [XStoreQueryAssociatedProductsAsync](/reference/system/xstore/functions/xstorequeryassociatedproductsasync) instead.

The following code snippet shows an example of retrieving listing information for the specified products that are associated with the current game.

```cpp theme={null}

void ProcessResults(XStoreProductQueryHandle queryHandle)
{
    HRESULT hr = XStoreEnumerateProductsQuery(
        queryHandle,
        nullptr,
        EnumerateProductsQueryCallback);

    if (FAILED(hr))
    {
        printf("Failed enumerate the product query handle: 0x%x\r\n", hr);
        XStoreCloseProductsQueryHandle(queryHandle);
        return;
    }

    XStoreCloseProductsQueryHandle(queryHandle);
}

void CALLBACK QueryProductsCallback(XAsyncBlock* asyncBlock)
{
    XStoreProductQueryHandle queryHandle = nullptr;

    HRESULT hr = XStoreQueryProductsResult(
        asyncBlock,
        &queryHandle);

    if (FAILED(hr))
    {
        printf("Failed retrieve the product query handle: 0x%x\r\n", hr);
        return;
    }

     ProcessResults(queryHandle);
}

void QueryProducts(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;

    asyncBlock->callback = QueryProductsCallback;

    XStoreProductKind allProductKinds =
        XStoreProductKind::Consumable |
        XStoreProductKind::Durable |
        XStoreProductKind::Game |
        XStoreProductKind::Pass |
        XStoreProductKind::UnmanagedConsumable;

    const char* storeIds[] =
    {
        "9YYYYYYYYYYY",
        "9ZZZZZZZZZZZ",
    };

    // This is only needed if you want to restrict to items that are currently purchasable.
    // If you want items that have been sold in the past,
    // but are no longer available for purchase, then
    // pass in nullptr or an empty array for the actionFilters.
    const char* actionFilters[] =
    {
        "Purchase"
    };

    HRESULT hr = XStoreQueryProductsAsync(
        storeContextHandle,
        allProductKinds,
        storeIds,
        ARRAYSIZE(storeIds),
        actionFilters,
        ARRAYSIZE(actionFilters),
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get products: 0x%x\r\n", hr);
        return;
    }
}

```

## Requirements

**Header:** XStore.h (included in XGameRuntime.h)

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles, and XBOX Series consoles

## Conceptual documentation

* [Basic store operations](/publishing/xstore-commerce/xstore-basic-operations)
* [Granting players access to add-on content](/publishing/xstore-commerce/xstore-granting-access)
* [Fine Grained Rate Limiting for Microsoft Store APIs](/publishing/xstore-commerce/xstore-fgrl)

## See also

[XStore](/reference/system/xstore/xstore_members)
[XStoreQueryProductsResult](/reference/system/xstore/functions/xstorequeryproductsresult)\
[XStoreQueryAssociatedProductsAsync](/reference/system/xstore/functions/xstorequeryassociatedproductsasync)\
[XStoreQueryEntitledProductsAsync](/reference/system/xstore/functions/xstorequeryentitledproductsasync)\
[XStoreQueryProductsAsync](/reference/system/xstore/functions/xstorequeryproductsasync)\
[XStoreQueryProductForCurrentGameAsync](/reference/system/xstore/functions/xstorequeryproductforcurrentgameasync)\
[XStoreQueryProductForPackageAsync](/reference/system/xstore/functions/xstorequeryproductforpackageasync)\
[Basic store operations](/publishing/xstore-commerce/xstore-basic-operations)\
[Granting players access to add-on content](/publishing/xstore-commerce/xstore-granting-access)


## Related topics

- [XStoreQueryProductsResult](/reference/system/xstore/functions/xstorequeryproductsresult.md)
- [XStoreQueryProductForPackageAsync](/reference/system/xstore/functions/xstorequeryproductforpackageasync.md)
- [XStoreQueryProductForPackageResult](/reference/system/xstore/functions/xstorequeryproductforpackageresult.md)
- [XStoreQueryProductForCurrentGameAsync](/reference/system/xstore/functions/xstorequeryproductforcurrentgameasync.md)
- [XStoreQueryAssociatedProductsForStoreIdResult](/reference/system/xstore/functions/xstorequeryassociatedproductsforstoreidresult.md)
