Tenants - Subjects
  • 22 Dec 2023
  • 1 Minute to read
  • Dark
    Light

Tenants - Subjects

  • Dark
    Light

Article summary

The Tenant's subject search endpoint allows users to search subjects available to the authorized tenant.

The query arguments determine the type of search performed passed:

Argument
Example
Definition

ids
string

"cat_123,dog_123"

(optional) A comma-delimited list of subject_uids.
 
Passing the ids parameter will perform a batch ID search.

limit
integer

15

(optional) The number of results to return.
 
 Only used in prefix and semantic searches.
 
 Limited to 1000, defaults to 10.

GET /1/tenants/{tenant_id}/subjects
Host: https://api.cogniac.io

Example: Searching for Semantically Similar Subjects

curl -X GET https://api.cogniac.io/1/tenants/current/subjects?ids=cat \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json"
import cogniac

cc = cogniac.CogniacConnection(username="test@cogniac.co", 
                               password="myPassword", 
                               tenant_id="63QhzFLc9tg4")

search=cc.search_subjects(ids=[], 
                   prefix=None, 
                   similar='cat', 
                   name=None, 
                   tenant_owned=True, 
                   public_read=False, 
                   public_write=False, 
                   limit=10)
print(search)
{
  "data": [
    {
      "created_at": 1478574780.947824,
      "created_by": "user@cogniac.co",
      "description": null,
      "modified_at": 1478574780.947824,
      "name": "cat",
      "public_read": true,
      "public_write": false,
      "subject_uid": "cat_lq1",
      "tenant_id": "wh1Swty"
    },
    {
      "created_at": 1478574787.262627,
      "created_by": "user@cogniac.co",
      "description": null,
      "modified_at": 1478574787.262627,
      "name": "cat_roi",
      "public_read": false,
      "public_write": false,
      "subject_uid": "cat_roi_bn2",
      "tenant_id": "wh1Swty"
    },
    {
      "created_at": 1478582892.811003,
      "created_by": "bob@yahoo.com",
      "description": null,
      "modified_at": 1478582892.811003,
      "name": "cat",
      "public_read": true,
      "public_write": false,
      "subject_uid": "cat_8gf",
      "tenant_id": "Oi23gt5a"
    },
    {
      "created_at": 1478574780.557287,
      "created_by": "bob@yahoo.com",
      "description": null,
      "modified_at": 1478574780.557287,
      "name": "cat_and_dog",
      "public_read": true,
      "public_write": true,
      "subject_uid": "cat_and_dog",
      "tenant_id": "Oi23gt5a"
    },

  ]
}

Was this article helpful?