Skip to content

Using the Iconify API

Don’t want to download anything? The Iconify API provider gives you access to 200,000+ icons across 200+ sets: just register a prefix and start rendering. Icons are fetched over HTTP on first use and cached locally from that point on.

$manager = SwarmIconsConfig::create()
->addIconifySet('heroicons')
->addIconifySet('tabler')
->cachePath(__DIR__ . '/cache/icons')
->build();
echo $manager->get('heroicons:home');
echo $manager->get('tabler:star');

No downloads, no JSON files, no manifest. The tradeoff is that your app needs internet access the first time it encounters each icon.

The first time you render an icon, the provider checks the cache. On a miss, it makes a single HTTP request to the Iconify API, builds the Icon object, stores it in cache, and returns it. Every request after that resolves from disk:

swarm_icon('heroicons:home')
→ cache hit? → return immediately
→ cache miss? → GET api.iconify.design/heroicons.json?icons=home
→ cache the result
→ return SVG

The default TTL is 0: cache forever. That means each icon is fetched exactly once, ever.

If the primary API host is down, the provider automatically tries two mirrors in sequence:

  1. https://api.iconify.design (primary)
  2. https://api.simplesvg.com
  3. https://api.unisvg.com

You don’t need to configure this: it happens transparently.

If you’d rather avoid runtime HTTP entirely, you can pre-fetch icons during deployment. The cache:warm command batches everything into a single request:

Terminal window
vendor/bin/swarm-icons cache:warm --prefix=heroicons --icons=home,user,star,settings

You can also batch-fetch programmatically:

$provider->fetchMany(['home', 'user', 'star', 'settings']);

After warming, those icons resolve from cache with zero latency.

This provider is ideal for prototyping and development: you get instant access to any Iconify set with no setup. But there are limits to be aware of:

  • The first request for each icon has HTTP latency
  • Your app needs internet access (at least on first use, unless you pre-warm)
  • all() returns an empty array: the API has no list endpoint

For production, JSON Collections are usually the better fit. You can also combine both with a Hybrid Provider (local files first, API as a safety net).

A few commonly used sets to get you started:

PrefixSetIcons
biBootstrap Icons2,000+
bxBoxicons1,600+
carbonCarbon Icons2,000+
fa7-brandsFont Awesome 7 Brands586+
fa7-regularFont Awesome 7 Regular272+
fa7-solidFont Awesome 7 Solid1,999+
flowbiteFlowbite Icons500+
fluentFluent UI Icons14,000+
heroiconsHeroicons300+
icon-park-outlineIconPark Outline2,600+
iconoirIconoir1,600+
ionIonicons1,300+
line-mdMaterial Line Icons300+
lucideLucide1,500+
mdiMaterial Design Icons7,000+
mingcuteMingCute Icons2,800+
octiconGitHub Octicons600+
phPhosphor Icons7,000+
riRemix Icons2,800+
simple-iconsSimple Icons3,000+
solarSolar Icons7,500+
tablerTabler Icons5,000+
uilUnicons Line1,200+

Browse all 200+ sets from the CLI:

Terminal window
vendor/bin/swarm-icons json:browse