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 aspartner_idin the/configurationresponse. - 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:
-
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" -
If your player does not support DRM, do not show objects with
protectionother than0. - If MEGOGO told you to use only some contracts, show only the objects
with these
contract_idvalues. - Ignore the object types that your application does not support.
- 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 withhdr="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¶
- Add the new objects and update the changed objects. Any field can change.
- Remove the objects that are not in the new feed. Their videos do not play.
- Do not remove or hide an object at its
closing_date. Use the next feed to find which objects to remove. - For series, update the seasons and the episodes (
season,seria). Use the episodeidto 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¶
- If the response has
next_page, there are more videos. -
Send the same request again. Add
pagewith the value ofnext_pageafterpaging_strategy:https://api.megogo.net/v1/video?paging_strategy=token&page=PjIw&category_id=16&lang=en&sign=c926082509edd2e356584cd7b1280ecd_example1_xx -
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.
- Show the data that you have: from your catalog (method A) or from the list response (method B).
-
Send
/video/infowith theaccess_tokenof 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} -
Use these fields of the response:
Field Use is_availabletrue: the user can watch now. Show the "Watch" buttondelivery_rulesHow the user can get the video ( svod,tvod,dto,fvod,advod)purchase_info.tvod,purchase_info.dtoThe offers for a single purchase: tariff_id,price,period(days),quality,is_boughtpurchase_info.svod.subscriptionsThe IDs of the subscriptions that contain the video -
If the video has a trailer, the user can watch it without a subscription. Request the stream with the trailer ID:
trailer_idin/video/info, ortrailer@idin 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_tokenin 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 |