# Iframely documentation > Iframely connects products and publishers through rich media, embeds, previews and URL data. Send any URL to the API and get back responsive embed code, oEmbed or unified URL metadata for 1900+ supported providers. --- title: "Get started with Iframely API" description: "Iframely gives you responsive embeds via oEmbed, Twitter Cards and Open Graph parsers" source: https://iframely.com/docs --- # Let's connect If you know where you are heading to, use links to the left. Otherwise, read on.
This introduction gives the same links in proper context. ## Basic flow Iframely takes your URL as an input, fetches its semantics from the origin server and tries to return rich media embed codes and other URL data. If successful, you'll get `html` as embed code that follows your [API settings](/settings) and optional query-string [parameters](/docs/parameters). If the request fails, you'll get an [error code](/docs/result-codes) and a message. ## API endpoint Iframely API follows JSON format. There are (just) two API endpoints available: one follows [oEmbed spec](/docs/oembed-api), another provides detailed [Iframely data](/docs/iframely-api). Think of it as the `<head>` of the origin URL with `<meta>` and media `<link>`s. oEmbed is excellent for simple embedding. Iframely data brings more [URL meta](/docs/meta) and details about rich media [types & feature flags](docs/links). [Embed.js](/docs/embedjs) lets you use Iframely without API calls. ## What URLs to send [We suggest](/docs/providers) you send everything you have. Iframely knows rich media from over 1900 domains but recognizes thousands more. We offer that you control what you get by allowing [rich media types](/docs/embeds). ## What to expect as output [Rich media](/docs/embeds) from third-party publishers comes in a variety of types. Many rich media embeds can be used as-is. Some may require an Iframely-hosted [iFrame helper](/docs/iframes) to display correctly. For example, [React](/docs/react) does not add third-party scripts, and you will need to [omit scripts](/docs/omit-script). [Hosted iFrames](/docs/iframes) deliver Iframely interactives such as [summary cards](/docs/cards), [click-to-play](/docs/click-to-play) and [player events](/docs/playerjs). ## Customize & fine-tune You can control every aspect of Iframely via your [settings](/settings), API [query-string parameters](/docs/parameters) and WYSIWYG editors. Initially, your account is configured for the most common use cases. You can give your authors our [URL options](/docs/options) for individual URLs to choose the media variant just the way they want it. ## Deliver the content You should cache API responses, including error codes, on your end and refresh your local data periodically. We recommend cache time-to-live of 1 to 24 hours. You can have longer TTLs if you use [hosted iFrames](/docs/iframes) because Iframely will keep updating its rich media for you in the background. You may deliver iFrames via [your own CDN](/docs/cdn). For CMS use, we recommend our [content IDs](/docs/ids) so that you can refresh Iframely data in batches of up to 100 URLs in your articles. Otherwise, we recommend that you [manage your origins](/docs/allow-origins). ## Available integrations & guides Some Iframely integrations are available. [WordPress](/wordpress) plugin, [Meteor](https://github.com/itteco/meteor-oembed/) package, [Medium](/docs/medium)-like text editor add-on, [CKEditor](/docs/ckeditor) supports Iframely, [NodeBB](https://github.com/nodebb/nodebb-plugin-iframely) forums, to mention a few. There are also integration guides for [React](/docs/react), [Angular](/docs/angular) and [AMP](/docs/amp). If you use of Iframely with Web Components, please read about required [Shadow DOM](/docs/shadow-dom) tweaks. ## Become a publisher Learn about [our robot](/docs/about) and how to recognize and allow it on your network. [Publish your rich media](/docs/publish) for Iframely. If you already provide embed codes for your users, [submit your site](/qa/request) as a provider. --- title: "What URLs to send to Iframely APIs" description: "Send us as many URLs as you like. You won't be billed for poor results" source: https://iframely.com/docs/providers --- # What URLs to send to Iframely? Iframely is your single API endpoint. We strive to provide embed code or data for every URL. If we miss a provider you think we should support, please [let us know](/qa/request). Traditional rich media involves a list of URL patterns. It is to detect supported embeds providers and route accordingly. We encourage you to go ahead and send us all your URLs. Instead of having an allow-list, choose from [supported media types](/docs/embeds) and Iframely interactives in your settings. Request Iframely to reply with an error otherwise. If a URL does not match your criteria, it won't be billed. ## URL patterns Giving you a definite list of providers is quite a challenge. We simply gave up trying and stopped counting: - Iframely has rich media from over [1900 domains](/domains) in our QA database. - Number of providers offer custom domain for thousands of their customers. Brightсove, Bandcamp, Tumblr, Behance, 23video, Libsyn, Podbean, Art19, Custed, Droplr and many others. - Thousands websites make videos they embed discoverable for SEO. We recognize: YouTube, Vimeo, Wistia, Brightcove, Kaltura, Dailymotion, JWPlayer, SoundCloud and others. - Local news stations of USA Today, CNE, NBC and other news networks. - Self-hosted distributed platforms such as Peertube and Mastodon. - Every news, media and blogging site that we provide a [summary card](/docs/cards) for. - Direct URL links to an image, [GIF](/docs/gifs), MP4 video, PDF or office file. - Any variation of URL shorteners and URL redirects that may mask original URL. This said, we recommend you send us all URLs that match `/^https?:\/\//i`. If you absolutely need one, here's the ever-changing list of domains we have in our QA database: [iframe.ly/domains.json](https://iframe.ly/domains.json). ## Manage your own providers list Alternatively, you can always build a list of URL patterns you want to allow on your end. To block any of the available domains, you can simply head to [provider settings](/providers) and add any domains that want Iframely to ignore. We'll respond with [error 417](/docs/result-codes#417), no matter the URL redirects. To disable rich media from individual providers, you may send [&media=0](/docs/parameters#media=0) API parameter. Iframely will disable the media for that individual URL (perhaps, falling back to a [summary card](/docs/cards) if allowed). > Your providers block list is limited to ~ 800 digits. Use `*` wildcard if required. ## Follow the rules Before you send a URL to us, please remember about legal implications of doing so. According to our [Terms of Use](/terms), Iframely is only a technical intermediary. Whereby, you are responsible for adhering to the terms of service for each provider. For your convenience and quick reference, here are the links to the terms of use of our most popular rich media providers: [YouTube](https://www.youtube.com/t/terms), [Twitter](https://developer.twitter.com/en/developer-terms/agreement-and-policy.html), [Facebook](https://developers.facebook.com/policy/) and [Instagram](https://www.instagram.com/about/legal/terms/api/). Each provider will also have their own privacy policy. Please consider our [GDPR](/gdpr) input. If needed or wanted, take a look at our [Consents](/docs/consents) feature. > Please manage a list of providers if you need to control which third party Terms of Use you bind yourself too. --- title: "Third party rich media embed types and sizes" description: "Send us as many URLs as you like. You won't be billed for poor results" source: https://iframely.com/docs/embeds --- # What to expect as rich media Third-party publishers provide and host rich media. It comes in a variety of types. Iframely lets you control what to allow as embedded content. The `html` field in API responses depends on your preferences. Many rich media embeds can be used as-is. Some would require an Iframely [iFrame helper](/docs/iframes) to display correctly. If any widget type does not fit into your system, you can disable it in your settings. Iframely will try and generate an [Iframely card](/docs/cards) instead. You may disable cards too and get URL data to build URL preview yourself.. ## Third-party rich media Iframely gives you granular control and information about rich media types and general URLs data. In your [media settings](/settings/media), please choose rich media types that work for your product. You do it via [functional use cases](/docs/links#functional-use-case-rels), `rel` in terms of [Iframely API](/docs/iframely-api) format. - **Apps** - posts, maps, infographics and widgets, ex. Twitter, Facebook, Instagram, Google Maps, CodePen. - **Players** - video, audio, podcasts, slideshows, playlists, ex. YouTube, iTunes, NY Times, SoundCloud. - **Photos & images** - provider-hosted images like Imgur, 500px, Flickr. Otherwise, images are pulled & hosted by Iframely. - **Raw media files** - GIFs and other direct links to image, video or audio files; served by Iframely. - **Readers** - long-form readers like Tumblr articles, Twitter timelines, GitHub gists. - **PDF** and **Office files** - served via Google Reader and MS Office live. Beware of [GDPR](/gdpr). - **Surveys** - include polls, surveys and forms, ex. Apester, PollDaddy, Quizlet, JotForm. - **Summary** - publisher's own branded cards for their URL previews, ex.: NY Times, Medium, Airbnb. - **Attachment** - attached promo media, such as players embedded in an article. Wrapped into a [media card](/docs/cards). You may disable any of the types. Instead, Iframely would try to build a [summary card](/docs/cards) in that case. [&media=0](/docs/parameters#media=0) API parameter lets you disable rich media for individual URLs. Please refer to the list of additional Iframely API [rel flags](/docs/links#functional-use-case-rels). > You can set APIs to respond with [error 417](/docs/result-codes#417) ("expectation failed") when an URL ends up with no HTML based on your preferences. We do not charge for error URLs. ## Iframely-hosted HTML helpers Iframely provides and hosts additional optional interactives: - [Cards](/docs/cards) - summary cards are URL previews. Media cards may contain a player attachment. - Images - to avoid hot-linking to images, they are delivered via hosted iFrame. Images are fetched and optimized for the user. - [Click-to-play](/docs/click-to-play) - an image placeholder with the "play" button, so player loads only when the user requests it. If publishers' video autoplays, we cover it with click-to-play by default. - [MP4 player](/docs/click-to-play) - Iframely-hosted MP4 player delivers raw MP4 files and streams. - [Player events](/docs/playerjs) - unified JavaScript API helps you control playback. - [Playback sync](/docs/playerjs) - Iframely stops a playing video if a user starts interacting with another one. - [Autoplay](/docs/autoplay) - videos are started on scroll, optionally muted. - [GIFs](/docs/gifs) - Iframely transcodes GIFs into smaller auto-looping MP4 files. - [User consents](/docs/consents) - if needed for [GDPR](/gdpr) or for its own intrinsic privacy value, you can ask user consents before exposing them to third-party rich media. Iframely also resolves the number of technical inconsistencies from third-party publishers. Depending on your development environment, you might need a [hosted iFrame](/docs/iframes) to deliver media to an end-user. --- title: "Iframely Responsive Async iFrame Helpers" description: "Iframely can wrap raw html embed codes into hosted iFrames for security, speed and required fallbacks" source: https://iframely.com/docs/iframes --- # Iframely-hosted rich media helpers Iframely hosts iFrame containers for [rich media embeds](/docs/embeds) from publishers. iFrames are served from our or [your](/docs/cdn) CDN. By default, we activate iFrame helpers only when required for specific rich media. Depending on your system, you may request our iFrames for all content. Or to help with specific technical requirements only. Or disable each fallback or Iframely interactive that may use an iFrame. Hosted iFrames provide technical features and improvements. Iframely knows [rich media](/docs/embeds) from [over 1900 domains](/domains). It might be overwhelming to keep up with all the inconsistencies. Our iFrame helpers aim to resolve it for you. All Iframely interactives require a hosted iFrame. It includes [cards](/docs/cards), [consents](/docs/consents), images, [click-to-play](/docs/click-to-play) covers, [player events](/docs/playerjs), sync and [GIFs](/docs/gifs). > iFrames are part of APIs for billing purposes. They trigger billing hits the same way. Because of this, our default is to activate iFrame only when required. ## Technical and system consistency Hosted iFrames add the following technical features to all providers. - **Async load** - our iFrames do not block scripts waiting for ``'s `onload` event. The iFrames load empty, fire `load` event instantly, and only after that, they start rendering their third-party content. - **JavaScript-friendly** - embeds from some publishers cannot be added to the DOM of your page via JavaScript. For example, if they use `document.write`. We wrap those into iFrame by default to fix that. - **Third-party scripts** - many systems set HTML via `innerHTML` (say, [React](/docs/react)). They do not execute any third-party scripts in the added HTML. We can wrap such HTML embeds into iFrame and give you a single [embed.js](/docs/embedjs) script that you need to make an exception for. Read more in [Omit scripts](/docs/omit-script) guide. - **Minimizing layout shift** - Iframely tries to predict the height of dynamic scripted widgets, so they take the required space right away and minimize [CLS](https://web.dev/cls/). It covers Twitter, Facebook and Instagram and other HTML widgets. Our iFrames adjust the height to the exact actual value when it becomes known. - **HTTPs** - if rich media is not SSL-friendly, we wrap it into our iFrame. If loaded over HTTP, iFrames will show third-party rich media. Over HTTPs, iFrame will fall back to a [summary card](/docs/cards). You can disable all non-SSL rich media. - **Caching**: Iframely iFrames keep updating their URLs and rich media in the background. You do not need to re-cache embed codes on your own that often. - **URL options** - you can give your authors our [URL options](/docs/options) for individual URLs to choose the media variant just the way they want it. - **Web components** - while we call it "iFrames", we use Shadow DOM and imports when it's beneficial. In browsers that support it, we bulk-insert web components via a single HTTP request. You can disable this upgrade in your settings or via `&import=0` [API parameter](/docs/parameters#import=0). - **AMP** - Iframely interactives and rich media embeds formatted for [Accelerated Mobile Pages](/docs/amp). - **[Lazy-loading](/docs/lazy-load)** - for all iFrames or players only. For players, we show an image placeholder right. Then swap it with an actual player it finishes loading. ## How we source iFrame helpers Iframely handles billions of frame-views via our global content-delivery network and through the [bring-your-own CDN](/docs/cdn) option. Depending on your [plan](/pricing) and settings, the iFrame source will either include the [hashed value](/docs/allow-origins) of your API key or permanent public embed code through the [Content IDs](/docs/ids). The iFrames with content ID will keep being available even if you decide to cancel your subscription later. Check the box in your [iFrames settings](/settings/media) page or use &id=1 API parameter to turn content IDs on. HTML of the embed code may contain Iframely's [embed.js](/docs/embedjs) script to resolve the unknown widget height and other features. Embed.js script is available [on GitHub](https://github.com/itteco/embedjs) if you wish to self-host. To limit the use of your iFrames to your domains only, please refer to [Allow origins](/docs/allow-origins) guide. ## How to activate iFrame helpers You can activate hosted iFrames in your [API settings](/settings) or by sending `&iframe=1` [query-string parameter](/docs/parameters) with your API requests. API settings let you configure the use of iFrames in a more flexible way. For example, skip certain domains or only use iFrames when a technical fix or Iframely interactive are needed. If you'd instead not get any iFrames at all, you may use `iframe=0` with your API calls to disable any helpers. --- title: "Keep your Iframely API keys secure" description: "Control origins that have access to your Iframely account, activate CORS and CSP" source: https://iframely.com/docs/allow-origins --- # Keep your API key secure Iframely authorizes API access using API key tokens. You can create multiple keys and disable/pause them at any time. It is your responsibility to keep your API keys secure. Iframely has different factor authorization mechanisms depending on how you use your API keys. There's a full API key value, that is meant for server-server communication (also known as "private" key). There is also an API key hash value that you can use in client-facing applications (also known as a "public" key). Manage your API keys and their restrictions [in your dashboard](/settings/keys). If your key is client-facing, or for [iFrames](/docs/iframes) and thumbnail images, you can restrict referring domain origins. ## Private server access A private API key (`&api_key` parameter) is meant to make API calls from your server to our servers via [Iframely API](/docs/iframely-api) or [oEmbed API](/docs/oembed-api) endpoints. That is assumed to be a private communication, though the onus is on you to keep the API key safe. If the breach does occur, we recommend generating a new key to replace it right away. If your not sure about your server API key privacy, you may also set and send us an extra secret HTTP header to authorize API calls. In your key details, enter a HTTP header name and allowed value of your choosing. Iframely will check headers in API calls with your `api_key` and raise `403` response if header is incorrect or not present. ## Public client access When you make API calls from a client-facing JavaScript, you want to secure your API key. For this purpose, instead of the private `api_key` parameter that is intended for the server-server calls only, use the client `key`. It should be the MD5 hash value of your actual API key. You can find it on your [keys page](/settings/keys): Unless you use [Content IDs](/docs/ids), we also include that client `key` parameter as the `src` attribute of [Iframely iFrames](/docs/iframes). This way, no end-user will see your private API key. Only a public client hash value may be exposed to users and can be sure it is used in the client context only. It will allow you to control traffic with that key, allowing only certain referring origins. If you use [Custom CDN](/docs/cdn), please make sure you configure the `origin` header to be passed through to Iframely. ## Configure allowed origins > We advise against reconfiguring production API keys as it is likely to cause disruptions. Instead, we recommend adding a new restricted API key. This way, you can test before launching and retire the old key when it is no longer in use. - Select the key from the list to edit it and find the "Activate origin check. Allow these domains only" checkbox. - In the text area below the checkbox, list the domain names of your sites, one per line. - You can use a wildcard for subdomains such as`*.yourdomain.com`. Beware though, wildcard will allow only the subdomains. Make sure to include your root domain separately if you need it. - `www.yourdomain.com` and `yourdomain.com` are two different domains in terms of security. Include `www.` if required. > Your changes may take up to an hour to propagate through our CDN. Any errors in security headers will stay in the cache for that hour. Make sure you know what you're doing. Beware of nested browsing context. When our iFrame is in your own iFrame on host A, and you load them both onto your site B, then both A and B domains need to be white-listed. If the "Activate origin check" checkbox is off, all domains are allowed. ## Technically speaking: CORS and CSP This is what happens when you activate your domain allowlist: - `frame-ancestors` HTTP header for Content-Security-Policy is added to Iframely-hosted iFrames. Internet browsers display such iFrames only on the allowed domains and show an error elsewhere. - Iframely API endpoints start checking the `origin` HTTP header. If the origin isn't on your list, API call is rejected with the error `403` and no cross-origin resource sharing is allowed. - If an `origin` isn't present at all in a client call, we can also raise error `403`. Please turn the "Require an origin" option on. > However, Iframely will keep allowing your API calls without an origin when you send your full private API key as `api_key` parameter. We assume it is a server-side API call. You may skip the restriction for iFrames and thumbnail images and leave it only for data API endpoints. --- title: "oEmbed API - Responsive Embeds" description: "oEmbed API for Responsive Web Embeds. Open-Source or hosted" source: https://iframely.com/docs/oembed-api --- # oEmbed API endpoint One of the (only) two Iframely endpoints follows the [oEmbed](http://oembed.com) protocol: - You make an HTTP GET request with your link as the `&url=` query-string parameter. - If any, HTML embed code is in the `html` field of JSON response. The `html` and rich media content depend on your [API settings](/settings) and optional [request parameters](/docs/parameters). If we cannot find third-party rich media for your URL, we will prepare a [summary card](/docs/cards). We deliver it via a [hosted iFrame](/docs/iframes). You may request to get an iFrame every time if you need any other technical improvements or Iframely interactives it brings. ## API request - `url` and `api_key` parameters are required. - `url` needs to be URL-encoded. - For additional security, you may substitute `api_key` with the `key` parameter. It should be the md5 hash value of your actual API key (see [Allow origins](/docs/allow-origins) guide). - There are also other optional [query-string parameters](/docs/parameters) available. > If you make API calls for each user via client-side JavaScript, use our CDN at `iframely.net/api/oembed/…`. If you use [Content IDs](/docs/ids), you can repeat the API call at `iframe.ly/{ID}.oembed`. You can even fetch data in batches of up to 100 content IDs, separated by `-` hyphen. ## API Response Iframely responds with a JSON that has a top-level `html` field for embed code and other oEmbed-specific data. [Here’s an example response for Vimeo](https://iframe.ly/api/oembed?url=https://iframe.ly/qH98az): ```json { "url": "https://vimeo.com/141567420", "type": "video", "version": "1.0", "title": "Input/Output", "description": "A new short from Terri Timely and Park Pictures", "author": "Terri Timely", "author_url": "https://vimeo.com/user1946955", "provider_name": "Vimeo", "thumbnail_url": "https://i.vimeocdn.com/…5aebf015a6472-d_295x166", "thumbnail_width": 295, "thumbnail_height": 166, "html": "
" } ``` Iframely supports `photo`, `video` and `rich` types as oEmbed output. For valid links, oEmbed API returns `link` type object and URL data when Iframely doesn't have any embed code for your URL. You can also get an [error code](/docs/result-codes) if URL fails. > Beware: `photo` type in oEmbed spec provides `url` as a hotlink to the image, no `html`. On plans that support it, Iframely also returns `options` object. Use it to pass [URL embed options ](/docs/options) to your authors. --- title: "Iframely API for Responsive Web Embeds" description: "Mighty API for Responsive Web Embeds. Based on oEmbed, Open Graph, Twitter Cards" source: https://iframely.com/docs/iframely-api --- # Iframely API endpoint Iframely-formatted endpoint provides complete JSON data Iframely could fetch about your URL. The basic flow is the same as with [oEmbed API](/docs/oembed-api): - You make an HTTP GET request with your link as the `&url=` query-string parameter. - If any, HTML embed code is in the `html` field of JSON response. The `html` and rich media content depend on your [API settings](/settings) and optional [request parameters](/docs/parameters). If we cannot find third-party rich media for your URL, we will prepare a [summary card](/docs/cards). We deliver it via a [hosted iFrame](/docs/iframes). You may request to get an iFrame every time if you need any other technical improvements or Iframely interactives it brings. In addition to the main `html` field, Iframely data will also give you URL's unified semantics and attribution as `meta` data and all available publisher's media variants as `links`. Together, `links` and `meta` sections mimic the `` of a requested web page, similar to Iframely [embeds discovery](/docs/publish). ## API request - `url` and `api_key` parameters are required. - `url` needs to be URL-encoded. - For additional security, you may substitute `api_key` with the `key` parameter. It should be the md5 hash value of your actual API key (see [Allow origins](/docs/allow-origins) guide). - There are also other optional [query-string parameters](/docs/parameters) available. > If you make API calls for each user via client-side JavaScript, use our CDN at `iframely.net/api/iframely/…`. If you use [Content IDs](/docs/ids), you can repeat the API call at `iframe.ly/{ID}.json`. You can even fetch data in batches of up to 100 content IDs, separated by `-` hyphen. ## API response Iframely responds with a JSON that has a top-level `html` field with our recommendation as embed code. Plus all other information we have found about your URL. [Here’s an example response for Vimeo](https://iframe.ly/api/iframely?url=https://iframe.ly/qH98az): ```json { "id": "qH98az", // URL Content ID (if available) plus canonical URL "url": "https://vimeo.com/141567420", // Rel use cases and html code for primary variant of embed // Check for `autoplay` if you requested it "rel": ["player", "ssl"], // That's the embed code we recommend "html": "
", // Meta object with attribution & semantics "meta": { "title": "Input/Output", "description": "A new short from Terri Timely and Park Pictures", "author_url": "https://vimeo.com/user1946955", "author": "Terri Timely", "site": "Vimeo", "canonical": "https://vimeo.com/141567420", "duration": 249, "date": "2015-10-06", "medium": "video" }, // Plus list of all media that we have for this URL // Embed src links with functional rels, for example: "links": { // List of player embed widgets "player": [{ // SRC of embed "href": "https://player.vimeo.com/video/141567420", // Functional and technical use cases "rel": ["player", "ssl", "html5"], // Link's MIME type, says "embed as iFrame" "type": "text/html", // Media query, e.g. aspects "media": { "aspect-ratio": 1.777778 }, // Plus generated HTML code for simplicity of use "html": "
" }, { … // Might have multiple variations of the same player. // Say, one that 'autoplay's, one as MP4 video, one as https. }], "thumbnail": [{ "media": { // Exact sizes here "height": 360, "width": 640 }, // We repeat the same rel for consistency "rel": ["thumbnail"], "type": "image", // "Use href as src of an image" "href": "http://cdn1.aka … med_1381670134_00040.jpg" }, { … }], // Also possible: header-menu, image (as rel), reader, survey, file, logo, icon "icon": [{ … }] }} ``` - `rel` is the primary information about the use case of the embeds. Primary rels are `player`, `thumbnail`, `app`, `image`, `reader`, `survey`, `summary`, `icon` and `logo`. - `meta` will contain the list of semantic attributes we could get and unify to the standard naming. > Array values with only one element will go as a single object (i.e. no `[]`). On plans that support it, Iframely also returns an `options` object. Use it for [URL Options](/docs/options) editor. --- title: "Embed.js library to unfurl rich media embeds" description: "Generate responsive embed codes for media players, rich other embeds and summary cards" source: https://iframely.com/docs/embedjs --- # Embed via JavaScript Iframely hosts the `embed.js` JavaScript library that works in orchestrations with [hosted iFrames](/docs/iframes) for third-party rich media and Iframely interactives. We include the `embed.js` by default as ` ``` To load the `embed.js` script conditionally, only when rich media is on your page, please copy-paste this [example gist](/docs/omit-script#load-when-required). - `src` should have either your `api_key` or its MD5 hash value as a `key` parameter in the query-string. - Securing API by managing [allowed origins](/docs/allow-origins) is recommended for production use. - You may add any of the other supported [query-string parameters](/docs/parameters). - If you use a [custom CDN](/docs/cdn), source the `embed.js` script from your domain name. > You may also self-host the `embed.js` script. It is available [on GitHub](https://github.com/itteco/embedjs) and NPM. ### HTML templates for your URLs Iframely's `embed.js` will search for the following links on your page with `data-iframely-url` attribute: ```html
``` During its load cycle, `embed.js` replaces all such URLs with Iframely iFrame corresponding to the `href` link. If all links are already in the DOM before you load the `embed.js` script, you'd get all links unfurled. If you load the `embed.js` before adding HTML template elements to your page, please see "Adding links dynamically" below. You may add `iframely-embed` and `iframely-responsive` styles to your page yourself, as described in our omit-CSS document. It helps with layout shift until after `embed.js` is loaded. > Still, if [cumulative layout shift](https://web.dev/cls/) is critical, you'd be better off using APIs instead. ### Adding links dynamically If you add links dynamically, say, in a chat application or after the `embed.js` script is loaded, there's an extra step for you. Please call `embed.js` loader explicitly: ```js iframely.load(); ``` It will fetch all the missing links and unfurl them. You can also specify an element which `` element to replace with its rich media Frame: ```js iframely.load(linkElement); // linkElement - is an with 'href' attribute to replace ``` Alternatively, you may skip the HTML template altogether and specify container element and an URL to put there directly: ```js iframely.load(containerElement, 'https://{YOUR_URL_HERE}'); ``` ### Act when unfurling fails Perhaps an original link or its rich media are no longer available. For example, it was removed from YouTube, became private on Facebook, or changed you changed API settings and didn't allow that media type any longer. Embed.js will automatically hide such failed rich media. If there's a container of rich media elements you want to hide, there are a couple of ways to do it. - You may source `embed.js` with optional `&parent=…` parameter containing CSS style name of the parent container. Iframely will find the first parent element with such class name and hide it, leaving the rest of your page tidy. ```js ``` - Alternatively, you can listen for the "after cancel" event and handle it as your app requires: ```js iframely.on('cancel', function (url, parentNode) { // url - the original URL to rich media // parentNode - container of the deleted rich media // e.g.: send a notification to your CMS to remove URL // or restore simple link so users can click on it }); ``` - If you only need to restore the failed URl as `a href` link to the same resource, you can source `embed.js` with the parameter `&cancel=0`, and it will convert cancelled widgets into a link. ## Card events `embed.js` raises a click event if you need to runa ny analytics when your user clicks in a [summary card](/docs/cards): ```js iframely.on('click', function (href) { // For example, call Google Analytics ga('send', 'event', { eventCategory: 'URL preview', eventAction: 'click', eventLabel: href }); }); ``` All clicks in cards open the URL in a new tab, except for the cards of your own domain. The same domain URLs are opened in the same window to allow for seamless navigation. To change that, override `iframely.openHref` function: ```js iframely.openHref = function (href) { // You're in full control now }; ``` ## URL options events iFrames that are sourced with [content IDs](/docs/ids) will declare [per-use options](/docs/options) for a URL they represent. For Iframely in a text editor, use those options to build a unique customization form for that URL. ```js iframely.on('options', function (widget, options) { // Use our options.js to build the options form for your text editor }); ``` ## Shadow DOM When you place Iframely card and other rich media embed codes into Shadow DOM, there may be issues. Please see the guide about how to [use Iframely embeds with Web Components](/docs/shadow-dom). --- title: "Optional query string parameters for Iframely APIs" description: "Configure parameters in your settings or send with every API call" source: https://iframely.com/docs/parameters --- # Additional API parameters Together with your API settings, optional query-string API parameters help you fine-tune what you receive from APIs. API parameters let you override your settings for individual URLs and API calls. For individual URLs, Iframely also offers an [options editor](/docs/options). It adds a variety of provider-specific `_`-prefixed parameters to fine-tune particular rich media. ## Required parameters ### `api_key` The API key you see in your profile. If your code faces users, you may replace `api_key` with `key` parameter, which should be the MD5 hash of your actual API key. See how to [restrict API access](/docs/allow-origins) with your `key` in that case. ### `url` URL-encoded value of the URL. Also, make sure it's HTTP or HTTPs link (we suggest you match against `/^https?:\/\//i`).
> Please URL-encode the URLs you send to Iframely. Seriously. ## iFrame helpers Below parameters are meant to complement your API settings. If you are in production and want to test some features, you may activate them via these query-string parameters. And vice versa - if you have a feature in your settings, you can disable it via query-string. To choose between query-string and API settings, consider this. Unlike your API settings, API query-string will be included with embed codes and you won't be able to undo it without making another API request. Settings will be applied to all Iframely [iFrames](/docs/iframes) that are already on your site. > When we give `=1` as parameter value, `=0` is also available to undo the feature in your settings. > You can use `true` and `false` values instead, if you like it better. ### `iframe=1` Explicitly activates our async [iFrames](/docs/iframes). Rich media from the publisher will be put into Iframely-hosted iFrame and include the required delivery helper. The media inside an iFrame will be kept up-to-date in the background on our end. ### `iframe=0` - Disables any required iFrame [display helper](/docs/iframes#technical-and-system-consistency). - Disables any allowed Iframely interactive such as [cards](/docs/cards), [click-to-play](/docs/click-to-play) and images. - If any, you will get rich media from the publisher as-is and handle it yourself. > In [oEmbed API](/docs/oembed-api) format, we cannot fit any autoplaying videos. ### `id=1` If your plan supports it and during the initial trial period, the parameter adds a [content ID](/docs/ids) to the API response. When you need to refresh the cache, you can use those IDs to re-fetch data in batches of up to 100 URLs. For [hosted iFrame](/docs/iframes), it will link the source to content ID rather than your API key. iFrames with IDs will remain in service even if you decide to cancel your subscription. ### `omit_script=1` [Rich media](/docs/embeds) embed codes may also include ` ``` - `color` - the hex code of accent colour of actions on the page to match your branding (please, no `#` to keep URL valid); - `site` - your domain name (we'll add "allow all" control for that domain name); - `theme` - `dark` or `light`, if you want a specific theme. By default, adjusts to user's browser preferences. Here is the consents form for our default CDN (iframely.net) and on this website (iframely.com): ## Technical configuration If you want "Site" or "Page" scope for one of your consent buttons, the widget will need to have access to the `Origin` and `Referer` header. The corresponding consent button will not show if the request headers are not present. You need to check your site's referrer policy and your CDN settings. ### Referrer-policy Iframely needs a unique [Referer](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer) header for our iFrames as an identifier of your page. When users allow "all widgets on a page", we check against that as an identifier. If your website works over HTTPs, it is the default user browser behaviour for cross-origin requests to send only the host value as the `Referer` header. A full path may have undesirable consequences for user security and privacy. Therefore, `Referer` is the same for all your pages by default, and single consent will apply to your entire website. To avoid that problem, please change your [Referer-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy): ```yaml Referrer-Policy: unsafe-url ``` If the risk of a potential leak of private information is a concern, please consider against the use of the "Page" consent scope. ### Custom CDN If use [your own CDN](/docs/cdn) with Iframely: - Embed [User settings form](#user-settings-form) off that same CDN as the origins must match. - If you want "Site" or "Page" consent buttons - allow your CDN to forward `Referer` and `Origin` headers to Iframely. - Additionally, please ensure that your CDN set up listens and allows the `referer` and `origin` values as the cache-control `vary` field set by Iframely widgets. --- title: "Iframely Content IDs for Rich Media URLs" description: "Iframely will give you a short ID that you can use for batch cache refreshes or as permanent source for the iFrame embed" source: https://iframely.com/docs/ids --- # Iframely content IDs For content management systems, Iframely can generate short identifiers (IDs) for each unique URL. Use it to source [iFrames](/docs/iframes) in HTML embed codes, edit [URL options](/docs/options), for batch URL refreshes or to request different formats such as [AMP](/docs/amp). Content IDs are unique within your account and are linked to your API settings. The feature is available on subscription [plans](/pricing) that support it. Content IDs are a permanent source of Iframely iFrames in HTML codes and URL data and survive the termination: we keep maintaining the embed codes and refresh related media content even if you no longer have an active subscription with us. Because of this commitment, URLs with associated IDs are stored permanently on Iframely network, unlike regular URLs that get cleaned up after a period of inactivity according to our privacy policy. ## How to get content IDs There are three scopes you can request to generate content IDs for: ### iFrame settings Configure this as default for iFrame `src`s in your [iFrames settings](/settings/media). When Iframely needs to generate an [iFrame helper](/docs/iframes) based on publisher's data or according to your other API settings, the `html` field for such embed codes will link to permanent public short URL address: ```html ``` By default, and on plans that don't support content IDs, our iFrame codes link to the hashed API key instead: ```html ``` ### `id=1` To activate IDs for all URLs, whether we wrap HTML embed code into our iFrame helper or not, make you API call with `&id=1` [query-string](/docs/parameters) parameter in [oEmbed](/docs/oembed-api) or [Iframely](/docs/iframely-api) formats. You'll get content `id` field in response JSON even when Iframely returns the native embed code from publisher without our iFrame helper. ### `id=0` This query-string parameter overrides your [iFrames settings](/settings/media), and forces iFrame helpers, if any, to link to your hashed API key instead. > Iframely Content IDs are case-sensitive. ## API calls with content IDs instead of URLs When content ID is available, it will be returned as `id` field in the JSON response. You can use it for subsequent API calls to Iframely. Such API calls don't require your API key and are a good fit for public facing implementations. ### Fetch single content by ID If you have received short `id` for your previous API call, your repeat calls may go directly to: - [iframe.ly/{ID}.json](https://iframe.ly/qH98az.json) - for [Iframely API](/docs/iframely-api) format - [iframe.ly/{ID}.oembed](https://iframe.ly/qH98az.oembed) - for JSON in [oEmbed](/docs/oembed-api) format Such API calls do not require `api_key` and are publicly available (yet are still linked to your account). You may add any [optional API parameters](/docs/parameters) to such anonymous calls. For example, quickly get an [AMP-formated](/docs/amp) iFrame with `&amp=1`. > If you fetch JSON data from users' browser, please use CDN: `iframely.net/{ID}.json` (or your own domain if you're on "bring your own CDN"). ### Batch request up to 100 IDs Instead of making a hundred API calls, we suggest you combine it into one. Simply generate an endpoint address this way: IDs delimited with `-` hyphen. For example: - [iframe.ly/{ID1}-{ID2}-…-{IDn}.json](https://iframe.ly/qH98az-7QPpxhS.json) - for [Iframely API](/docs/iframely-api) format - [iframe.ly/{ID1}-{ID2}-…-{IDn}.oembed](https://iframe.ly/qH98az-7QPpxhS.oembed) - for JSON in [oEmbed](/docs/oembed-api) format Again, you can use any of the [optional API parameters](/docs/parameters). The response will contain Iframely or oEmbed JSONs as values, with IDs as the root level keys: ```json { "ID1": { … }, "ID1": { … }, … "ID-N": { … } } ``` In other words, `body.IDn` from response of such batch calls will be the same JSON object as if you called `iframe.ly/IDn.json` or `iframe.ly/IDn.oembed` for a single ID. > The order of IDs in response may not match the order from request. We fill the data based on latency of an individual ID. --- title: "Bring your own CDN" description: "Get Iframely iFrames via your own CDN" source: https://iframely.com/docs/cdn --- # Bring your own CDN You can have Iframely [iFrame helpers](/docs/iframes) served via your own content delivery network. Say, Amazon CloudFront, Cloudflare or others. Enterprise plan requires a custom CDN provided. We will reach out if that becomes an issue. To have it configured, point your CDN distribution to our servers and give the address of your distribution to our support team. We will verify your setup and add your CDN to your account options. After that, Iframely will start returning embed codes with your own CDN proxy that fetches white-labeled iFrames from our cloud and delivers it to your users. If you [&omit_script](/docs/omit-script) and add [embed.js](/docs/embedjs) to your pages yourself, please load it off your custom CDN as well. > You may also opt to self-host embed.js script. It is available [on GitHub](https://github.com/itteco/embedjs) and NPM. ## For any CDN provider Basically, you need to map to the root of our domain, and let Iframely orchestrate your CDN's cache. The general requirements for any CDN are these: - Point your distribution to `iframe.ly` domain. - Forward us the `host` header so we recognize your CDN name. - Cache based on the origin headers - we'll ochestrate TTL and `vary`. - Match the HTTP/HTTPs protocol or choose HTTPs-only. - Forward all the query-string parameters. Select HTTP headers needs to be forwarded to origin to enable certain Iframely features: - Forward `Accept` header so we can deliver [WebP](https://developers.google.com/speed/webp/faq) images and other progressive features. - Forward `Origin` or `Referer` if you configure that as the action scope for a [user consents](/docs/consents#custom-cdn) button or if you activate any [API origin restrictions](/docs/allow-origins). - Forward `Sec-CH-Prefers-Color-Scheme` client header if you want [auto dark/light themes](/docs/parameters#theme) for supported rich media publishers. ## Configure Amazon CloudFront Create a new CloudFront distribution. For it, configure the following general settings that are required by Iframely: - Delivery method: `web`. - Origin domain name: `iframe.ly`. - Origin path: leave empty. - Forward headers: `whitelist`, add header `CloudFront-Forwarded-Proto`. Otherwise, we won't be able to tell if a request comes via SSL or not. Also add `host`, `origin` and `referer`. - Object caching: `use origin cache headers`. - Forward Query Strings: `yes`. - All the other fields can be left with default values. You may create custom CNAME subdomain from your main domain that points to CloudFront distribution if you like, but don't forget to get a custom SSL certificate from Amazon in that case as well. ## Configure Cloudflare You can either create a subdomain for your existing Cloudflare site, or register a custom root-level domain and add it to Cloudflare separately. - In DNS, create subdomain as the `CNAME` record and point it to `iframe.ly`. You can safely use `CNAME Flattening` setting to make DNS resolution a bit faster for your users. - In Caching, make sure the following settings are applied: - `Browser Cache TTL: Respect Existing Headers` - Minimum cache TTL will depend on your Cloudflare plan. - In Rules/Page Rules, create a rule for `yourcdn.yourdomain.com/*` (use your own domain) and add these two settings: - `Cache Level: Cache Everything` - it makes Cloudflare cache everything, including text/html resources too. - `SSL level: Full` - Iframely needs to know that requests come over SSL. > Iframely needs all query string parameters. If you need other Cache Control values elsewhere on your domain, then you will not be able to set CDN as subdomain. > You will have to register a separate domain for your custom CDN with Iframely, as our iFrames don't work without query strings. - Don't forget to activate SSL in Crypto section if you need HTTPs connections. ## Contact us to finalize Once you've configured your CDN, [send us](mailto:support@iframely.com) your CDN domain name. We will verify that everything is right and configure it as domain name for your Iframely iFrames. > If you use User Consents feature, you may also need to allow `referer` and `origin` headers, depending on your configuration. [Read here](/docs/consents#technical-configuration). The `origin` header may also be required for your [API key security configuration](/docs/allow-origins). --- title: "Omit third-party scripts from HTML embed codes of rich media" description: "Use &omit_script=true to skip Iframely script" source: https://iframely.com/docs/omit-script --- # Omit scripts from HTML Third-party rich media embed codes may include a ` ``` Your page may or may not have our embeds on it. Here is an example code that loads embed.js only when it is required: See the [embed.js](/docs/embedjs) document if you need events and controls that our Embed.js script provides. > If you use a [custom CDN](/docs/cdn) option, please, source the embed.js script from your distribution. > You may also opt to self-host embed.js script file. It is available [on GitHub](https://github.com/itteco/embedjs) and NPM. --- title: "Fine-tune Iframely embeds with CSS" description: "Use &omit_css=true to switch Iframely to use class names instead of inline CSS styles" source: https://iframely.com/docs/omit-css --- # Omit CSS and adjust styles Iframely wraps responsive iFrames into two `div` elements. By default, required styles are included inline so the HTML works right away. You may add a bit of required CSS to the stylesheet of your page and use Iframely with class names. Here's when it's particularly useful: - If your content management system is sensitive for inline styles; - Just to get slimmer HTML codes so they take less space in your database; - To activate the predictive height mechanism for the apps such as Twitter and Facebook. ## Add required styles to your page First of all, add these required classes either as `