Zobjects are additional, customizable metadata that you can create and associate with videos. Simple examples of Zobjects are actors, directors, or artists.
Since Zobjects can be used to create any metadata association you need, you first need to create a Zobject type to define the data structure.
Creating a Zobject Type using the API
This example will outline how to create a new Zobject type to hold the name of Film directors and a list of Films. Afterward, we will create Zobject instances for each director.
Zobject types can also be created in the Zype admin in the Zobejct Type section, and we have a guide outlining how to do that HERE.
To create a new Zobject type you will use the Create Zobject Type endpoint.
curl --request POST \
--url https://api.zype.com/zobject_types
In the payload, we are going to add a title, a description, a flag to establish if the Zobject instances can be associated with videos, and 2 custom attributes, each instance will have:
- Full Name - as a String
- Films - as an Array
The payload will look something like this:
{
"zobject_type": {
"title": "z_directors",
"description": "Description of the Zobject, for example films Directors",
"videos_enabled": "true",
"zobject_attributes_attributes": [
{
"field_name": "full_name",
"field_type": "String",
"description": "this sample field to hold the name of the director"
},
{
"field_name": "film",
"field_type": "Array",
"description": "this array will hold the name of some films from the director"
}
]
}
}
Note that the parameter for custom attributes is zobject_attributes_attributes.
The data type available are:
- String
- Text
- Integer
- Float
- Date
- Time
- Boolean
- Array
- Id
Now we have our new Zobject type available in the Zobject types section:
The new Zobject Type details view will look like this on the admin:
Creating Zobjects using the API
Now that we have our Zobject Type we can create entrees or Zobjects for each director.
Same as with types, Zobjects can be created from the Zype admin in the Metadata section on the left navigation, and we have a guide outlining how to do that HERE.
To create a new zobject type we use the Create Zobject endpoint.
curl --request POST \
--url https://api.zype.com/zobjects
In the payload, we need to add the Zobject type and we are going to add a title, description, set it as active, and fill the custom parameter in the ZobjecType.
Note that spaces on the title the Zobject type will get replaced by an underscore "_"
The payload would look something like this:
{
"zobject_type": "z_directors",
"zobject": {
"title": "Tarantino",
"active": true,
"description": "zobject for quentin tarantino",
"friendly_title": "director-taratino",
"custom": {
"full_name": "Quentin Tarantino",
"film": "Reservoir Dogs, Pulp Fiction, Kill Bill, Django Unchained"
}
}
}
You can now create new Zobjects for each director. You can also associate this Zobject to the videos from the director.
Was this article helpful?
Articles in this section
- Integrating a Custom Video Player via API
- Create zobjects with custom attributes using the API
- Creating New Subscriptions with the API
- Assigning Categories to Videos Using the API
- Using the Upload API Endpoint
- Ad Timings with the API
- Importing a Single Video from a URL
- How to Merge a New Video Import to an Existing Video Using the API
- How to Request a Video Player