The Webpage to Icon API converts a URL to an icon. Try this Demo to see it in action. The Webpage to Icon API is not simply a favicon grabber.
But instead bases the final icon on all the available icons for the webpage. If no favicons or meta icons are available it will generate one for the webpage. The chosen icon, the background and any border selected can change depending on the users selections.
To use the API replace the APPLICATION KEY text below with Ihr Anwendungsschlüssel. Then set the size parameter, which defaults to 32.
Finally specify the webpage that you want to turn into an convert. By passing the required URL to the URL parameter. In the following example, we convert https://www.astropioneer.blog/ into a 48x48 pixel image.
//api.grabz.it/services/icon?key=Sign in to view your Application Key&size=48&url=https://www.astropioneer.blog/
Sie sollten die url
parameter at the end of the querystring. This helps in avoiding the need to encode most URLs when using the API.
While you can download the image using a server-side language like PHP. You can also display it directly on a web page or use it in JavaScript as shown below. Remember that when using the API in a webpage. You must add the domain of the webpage to the list of autorisierte Domains.
<img src="//api.grabz.it/services/icon?key=Sign in to view your Application Key&size=48&url=https://www.astropioneer.blog/"/>
<script>
fetch('https://api.grabz.it/services/icon?key=Sign in to view your Application Key&size=48&url=https://www.astropioneer.blog/')
.then(response => response.blob())
.then(blob => {
console.log(blob);
});
</script>
You can also transform an image by selecting the desired transform from the options below. For instance, you can see an example here where the transform makes the resulting image sepia.
//api.grabz.it/services/icon?key=Sign in to view your Application Key&transform=sepia&size=48&url=https://www.astropioneer.blog/
The API accepts the following four parameters.
Name | Beschreibung | Optionen |
---|---|---|
Schlüssel | Ihr Anwendungsschlüssel | Dieser Parameter ist erforderlich um ein Bildsymbol zu erstellen |
URL | Die URL der zu konvertierenden Webseite into ein Bild | Dieser Parameter ist erforderlich to create an image image |
Größe | The size of the resulting square image | So 32 would result in a 32x32px image |
transformieren | The transform to apply to the resulting image. Der Standardwert ist none. |
blackandwhite - create a black and white imagegrayscale - create a grayscale imageinverse - invert the colors of the imagesepia - create a sepia colored image |
Quelle | Definieren Sie die bevorzugte Quelle für Symbole, die in verwendet werden generating the finished image. Der Standardwert ist all. |
all - Verwenden Sie alle Arten von Symbolenfavicon - Verwenden Sie nur Faviconsmetadata - Verwenden Sie nur die Metadatensymbole der Webseite |
The API can return the following error codes.
Code | Beschreibung |
---|---|
100 | Keine URL angegeben |
103 | Fehlender Anwendungsschlüssel |
104 | Nicht erkannter Anwendungsschlüssel |
114 | Size Invalid |
401 | Die Domäne, in der diese API verwendet wird, muss sein zugelassen. |
500 | Ein Upgrade ist erforderlich |