---
title: Define a rating
slug: cms-12/api/defining-a-rating
docTags: 
createdAt: 2026-08-07T16:45:43.000Z
---

A rating is a simple structure that is powerful in its flexibility. Its three core attributes are customizable, allowing a developer to tailor an application's rating system to its needs.

### Design a resource reference

One core rating attribute is the resource reference, which identifies the resource to which the rating is applied. In the Optimizely Community API, resources are identified using the `Reference` class. The scheme applied to define these references is designed within your application. This lets a developer structure ratings to be conveniently identified, organized, and retrieved in the application.

When designing a scheme for representing references, consider the following:

- **What are you rating?** Are you rating a first-class object within your system, a class of objects, or a facet of an object? For example, you might rate a product, a variant, or the product's price. Design your reference scheme to accommodate intangibles like facets, which are not necessarily uniquely identifiable objects within the application.
- **How will you retrieve your ratings?** Do you intend to retrieve ratings individually or in batches? If you need to retrieve a batch of ratings for a category of resources, consider representing that organizational scheme within your resource references.

A URI or similar namespace scheme provides an ideal template for a reference. Consider the following sample reference scheme that might be applied to address the above considerations:

```csharp
product://optimizely/{product-identifier}/{variant-identifier}/{facet-identifier}
```

For information on `References`, including best practices, see  *References and IDs* in [Discover the platform](docId\:NKmGS-fLtRQIYLEWZfb69).

### Design a rating scheme

The value of a rating is represented as a simple integer value. The value's significance is defined in your application.

- A simple 5-star scale might be represented by values 1-5
- A 5-star scale, allowing half-star ratings, might be represented by values 1-10
- A percentage-based scale might be represented by values 1-100

Anticipate the potential for future alterations to your rating scale. For example, your application currently requires a 5-star rating scale, but you anticipate a future need for more granular values. In such a situation, consider implementing that scale with the values 1-10 rather than 1-5, where an even integer within that range represents each whole star. This allows for the introduction of half-star ratings later without skewing the statistics for existing ratings.
