Link

Parses the provided the URL and retrieves the metadata object of the URL. The response time, and validity of the metadata depends on the requested URL. If you have questions regarding the metadata provided please refer to our FAQ's or message us.

End Point

GET /api/link/retrieve_url/:url
Attributes

Host (array)
Array of strings containing www, site name, and top level domain (TLD).
iEmbed (object)
As of now only contains an iFrame object which is a encoded string of html entities of the iFrame HTML tag.
Metadata (object)
Metadata of the provided URL.
  • Description (string)
    URL's meta description.
  • alt_Description (string)
    URL's meta alternative description fetched from the provided URL.
  • host (string)
    URL's host provided using (host).
  • favicon (string)
    Providing the URL's favicon. As on now a 16x16 size.
  • image (string)
    URL's image if any given.
  • is_safe (boolean) in beta
    Determines if the provided URL is safe (In beta).
  • token (string)
    Token to refetch the URL iFrame without having to access the API. Store this token in your database and connect using the URL https://mylinkpreview.com/embed/token/{token}
  • title (string)
    Provided URL's title.
  • url (string)
    Provided URL to the API URL parameter.
Status (string)
Check to see if response was okay by comparing to "success".
Limit (string)
The limit for your API key.
Link Object

{
    "host": [
        "www",
        "indiehackers",
        "com"
    ],
    "iembed": {
        "iframe": "<iframe class="lp-iframe-object" width="100%" frameborder="0" scrolling="no" allowtransparency="true" src="https:\/\/mylinkpreview.com\/embed\/token\/ivrjl8l7" style="max-width: 720px!important;">Woops, MyLinkPreview iFrame failed to load.<\/iframe>"
    },
    "metadata": {
        "description": "4 After spending several weeks on building mylinkpreview.com (ReSTful API for requesting link previews) we've finally launched a MVP. We are thrilled to see what you guys think of some of our features, such as: is URL safe (beta), embedding a fully responsive link preview on any website\/app and the design of the previews. Hey this is awesome! Would love to pick your brain on your experience getting this off the ground! As of now I am simply posting about mylinkpreview around websites like indiehackers, reddit and product hunt to see what people think of the product. This way I can make modification to MVP and then start contacting clients (websites) to see if they will be willing to give us a try. If you have any thoughts, or comments I look forward to hearing them. Congrats Thanks. Learn from the founders behind hundreds of profitable online businesses, and connect with others who are starting and growing their own companies.  ",
        "alt_description": "After spending several weeks on building mylinkpreview.com (ReSTful API for requesting link previews) we've finally launched a MVP. We are thrilled to s...",
        "host": "Indiehackers.com",
        "favicon": "https:\/\/mylinkpreview.com\/assets\/uploads\/favicon\/indiehackersCOM.png",
        "image": "https:\/\/mylinkpreview.com\/assets\/uploads\/images\/ivrjl8l7.png",
        "is_safe": 1,
        "token": "ivrjl8l7",
        "title": "Launched a Link Preview API",
        "url": "https:\/\/www.indiehackers.com\/post\/launched-a-link-preview-api-063ca765f3"
    },
    "status": "success",
    "limit": "60\/hr"
}

Retrieve URL

Provide a URL to obtain the link object.

Parameters

key (required)
Your requested API key.
url (required)
A valid URL to fetch the link object for.
format (optional)
As of now JSON is the only format allowed. It might change in the future.
https://mylinkpreview.com/api/link/retrieve_url?key=123&url=https://www.indiehackers.com/post/launched-a-link-preview-api-063ca765f3
                                                            $url = urlencode("https://www.indiehackers.com/post/launched-a-link-preview-api-063ca765f3");
                                                            $key = "123";
                                                            try {
                                                            $response = file_get_contents("https://mylinkpreview.com/api/link/retrieve_url?key=$key&url=$url");
                                                            print_r(json_decode($response));
                                                            } catch (Exception $e) {
                                                            echo 'Caught exception: ',  $e->getMessage(), "\n";
                                                            }
                                                        

Embedding into website

To place the iFrame object onto the website simply decode the html entities and place the iFrame anywhere on your page.

Required Libraries

iFrame Resizer (required)
iFrame Resizer github repository.
iFrame Resizer Content Window (required)
iFrame Resizer Content Window github repository.

Note
Our iFrame is fully responsive, but in order to take advantage of that we require the iFrame resizer library. Simply follow the code on the right to embed the scripts, along with the iFrame to make the frame fully responsive on all platforms.

Code

                                                    <head>
                                                    
                                                    <!-- 1. Requied iFrame resizing lib -->
                                                    <script src="path_to_script/iframeResizer.min.js"></script>
                                                    <script src="path_to_script/iframeResizer.contentWindow.min.js"></script> 
                                                    
                                                    <head>
                                                    <body>
                                                    
                                                    <!-- 2. Fetch iFrame from API -->
                                                    <iframe class="lp-iframe-object" width="100%" frameborder="0" scrolling="no" allowtransparency="true" src="https://mylinkpreview.com/embed/token/ivrjl8l7" style="max-width: 720px!important;">Woops, MyLinkPreview iFrame failed to load.</iframe>
                                                    
                                                    <!-- 3. iFrame resize for responsive behaviour -->
                                                    <script>
                                                    iFrameResize({ log: true, autoResize: true}, '.lp-iframe-object');
                                                    </script>