Generate Link Preview API
ApyHub
50 atoms
Base tier
About
This Utility API fetches metadata from any URL passed to it, including Open Graph tags.
The API returns relevant information such as title, description, image, and more, in JSON format. The API can be used to enrich content, generate link previews, or provide social media sharing functionality. By using this API, you can show previews of a webpage when urls are shared within your applications which can improve the effectiveness of communication by providing users with a more informative and engaging experience.
Additionally, our API has a built-in feature that checks whether the link has been reported as malicious. This helps to ensure the safety and security of your users when using our API to fetch metadata from URLs.
Try out the API in the API playground for free and see how this li nk preview API can help you generate url previews quickly, improve link sharing capabilities and enhance security with a simple API call.
API Playground
API Documentation
link preview
POST
https://api.apyhub.com/extract/url/preview
Request example
Method:
POST
Content Type:
application/json
Request Body
Parameter | Type | Mandatory | Description |
---|---|---|---|
url | String | Yes | The URL of the webpage |
images_property_type | “og” or “twitter” | No | Fetches images only with the specific property |
user_agent | String | No | The User-Agent header value of the HTTP request. (ex: user_agent: "google-bot") |
accept_language | String | No | The Accept-Language header value of the HTTP request. (ex: accept_language: "en-US") |
allow_redirects | Boolean | No (defaults to false) | Allow redirects (max 1), e.g. https://google.com/ → https://www.google.com/ |
secure_mode | Boolean | No (defaults to true) | When enabled (by default), the API checks if the URL is reported as malicious, returning the threat as a string if found. Recommended for user safety. |
For more information on
user_agent
value and accept_language
value, you can refer to the following resources:Response
Attribute | Type | Description |
---|---|---|
url | String | The URL of the webpage. |
title | String | The title of the webpage. |
siteName | String | The name of the website. |
description | String | The description of the webpage. |
mediaType | String | The media type of the webpage. |
contentType | String | The content type of the webpage. |
images | Array of Strings | The URLs of the images associated with the webpage. |
videos | Array of Strings | The URLs of the videos associated with the webpage. |
favicons | Array of Strings | The URLs of the favicons associated with the webpage. |
reported_malicious | Boolean | A boolean indicating whether the URL has been reported as malicious. This attribute is only included if the secure_mode parameter is set to true . |
Sample Response 1
If the
secure_mode
parameter is set to true
and the URL has been reported as malicious, the API will not fetch any link-preview metadata. Instead, it will return a JSON object with the reported_malicious
boolean set to "true" and the "threat" attribute indicating the type of threat associated with the URL.Sample Response 2
HTTP Response Codes
The method may return one of the following HTTP status codes:
Status Code | Description |
---|---|
200 | The request was successful. |
400 | The request was invalid or could not be understood by the server. |
401 | Required authentication information is either missing or not valid for the resource. |
408 | The server timed out waiting for the request. (5000ms) |
500 | If any unexpected error occurs while processing the request. |
Authentication
All API requests to ApyHub services need to be authenticated. Currently we support
tokens
or basic authentication
mechanisms.
You can generate and view your existing credentials from your workspace settings (on the left side of the navbar) and go to “API Keys".Points to note:
- Credential secrets are generated on the fly and are not stored in plain text, so on generating a credential please save the secrets somewhere safe.
- Use the
apy-token
as the header parameter to pass the token. - Use the
Authorization
header to send the basic authentication credentials.
Error codes
To search for a specific error code, enter the code in the search box below. Alternatively, you can click on the button to view a complete list of all error codes.
Table of contents