Skip to content

Build and update the catalog

This guide shows how to show the MEGOGO catalog in your application. You can use one of two methods:

Method How it works Use it when
A. Import the XML feed Each day, your server downloads the feed and updates your catalog. Your application shows the catalog from your database You have your own catalog, search and screens. You show MEGOGO content together with other content
B. Use the Content API Your application gets the lists (categories, collections, search) from the Content API when the user opens a screen You show MEGOGO content in separate screens. You do not want to keep a copy of the catalog

For both methods, your application gets the details of one video and the stream from the Content API.

Before you start

Make sure that:

  • You have the partner ID and a key pair. See Credentials.
  • Your code can sign requests. See Sign a request.
  • For method A: MEGOGO gave you the URL of your feed.

WARNING

Do not use /video/info to collect the data of many videos. Send /video/info only after a user action, for example when the user opens the page of a video. To get the data of many videos, use the XML feed or the list requests.

Method A. Import the XML feed

Step 1. Download the feed

Download your feed one time each day, after 05:00 UTC:

https://xml.megogo.net/assets/files/{region}/{partner_number}/all_mgg.xml
  • MEGOGO gives you the URL of your feed. Your feed contains only the objects that you can show. {partner_number} is the same value as partner_id in the /configuration response.
  • Do not use the feed of the region without {partner_number}. It contains objects that your keys cannot play. Exception: for Poland, use the region feed.
  • For the test feeds and the list of regions, see the XML feed reference.
  • The file can be large (up to about 200 MB). Use a streaming XML parser.
  • The first line after the XML declaration has the time of generation (UTC), for example ``. Until the new file is ready, the URL gives the previous file.

Step 2. Select the objects

Your feed contains the objects of all platforms. Show only the objects that your application can play:

  1. Use the flag of your platform:

    Your platform Show the object if
    Web web_allowed="1"
    Mobile devices (all mobile operating systems) ios_allowed="1"
    Smart TV, set-top boxes smart_tv_allowed="1"
  2. If your player does not support DRM, do not show objects with protection other than 0.

  3. If MEGOGO told you to use only some contracts, show only the objects with these contract_id values.
  4. Ignore the object types that your application does not support.
  5. If 4K is not set for your key, do not show the 4K versions. A 4K version is a separate object with quality value="UHD". Its title usually ends with "UHD" or "UHD HDR". If 4K is set, show the 4K versions only on devices that support H.265 (HEVC). Show the versions with hdr="true" only on devices that support HDR.

Step 3. Find how the user gets each object

Use the distribution elements of the object:

distribution@vod_type In your application
svod, fvod, advod Part of your subscription. The user must have your subscription
tvod Rent for a limited time
dto Purchase without a time limit. Show it as "forever"

CAUTION

The prices, tariff_id and service_id in the feed are MEGOGO tariffs. They can be different from your offers. Do not show these prices to your users. Do not use these IDs in the Billing API. Get the prices and the tariff_id of a video from /video/info (step 2 of Show the page of a video).

WARNING

The Content API gives the stream of an fvod or advod object without a user. Before you request the stream, make sure that the user has your subscription.

Step 4. Update your catalog

  1. Add the new objects and update the changed objects. Any field can change.
  2. Remove the objects that are not in the new feed. Their videos do not play.
  3. Do not remove or hide an object at its closing_date. Use the next feed to find which objects to remove.
  4. For series, update the seasons and the episodes (season, seria). Use the episode id to request the stream.

If the download fails, keep the previous catalog. Try again later the same day.

Method B. Use the Content API

Step 1. Get the configuration

Send /configuration when your server starts, and then one time each day. Keep the response in a cache:

https://api.megogo.net/v1/configuration?lang=en&sign=2e2c975fe0d4d2b4e82d784fa103ea38_example1_xx

The response has the categories (categories[].id) and the genres for the filters. The examples on this page use the invented keys from Sign a request.

Step 2. Get the list of videos

To get the videos of a category, send /video with paging_strategy=token:

