# Create your catalog programmatically

> Use the CatalogProvider class to define your catalog in code for flexible or runtime-driven configurations.

You can define your catalog directly in code using the `CatalogProvider` class. This approach gives you full programmatic control over your catalog configuration and is useful in complex scenarios, such as if you have a game with a very large catalog that constantly adds new items in large quantities.

If your catalog is static and you prefer a visual setup, you can configure listings using the IAP Catalog window in the Unity Editor instead. Refer to [Create a catalog in the Editor](./create-catalog-in-editor.md) for instructions on that approach.

> **Note:**
>
> For a Direct to Consumer (D2C) payment provider, you need to [create a remote catalog](./payment-providers/configure-remote-catalog.md).

To define catalog listings programmatically:

1. During the initialization stage, create an instance of the `CatalogProvider` class.
2. Use the `AddProduct()` method to add each listing, or `AddProducts()` to add multiple listings at once.
3. For each listing, specify a unique cross-store `Product ID` and `Product Type`.

The following example shows how to add a consumable listing with the ID `100_gold_coins` to a `CatalogProvider`, and later call `FetchProducts()` to retrieve the defined listing.

```cs
using UnityEngine;
using UnityEngine.Purchasing;

public class MyIAPManager {
    public MyIAPManager () {
        var catalog = new CatalogProvider();
        catalog.AddProduct("100_gold_coins", ProductType.Consumable);
        // Connect to the store
        catalog.FetchProducts(UnityIAPServices.DefaultProduct().FetchProductsWithNoRetries);
    }
}
```

> **Note:**
>
> Use the `CatalogProvider` class to configure store-specific IDs and other advanced configurations directly in code.

## Additional resources

* [Manage your catalog in the Dashboard](./dashboard-catalog/_index.md)
