Getting teletext pages as images

Teletext pages are available both as images and as structured JSON and XML data. In this tutorial, we will fetch the images of all subpages of a teletext page. To try out the examples, you need your app_id and app_key credentials.

Getting our first image

Each teletext page has one or more subpages. The subpage numbering starts from 1. Let’s start by fetching the first subpage of the teletext page 100. Here is the URL pattern:

https://external.api.yle.fi/v1/teletext/images/{page}/{subpage}.png?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY

In the URL, replace {page} with the page number and {subpage} with the subpage number. We’re looking for the subpage 1 of the page 100, so the URL is:

https://external.api.yle.fi/v1/teletext/images/100/1.png?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY

teletext page 100/1

Getting the rest of subpages

Page 100 usually has more than one subpage. To know how many subpages there are, we will have to look at the page metadata. The URL pattern is:

https://external.api.yle.fi/v1/teletext/pages/{page}.{format}?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY

Replace {page} with the page number and {format} with either json or xml.

Let’s look at the JSON data for page 100:

https://external.api.yle.fi/v1/teletext/pages/100.json?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY

In the response below, the content of the page has been removed to make the response shorter. You can see the content in the full JSON example response and in the XML example response.

{
 "teletext": {
  "network": "YLE",
  "xml": "preserve",
  "page": {
   "number": "100",
   "name": "Uutiset",
   "time": "2020-05-05T10:43:26",
   "subpagecount": "4",
   "nextpg": "101",
   "toptype": "Block",
   "animated": "yes",
   "subpage": [
    {
     "number": "1",
     "time": "8",
     "content": [
       // ... redacted for brevity ...
     ]
    },{
     "number": "2",
     "time": "8",
     "content": [
       // ...
     ]
    },{
     "number": "3",
     "time": "8",
     "content": [
       // ...
     ]
    },{
     "number": "4",
     "time": "8",
     "content": [
       // ...
     ]
    }]
  }
 }
}

In the response, the field "subpagecount" is set to "4", so there are four subpages. The entries in the "subpage" array give the numbers of each subpage in the "number" field. Thus the subpages are:

https://external.api.yle.fi/v1/teletext/images/100/1.png?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY
https://external.api.yle.fi/v1/teletext/images/100/2.png?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY
https://external.api.yle.fi/v1/teletext/images/100/3.png?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY
https://external.api.yle.fi/v1/teletext/images/100/4.png?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY

teletext page 100/1 teletext page 100/2 teletext page 100/3 teletext page 100/4