<@U04UQ68083H> How to use RelationshipApi from ory...
# ory-copilot
p
@chilly-king-10285 How to use RelationshipApi from ory sdk to list relationships.
b
A message from kapa.ai
To list relationships using the RelationshipApi from the Ory SDK, you would typically use the
GET /relation-tuples
endpoint. This endpoint allows you to query all relationships that match the provided parameters. The only required field is the namespace. Here is a general outline of how you might use this endpoint: 1. Authenticate your request. According to the [Ory API Reference](https://www.ory.sh/docs/reference/api), you must be authenticated using an
oryAccessToken
to perform this operation. 2. Specify your query parameters. These parameters can include
page_token
,
page_size
,
namespace
,
object
,
relation
,
subject_id
, and
subject_set
fields. Note that only the
namespace
field is required. The rest are optional and allow you to refine your query. 3. Send a GET request to the
/relation-tuples
endpoint with your query parameters. Please note that the exact method to use this endpoint will depend on the specific Ory SDK and programming language you are using. The SDK should provide methods to authenticate your request and send GET requests to the API. For command-line interface, you can use the
ory list relationships
command with various options to list relation tuples. The options include
--namespace
,
--object
,
--relation
,
--subject-id
,
--subject-set
, and pagination options like
--page-size
and
--page-token
. More details can be found in the [Ory CLI documentation](https://www.ory.sh/docs/cli/ory-list-relationships). Remember to replace placeholders with actual values relevant to your application. For more detailed information, refer to the [Ory API Reference](https://www.ory.sh/docs/reference/api) and the specific documentation for the Ory SDK you are using.