How to Use the Icons8 Public API
If you’re looking for a quick and easy way to access thousands of high-quality icons for your projects, look no further than the Icons8 Public API!
Here’s everything you need to know to get started:
Overview of the Icons8 Public API
The Icons8 Public API provides a simple way to access all the icons on the Icons8 website from your own application. You can retrieve icons by searching for specific keywords, browsing categories, or even generating custom icons on-the-fly.
Here’s a quick rundown of the available endpoints:
GET /icons/search
- Search for icons by keywordGET /icons/:category
- Get a list of icons in a specific categoryGET /icons/:category/:id
- Get details for a specific iconGET /icons/for/:platform
- Get a list of icons for a specific platform (e.g. iOS, Android, Windows)
Example Code in JavaScript
Using the Icons8 Public API is easy with JavaScript code. Here are some examples to get you started:
Searching for Icons
const apiUrl = 'https://api.icons8.com/api/iconsets/v4/';
const apiKey = 'YOUR_API_KEY_HERE';
const query = 'cat';
fetch(apiUrl + 'icons/search?term=' + query + '&token=' + apiKey)
.then((response) => response.json())
.then((data) => console.log(data.icons));
Getting a List of Icons by Category
const apiUrl = 'https://api.icons8.com/api/iconsets/v4/';
const apiKey = 'YOUR_API_KEY_HERE';
const category = 'animals';
fetch(apiUrl + 'icons/' + category + '?token=' + apiKey)
.then((response) => response.json())
.then((data) => console.log(data.icons));
Getting Details for a Specific Icon
const apiUrl = 'https://api.icons8.com/api/iconsets/v4/';
const apiKey = 'YOUR_API_KEY_HERE';
const category = 'animals';
const iconId = 'dog';
fetch(apiUrl + 'icons/' + category + '/' + iconId + '?token=' + apiKey)
.then((response) => response.json())
.then((data) => console.log(data.icon));
Getting Icons for a Specific Platform
const apiUrl = 'https://api.icons8.com/api/iconsets/v4/';
const apiKey = 'YOUR_API_KEY_HERE';
const platform = 'ios';
fetch(apiUrl + 'icons/for/' + platform + '?token=' + apiKey)
.then((response) => response.json())
.then((data) => console.log(data.icons));
Conclusion
That’s it! With just a few lines of code, you can easily access thousands of high-quality icons with the Icons8 Public API. Happy coding!