import mql from '@microlink/mql' const { data } = await mql('https://kikobeats.com')
url
required
Type: <string>
The target URL for getting information based on the content.
The url parameter is the only required parameter for any Microlink API request.
URL requirements
The URL provided must be:
- Publicly reachable by the service (no localhost or private IPs)
- Well-formed following the WHATWG URLstandard
- Including protocol (http:// or https://)
If you want to extract content behind a login panel, the URL provided should contain the authentication step as part of the query string, or provide the authentication credentials using headers.
URL encoding
If the URL provided has query string parameters, they should be properly escaped to not interfere with the Microlink API query parameters.
import mql from '@microlink/mql' const { data } = await mql('https://kikobeats.com?ref=microlink')
URLs with query parameters are automatically encoded.
Using MQL or Microlink CLI will escape the URL properly. Otherwise, you need to escape it using
encodeURIComponent
or equivalent.Protocol handling
The protocol matters: If the target URL has relative URLs inside (e.g., images or videos), then the URL provided will be used to resolve relative URLs into absolute.
This means that if you provide HTTPS, then all relative URLs will be resolved under SSL.
Common URL patterns
Here are examples of different URL types you can process:
Standard websites
import mql from '@microlink/mql' const { data } = await mql('https://github.com/microlinkhq')
URLs with fragments
import mql from '@microlink/mql' const { data } = await mql('https://microlink.io/docs/api/getting-started/overview#url-requirements')
Internationalized domain names
import mql from '@microlink/mql' const { data } = await mql('https://例え.jp')
Error handling
If the URL cannot be processed, you'll receive one of these error codes:
- EINVALURL: The URL format is invalid
- EFORBIDDENURL: The URL resolves to a forbidden IP range
- EMAXREDIRECTS: Too many redirects (more than 10 hops)
- ETIMEOUT: The URL took too long to respond
See error codes for the complete list.