Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Content API

Stephan Kulla edited this page Mar 15, 2023 · 6 revisions

⚠️ This documentation is deprecated. Please go to https://github.com/serlo/documentation/wiki/iframe-API for the current documentation of our iframe API.



⚠️ This API will change soon.

We are in the progress of moving to a new infrastructure and this API will be simplified.

We will only support our recommended option ?contentOnly and the content height will no longer be send.

If you rely on one of the other options please get in touch.


We offer an API for all learning content on serlo.org.
(There is a separate API for the metadata of the content.)

Recommended Option

Include serlo.org content in your own application via <iframe> like

<iframe src="https://de.serlo.org/1553?contentOnly"></iframe>

contentOnly is our recommended options. It hides all elements except the content, breadcrumbs navigation and search, e.g. https://de.serlo.org/1553?contentOnly

Terms of Use

The API is free. Please contact us before using the API beyond prototyping: [email protected]

Further Customization

For further customization of the output we provide a couple of query strings which you can combine according to your needs like

<!-- Hide only topbar and footer -->
<iframe src="https://de.serlo.org/27801?hideTopbar&amp;hideFooter"></iframe>

Content height

We inform the parent window about the actual dimensions of our content via window.postMessage (initially and after any resize event). You can use that to give the iframe the correct height to avoid scroll bars:

window.addEventListener('message', e => {
  const { data } = e

  // Context is always `serlo`
  if (data.context !== 'serlo') {
    return
  }

  // Content width in px
  console.log(data.contentWidth)
  // Content height in px
  console.log(data.contentHeight)

  // Get the iframe somehow. You can also check `e.origin`
  const iframe = document.getElementsByTagName('iframe')[0]
  iframe.style.height = `${data.contentHeight}px`
})

Any Problems or Suggestions?

If that still doesn't fit your use case or you run into any issues, feel free to create an issue.