Delivery and embedding
Two delivery models
| When you need | Use | Result |
|---|---|---|
| PDF metadata inside an app or backend workflow | Default JSON response | Read the asset from data.pdf.url |
| A direct PDF response for downloads or previews | embed: 'pdf.url' | The API URL itself returns the PDF file |
JSON plus CDN URL
The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://rauchg.com/2014/7-principles-of-rich-web-applications' URL with 'pdf' & 'meta' API parameters:
CLI Microlink API example
microlink https://rauchg.com/2014/7-principles-of-rich-web-applications&pdfcURL Microlink API example
curl -G "https://api.microlink.io" \
-d "url=https://rauchg.com/2014/7-principles-of-rich-web-applications" \
-d "pdf=true" \
-d "meta=false"JavaScript Microlink API example
import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false
})Python Microlink API example
import requests
url = "https://api.microlink.io/"
querystring = {
"url": "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf": "true",
"meta": "false"
}
response = requests.get(url, params=querystring)
print(response.json())Ruby Microlink API example
require 'uri'
require 'net/http'
base_url = "https://api.microlink.io/"
params = {
url: "https://rauchg.com/2014/7-principles-of-rich-web-applications",
pdf: "true",
meta: "false"
}
uri = URI(base_url)
uri.query = URI.encode_www_form(params)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
response = http.request(request)
puts response.bodyPHP Microlink API example
<?php
$baseUrl = "https://api.microlink.io/";
$params = [
"url" => "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf" => "true",
"meta" => "false"
];
$query = http_build_query($params);
$url = $baseUrl . '?' . $query;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #: " . $err;
} else {
echo $response;
}Golang Microlink API example
package main
import (
"fmt"
"net/http"
"net/url"
"io"
)
func main() {
baseURL := "https://api.microlink.io"
u, err := url.Parse(baseURL)
if err != nil {
panic(err)
}
q := u.Query()
q.Set("url", "https://rauchg.com/2014/7-principles-of-rich-web-applications")
q.Set("pdf", "true")
q.Set("meta", "false")
u.RawQuery = q.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
panic(err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false
})data.pdf.url when your application already expects JSON and wants to keep the response metadata around.Direct PDF with embed
embed: 'pdf.url' to make the API URL return the PDF file itself:The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://rauchg.com/2014/7-principles-of-rich-web-applications' URL with 'pdf', 'meta' & 'embed' API parameters:
CLI Microlink API example
microlink https://rauchg.com/2014/7-principles-of-rich-web-applications&pdf&embed=pdf.urlcURL Microlink API example
curl -G "https://api.microlink.io" \
-d "url=https://rauchg.com/2014/7-principles-of-rich-web-applications" \
-d "pdf=true" \
-d "meta=false" \
-d "embed=pdf.url"JavaScript Microlink API example
import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false,
embed: "pdf.url"
})Python Microlink API example
import requests
url = "https://api.microlink.io/"
querystring = {
"url": "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf": "true",
"meta": "false",
"embed": "pdf.url"
}
response = requests.get(url, params=querystring)
print(response.json())Ruby Microlink API example
require 'uri'
require 'net/http'
base_url = "https://api.microlink.io/"
params = {
url: "https://rauchg.com/2014/7-principles-of-rich-web-applications",
pdf: "true",
meta: "false",
embed: "pdf.url"
}
uri = URI(base_url)
uri.query = URI.encode_www_form(params)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
response = http.request(request)
puts response.bodyPHP Microlink API example
<?php
$baseUrl = "https://api.microlink.io/";
$params = [
"url" => "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf" => "true",
"meta" => "false",
"embed" => "pdf.url"
];
$query = http_build_query($params);
$url = $baseUrl . '?' . $query;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #: " . $err;
} else {
echo $response;
}Golang Microlink API example
package main
import (
"fmt"
"net/http"
"net/url"
"io"
)
func main() {
baseURL := "https://api.microlink.io"
u, err := url.Parse(baseURL)
if err != nil {
panic(err)
}
q := u.Query()
q.Set("url", "https://rauchg.com/2014/7-principles-of-rich-web-applications")
q.Set("pdf", "true")
q.Set("meta", "false")
q.Set("embed", "pdf.url")
u.RawQuery = q.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
panic(err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false,
embed: "pdf.url"
})HTML download links
<a
href="https://api.microlink.io?url=https://rauchg.com/2014/7-principles-of-rich-web-applications&pdf&meta=false&embed=pdf.url"
download="article.pdf"
>
Download PDF
</a>Embedded PDF previews
<iframe> or <embed> element when you want an in-app preview:<iframe
src="https://api.microlink.io?url=https://rauchg.com/2014/7-principles-of-rich-web-applications&pdf&meta=false&embed=pdf.url"
width="100%"
height="800"
title="PDF preview"
></iframe>Markdown and CMS links
[Download the PDF](https://api.microlink.io?url=https://rauchg.com/2014/7-principles-of-rich-web-applications&pdf&meta=false&embed=pdf.url)Delivery with customization
embed. For example, a letter-sized PDF with margins:The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://rauchg.com/2014/7-principles-of-rich-web-applications' URL with 'pdf', 'meta' & 'embed' API parameters:
CLI Microlink API example
microlink https://rauchg.com/2014/7-principles-of-rich-web-applications&pdf.format=Letter&pdf.margin=1cm&embed=pdf.urlcURL Microlink API example
curl -G "https://api.microlink.io" \
-d "url=https://rauchg.com/2014/7-principles-of-rich-web-applications" \
-d "pdf.format=Letter" \
-d "pdf.margin=1cm" \
-d "meta=false" \
-d "embed=pdf.url"JavaScript Microlink API example
import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: {
format: "Letter",
margin: "1cm"
},
meta: false,
embed: "pdf.url"
})Python Microlink API example
import requests
url = "https://api.microlink.io/"
querystring = {
"url": "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf.format": "Letter",
"pdf.margin": "1cm",
"meta": "false",
"embed": "pdf.url"
}
response = requests.get(url, params=querystring)
print(response.json())Ruby Microlink API example
require 'uri'
require 'net/http'
base_url = "https://api.microlink.io/"
params = {
url: "https://rauchg.com/2014/7-principles-of-rich-web-applications",
pdf.format: "Letter",
pdf.margin: "1cm",
meta: "false",
embed: "pdf.url"
}
uri = URI(base_url)
uri.query = URI.encode_www_form(params)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
response = http.request(request)
puts response.bodyPHP Microlink API example
<?php
$baseUrl = "https://api.microlink.io/";
$params = [
"url" => "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf.format" => "Letter",
"pdf.margin" => "1cm",
"meta" => "false",
"embed" => "pdf.url"
];
$query = http_build_query($params);
$url = $baseUrl . '?' . $query;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #: " . $err;
} else {
echo $response;
}Golang Microlink API example
package main
import (
"fmt"
"net/http"
"net/url"
"io"
)
func main() {
baseURL := "https://api.microlink.io"
u, err := url.Parse(baseURL)
if err != nil {
panic(err)
}
q := u.Query()
q.Set("url", "https://rauchg.com/2014/7-principles-of-rich-web-applications")
q.Set("pdf.format", "Letter")
q.Set("pdf.margin", "1cm")
q.Set("meta", "false")
q.Set("embed", "pdf.url")
u.RawQuery = q.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
panic(err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: {
format: "Letter",
margin: "1cm"
},
meta: false,
embed: "pdf.url"
})Filtering JSON responses
pdf field, use filter:The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://rauchg.com/2014/7-principles-of-rich-web-applications' URL with 'pdf', 'meta' & 'filter' API parameters:
CLI Microlink API example
microlink https://rauchg.com/2014/7-principles-of-rich-web-applications&pdf&filter=pdfcURL Microlink API example
curl -G "https://api.microlink.io" \
-d "url=https://rauchg.com/2014/7-principles-of-rich-web-applications" \
-d "pdf=true" \
-d "meta=false" \
-d "filter=pdf"JavaScript Microlink API example
import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false,
filter: "pdf"
})Python Microlink API example
import requests
url = "https://api.microlink.io/"
querystring = {
"url": "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf": "true",
"meta": "false",
"filter": "pdf"
}
response = requests.get(url, params=querystring)
print(response.json())Ruby Microlink API example
require 'uri'
require 'net/http'
base_url = "https://api.microlink.io/"
params = {
url: "https://rauchg.com/2014/7-principles-of-rich-web-applications",
pdf: "true",
meta: "false",
filter: "pdf"
}
uri = URI(base_url)
uri.query = URI.encode_www_form(params)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
response = http.request(request)
puts response.bodyPHP Microlink API example
<?php
$baseUrl = "https://api.microlink.io/";
$params = [
"url" => "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf" => "true",
"meta" => "false",
"filter" => "pdf"
];
$query = http_build_query($params);
$url = $baseUrl . '?' . $query;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #: " . $err;
} else {
echo $response;
}Golang Microlink API example
package main
import (
"fmt"
"net/http"
"net/url"
"io"
)
func main() {
baseURL := "https://api.microlink.io"
u, err := url.Parse(baseURL)
if err != nil {
panic(err)
}
q := u.Query()
q.Set("url", "https://rauchg.com/2014/7-principles-of-rich-web-applications")
q.Set("pdf", "true")
q.Set("meta", "false")
q.Set("filter", "pdf")
u.RawQuery = q.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
panic(err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false,
filter: "pdf"
})pdf field. This is useful for JSON workflows, but unnecessary when you already use embed.Custom filename PRO
filename when the generated asset needs a readable, user-facing name:The following examples show how to use the Microlink API with CLI, cURL, JavaScript, Python, Ruby, PHP & Golang, targeting 'https://rauchg.com/2014/7-principles-of-rich-web-applications' URL with 'pdf', 'meta' & 'filename' API parameters:
CLI Microlink API example
microlink https://rauchg.com/2014/7-principles-of-rich-web-applications&pdf&filename=rich-web-applicationscURL Microlink API example
curl -G "https://api.microlink.io" \
-d "url=https://rauchg.com/2014/7-principles-of-rich-web-applications" \
-d "pdf=true" \
-d "meta=false" \
-d "filename=rich-web-applications"JavaScript Microlink API example
import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false,
filename: "rich-web-applications"
})Python Microlink API example
import requests
url = "https://api.microlink.io/"
querystring = {
"url": "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf": "true",
"meta": "false",
"filename": "rich-web-applications"
}
response = requests.get(url, params=querystring)
print(response.json())Ruby Microlink API example
require 'uri'
require 'net/http'
base_url = "https://api.microlink.io/"
params = {
url: "https://rauchg.com/2014/7-principles-of-rich-web-applications",
pdf: "true",
meta: "false",
filename: "rich-web-applications"
}
uri = URI(base_url)
uri.query = URI.encode_www_form(params)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
response = http.request(request)
puts response.bodyPHP Microlink API example
<?php
$baseUrl = "https://api.microlink.io/";
$params = [
"url" => "https://rauchg.com/2014/7-principles-of-rich-web-applications",
"pdf" => "true",
"meta" => "false",
"filename" => "rich-web-applications"
];
$query = http_build_query($params);
$url = $baseUrl . '?' . $query;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #: " . $err;
} else {
echo $response;
}Golang Microlink API example
package main
import (
"fmt"
"net/http"
"net/url"
"io"
)
func main() {
baseURL := "https://api.microlink.io"
u, err := url.Parse(baseURL)
if err != nil {
panic(err)
}
q := u.Query()
q.Set("url", "https://rauchg.com/2014/7-principles-of-rich-web-applications")
q.Set("pdf", "true")
q.Set("meta", "false")
q.Set("filename", "rich-web-applications")
u.RawQuery = q.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
panic(err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}import mql from '@microlink/mql'
const { data } = await mql('https://rauchg.com/2014/7-principles-of-rich-web-applications', {
pdf: true,
meta: false,
filename: "rich-web-applications"
})Security considerations
- Use @microlink/proxyfor self-hosted protection.
- Use @microlink/edge-proxyfor edge-deployed protection.