https://api.megogo.net/v1/video?paging_strategy=token&category_id=16&lang=en&sign=161ac1699f56040cd90b3b7cd610cabe_example1_xx

Expected response (shortened):

{
  "result": "ok",
  "code": 200,
  "data": {
    "limit": 20,
    "next_page": "PjIw",
    "video_list": [
      {
        "id": 12345,
        "title": "Example film",
        "year": "2024",
        "image": { "small": "https://…", "big": "https://…", "original_wide": "https://…" },
        "delivery_rules": ["svod"]
      }
    ]
  }
}

Other list requests use the same pagination:

Request Gives
/video?category_id={id} The videos of a category
/collections The collections (curated lists). MEGOGO makes collections for some partners on request. Ask your MEGOGO manager
/video/collection?id={id} The videos of a collection
/search?text={text} The search results
/catalog/objects?category_id={id} The videos for the selected filters, in groups

For the parameters, see the Content API reference.

Filter and sort the list

You can use one of two methods:

Method Requests
Filters of /video /video?category_id={id}&genre={genre_id}&sort={sort}. Get the genres from /configuration (categories[].genres, genres[]). sort: popular, add (new on MEGOGO), year
Catalog filters /catalog/filters?category_id={id}&show_title=true gives the filters of your key: genre, country, year, audio track, subtitles, quality and others. Then send /catalog/objects?category_id={id}&{filter_id}={item_id}, for example video_genre_id=2,25&country_id=2

MEGOGO turns on the catalog filters for a key. If /catalog/filters gives an empty filter_by, ask your MEGOGO manager, or use the filters of /video.

For a filter with multichoice: true, you can send more than one item ID, separated by commas. To get the sort options (order_by), add show_disabled_items=true to /catalog/filters.

Step 3. Get the next page

  1. If the response has next_page, there are more videos.
  2. Send the same request again. Add page with the value of next_page after paging_strategy:

    https://api.megogo.net/v1/video?paging_strategy=token&page=PjIw&category_id=16&lang=en&sign=c926082509edd2e356584cd7b1280ecd_example1_xx
    
  3. If the response has no next_page, this is the last page.

CAUTION

Do not change the page value and do not make it yourself. Its format can change. Include page in the signature like all other parameters.

Do not use offset and limit. MEGOGO is going to remove them.

Show the page of a video

Do these steps for both methods, when the user opens the page of a video.

  1. Show the data that you have: from your catalog (method A) or from the list response (method B).
  2. Send /video/info with the access_token of the user, if the user signed in:

    https://api.megogo.net/v1/video/info?id={video_id}&lang=en&access_token={access_token}&sign={sign}
    
  3. Use these fields of the response:

    Field Use
    is_available true: the user can watch now. Show the "Watch" button
    delivery_rules How the user can get the video (svod, tvod, dto, fvod, advod)
    purchase_info.tvod, purchase_info.dto The offers for a single purchase: tariff_id, price, period (days), quality, is_bought
    purchase_info.svod.subscriptions The IDs of the subscriptions that contain the video
  4. If the video has a trailer, the user can watch it without a subscription. Request the stream with the trailer ID: trailer_id in /video/info, or trailer@id in the feed.

To sell a single title, send the tariff_id from step 3 to the Billing API. See Sell a single title.

Limits

  • Each key can send 1000 requests per minute. Above this limit, MEGOGO can return HTTP 429.
  • For method B, keep the list responses without access_token in a cache for some minutes. Then many users do not send the same request.

Errors

Response Cause Action
HTTP 400, "message": "You entered wrong sign key" The signature is not correct Make sure that the signature has all parameters in the URL order, also page and lang. See Sign a request
HTTP 200, "result": "error", "code": 400 A parameter is not correct, for example the page value Start again from the first page
HTTP 200, "result": "error", "code": 404 The video is not found Do not show the video. For method A, remove it from your catalog
HTTP 429 Too many requests Send fewer requests. Use a cache
Feed: the generation time is not today The new feed is not ready Keep the previous catalog. Try again later

Next steps