Basic rules definition

For any url provided, Microlink API returns normalized data known as meta:
const mql = require('@microlink/mql')

const { data } = await mql('https://www.meetup.com/Murcia-Frontend')

console.log(data)
These data fields values are extracted from the HTML markup, using Open Graph, JSON+LD, and a series of fallbacks based on DOM selectors.
In the same way these information is extracted, you can define your own data rules, being possible overwrite or extend the default data extracted, creating your own API on top of any website.
A rule is defined by three primitives:
  • A DOM query (selector/selectorAll): It defines the HTML element(s) that will be used for getting the value (e.g., 'img').
  • An attribute (attr): It defines what field over the matched selector should be used for extracting the value (e.g., 'src').
  • A data type (type): It defines how the value extracted should be considered (e.g., 'image').
Combining these primitives, you can get any value present in any website:
const mql = require('@microlink/mql')

const { data } = await mql('https://kikobeats.com', {
  data: {
    avatar: {
      selector: '#avatar',
      type: 'image',
      attr: 'src'
    }
  }
})

console.log(
  `The avatar URL is '${data.avatar.url}' (${data.avatar.size_pretty})`
)