I know that primes of the form $4k+1$ can be represented uniquely as the sum of two squares (not counting order or negative numbers). But there are others like $8$ and $9$ that are not "prime *and* of the form $4k+1$" that can also be represented uniquely.

Is there a general pattern?