<@U04UQ68083H> How do I fetch the list of existing...
# ory-copilot
b
@chilly-king-10285 How do I fetch the list of existing identities for an Ory project in Go?
c
A message from kapa.ai
To fetch the list of existing identities for an Ory project in Go, you can use the
GET /admin/identities
endpoint of the Ory API. This endpoint is part of the "identity" group of methods in the Ory API and it lists all identities in the system. Here is an example of how you can use this endpoint in Go:
Copy code
go package pkg      import (       ory "<http://github.com/ory/client-go|github.com/ory/client-go>"   )      func main() {     conf := ory.NewConfiguration()     conf.Servers = ory.ServerConfigurations{{URL: "https://{your-slug}.<http://projects.oryapis.com|projects.oryapis.com>"}}        identity, res, err := client.IdentityApi.GetIdentity(ctx, created.Id).IncludeCredential([]string{"password"}).Execute()     // ...   }
In this example, replace
{your-slug}
with the slug of your Ory project. The
GetIdentity
method is used to fetch an identity. The
IncludeCredential
method is used to include the hashed credentials of the identity in the response. Please note that this is a basic example and you might need to handle errors and the response according to your needs. For more information, refer to the [Ory API Reference](https://www.ory.sh/docs/reference/api) and the [Ory Kratos API Reference](https://www.ory.sh/docs/kratos/reference/api). Please note that the code snippet provided is a basic example and you might need to handle errors and the response according to your needs.