Skip to main content

Managing Collections and Categories for Videos

Collections and categories are essential tools for organizing and structuring your video content. This guide will show you how to manage collections and categories for videos using the Teyuto API.

Managing Collections

Collections allow you to group related videos together.

Creating a Collection

To create a new collection:

  1. Use the POST /collections endpoint
  2. Set up your request headers:
    Content-Type: application/x-www-form-urlencoded
    Accept: application/json
    Authorization: YOUR_API_KEY
  3. In the request body, include:
    • title: The title of the collection
    • description: A description of the collection
    • privacy: The privacy setting (e.g., "hidden", "public", "registered")
    • video_ids[]: IDs of videos to include in the collection
    • Other optional fields like trailer_id, date_order, category_ids[], etc.

Example cURL request:

curl -X POST "https://api.teyuto.tv/v2/collections" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=My Collection&description=A great collection of videos&privacy=public&video_ids[]=123&video_ids[]=456"

Updating a Collection

To update an existing collection:

  1. Use the PATCH /collections/{id} endpoint
  2. Replace {id} with the collection ID
  3. Include the fields you want to update in the request body

Example cURL request:

curl -X PATCH "https://api.teyuto.tv/v2/collections/789" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=Updated Collection&description=An even better collection"

Deleting a Collection

To delete a collection:

  1. Use the DELETE /collections/{id} endpoint
  2. Replace {id} with the collection ID

Example cURL request:

curl -X DELETE "https://api.teyuto.tv/v2/collections/789" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY"

Getting Collection Details

To retrieve details about a specific collection:

  1. Use the GET /collections/{id} endpoint
  2. Replace {id} with the collection ID

Example cURL request:

curl -X GET "https://api.teyuto.tv/v2/collections/789" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY"

Managing Categories

Categories help in classifying videos and collections.

Adding Categories to Collections

When creating or updating a collection, you can assign categories using the category_ids[] parameter:

curl -X POST "https://api.teyuto.tv/v2/collections" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=My Collection&description=A categorized collection&category_ids[]=101&category_ids[]=102"

Adding Categories to Videos

Similarly, when creating or updating a video, you can assign categories:

curl -X POST "https://api.teyuto.tv/v2/videos/vod" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d "title=My Video&description=A categorized video&category_ids[]=101&category_ids[]=102"

Filtering Content by Category

To retrieve content filtered by category, you can use the category_id parameter in the GET requests for collections or videos:

curl -X GET "https://api.teyuto.tv/v2/collections?category_id=101" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY"

Best Practices

  1. Logical Organization: Create collections that make sense for your content and audience. This could be by theme, series, or any other logical grouping.

  2. Consistent Categorization: Develop a clear category structure and apply it consistently across your videos and collections.

  3. Use of Privacy Settings: Utilize the privacy settings to control access to your collections. This is particularly useful for creating members-only content or for staging content before it's ready for public viewing.

  4. Regular Maintenance: Periodically review your collections and categories to ensure they remain relevant and well-organized.

  5. Efficient Video Management: Instead of manually adding videos to collections one by one, use the video_ids[] parameter to add multiple videos at once when creating or updating a collection.

By effectively using collections and categories, you can create a well-organized video library that enhances user experience and content discoverability on the Teyuto platform.