# predicate

Source: https://zotonic.com/docs/1910/predicate

URI: https://zotonic.com/id/1910

Language: en



Retrieve information about predicates. Predicates are the labels on edges (connections between resources) that give meaning to an edge. An example is the predicate "author" which refers to the authors of an article. Predicates form together with the referring and the referred page a triple `{subject, predicate, object}`.

Each predicate has a list of valid subject categories and valid object categories. This is used to filter the list of predicates in the admin edit page, and also to filter the list of found potential objects when making a connection.

The predicate property `is_dependency_ignored` defaults to false. When true, connections using this predicate do not keep their object resource alive during `is_dependent` cleanup. Protected resources are still kept. This does not change ordinary connection queries. `dependency_ignored/1` returns the cached list of predicate IDs with this property enabled.

`all/1` and `m.predicate.all` return a map keyed by binary predicate name. Each value contains the binary keys `id`, `name`, `uri`, `title`, `summary` and `reversed`. `get/2`, `m.predicate.author` and `m.predicate[104]` return the same minimal map for a visible predicate, or `undefined`. Visibility is checked per caller, after reading the shared structural cache.

The four display properties are read with property permissions for the current caller; denied or missing values are `undefined`. Read other resource properties via `m.rsc[p.id]`. Use `object_category` and `subject_category` for restriction lists (lists of integer category IDs). Model routes reject hidden predicates/categories. The `is_used` model route additionally requires edit permission because it inspects connections irrespective of their visibility.

Available Model API Paths
-------------------------

| Method | Path pattern                                             | Description                                                                      |
| ------ | -------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `get`  | `/`                                                      | Return minimal visible predicate maps (same as `/all`), keyed by binary name.    |
| `get`  | `/all/...`                                               | Return minimal visible predicate maps with binary `id`, `name`, `uri`, `title`, `summary` and `reversed` keys. |
| `get`  | `/is_used/+pred/...`                                     | Return whether predicate `+pred` is referenced by at least one row in `edge`.    |
| `get`  | `/object_resources/+key/...`                             | Return visible/published resources allowed as objects for predicate `+key`, bucketed by matching valid object category and title-sorted. |
| `get`  | `/object_category/+key/...`                              | Return list of valid object category ids for predicate `+key` (empty means unrestricted). |
| `get`  | `/subject_category/+key/...`                             | Return list of valid subject category ids for predicate `+key` (empty means unrestricted). |
| `get`  | `/is_valid_object_in_category/+predicate/+category/...`  | Return whether category `+category` is valid for objects of `+predicate`, including inverse ancestor matching fallback. |
| `get`  | `/is_valid_object_subcategory/+predicate/+category/...`  | Return whether `+category` is valid object category for `+predicate`, allowing ancestor matches (`IsSubcats=true`). |
| `get`  | `/is_valid_object_category/+predicate/+category/...`     | Return whether `+category` is directly valid object category for `+predicate` (`IsSubcats=false`). |
| `get`  | `/is_valid_subject_subcategory/+predicate/+category/...` | Return whether `+category` is valid subject category for `+predicate`, including subject ancestor/subcategory matching (`IsSubcats=true`). |
| `get`  | `/is_valid_subject_category/+predicate/+category/...`    | Return whether `+category` is directly valid subject category for `+predicate` (`IsSubcats=false`). |
| `get`  | `/predicate/+key/...`                                    | Return predicate definition for `+key` (id/name), including identity and ACL-checked display fields; `undefined` if unknown. |
| `get`  | `/+key/...`                                              | Alias for `/predicate/+key/...`; return predicate definition for `+key` or `undefined`. |

`/+name` marks a variable path segment. A trailing `/...` means extra path segments are accepted for further lookups.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1910?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1910?language=en>)
