Generate Link Preview API

ApyHub
ApyHub
verified icon
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

link preview
POST
https://api.apyhub.com/extract/url/preview

Request example

1
curl --location --request POST 'https://api.apyhub.com/extract/url/preview' \
2
--header 'apy-token: {{token}}' \
3
--header 'Content-Type: application/json' \
4
--data '{
5
"url": "https://apyhub.com"
6
}'
Method: POST
Content Type: application/json
Request Body
ParameterTypeMandatoryDescription
urlStringYesThe URL of the webpage
images_property_type“og” or “twitter”NoFetches images only with the specific property
user_agentStringNoThe User-Agent header value of the HTTP request. (ex: user_agent: "google-bot")
accept_languageStringNoThe Accept-Language header value of the HTTP request. (ex: accept_language: "en-US")
allow_redirectsBooleanNo (defaults to false)Allow redirects (max 1), e.g. https://google.com/https://www.google.com/
secure_modeBooleanNo (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
AttributeTypeDescription
urlStringThe URL of the webpage.
titleStringThe title of the webpage.
siteNameStringThe name of the website.
descriptionStringThe description of the webpage.
mediaTypeStringThe media type of the webpage.
contentTypeStringThe content type of the webpage.
imagesArray of StringsThe URLs of the images associated with the webpage.
videosArray of StringsThe URLs of the videos associated with the webpage.
faviconsArray of StringsThe URLs of the favicons associated with the webpage.
reported_maliciousBooleanA 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
1
{
2
"data": {
3
"url": "https://apyhub.com/",
4
"title": "ApyHub: The Developer API Utility Belt",
5
"siteName": "ApyHub",
6
"description": "Powerful yet simple-to-use APIs that provide standard data & essential functionalities, helping developers save time and boost efficiency.",
7
"mediaType": "website",
8
"contentType": "text/html",
9
"images": [
10
"https://apyhub.com/meta-apyhub.png"
11
],
12
"videos": [],
13
"favicons": [
14
"https://apyhub.com/favicons/favicon-32x32.png",
15
"https://apyhub.com/favicons/favicon-16x16.png",
16
"https://apyhub.com/favicons/favicon.ico",
17
"https://apyhub.com/favicons/apple-touch-icon.png"
18
]
19
}
20
}
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
1
{
2
"data": {
3
"reported_malicious": true,
4
"url": "http://MALICIOUS_WEBSITE.com/uo1x/malware.exe",
5
"threat": "malware_download"
6
}
7
}

HTTP Response Codes

The method may return one of the following HTTP status codes:
Status CodeDescription
200The request was successful.
400The request was invalid or could not be understood by the server.
401Required authentication information is either missing or not valid for the resource.
408The server timed out waiting for the request. (5000ms)
500If 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

1
{
2
"error": {
3
"code": 105,
4
"message": "Invalid URL"
5
}
6
}
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
AboutAPI PlaygroundAPI DocumentationAuthenticationError codesRelated Utility APIsRelated Articles