Skip to main content

Meta Data Parser

unfurl

Unfurling is the process of extracting metadata from a webpage, such as its title, description, and main image. The simple unfurl method of the sdk takes either an array of URLs or a single URL and returns a standardized object of metadata.

Arguments:

ArgumentTypeDescription
urlsstring, string[] - requiredA URL, as a string, or an array of strings

Return Value

When given an array of URL, the unfurl method returns an objects where each key is a submitted URL and the value represents the metadata of that URL. When given a string URL, the unfurl method returns an object representing the metadata of that URL. In both cases, the metadata object has the following properties:

info

Different webpages publish different sets of metadata. The object returned will have some subset of the following properties, based on the available metadata for the URL.

  • title: The title of the webpage.
  • description: The description of the webpage.
  • url: The original URL.
  • canonical_url: The canonical URL of the page.
  • images: an array of objects, each representing an image with at a minimum a url property. The url property is the URL of the image. The other properties are optional and are alt text, secure_url link and the width and height of the image.
  • icon: A link to the favicon of the webpage.
  • site_name: The name of the website.
  • type: The type of the webpage. This is usually website or article.
  • locale: The locale of the webpage.
caution

Please note that not all websites allow parsing of their metadata, and the results of the unfurl method are not 100% guaranteed. In some cases, websites may block parsing or provide incomplete or incorrect metadata. Additionally, be mindful of the website's terms of service and any applicable laws or regulations related to web scraping.

Examples

Usage
const metadata = await window.wyng['_WYNG_ID_'].unfurl('https://www.example.com/blog');

console.log(metadata);
Result
  {
"title": "Example Domain",
"description": "This is a very real website description.",
"url": "https://www.example.com/blog",
"canonical_url": "https://blog.example.com",
"images": [
{
"url": "https://www.example.com/images/thumbnail.png",
"alt": "Example thumbnail",
"width": 400,
"height": 200
}
],
"icon": "https://www.example.com/favicon.ico",
"site_name": "Example",
"type": "website",
"locale": "en_US"
}