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.
Getting started
Section titled “Getting started”$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.
What happens on a request
Section titled “What happens on a request”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 SVGThe default TTL is 0: cache forever. That means each icon is fetched exactly once, ever.
Multi-host fallback
Section titled “Multi-host fallback”If the primary API host is down, the provider automatically tries two mirrors in sequence:
https://api.iconify.design(primary)https://api.simplesvg.comhttps://api.unisvg.com
You don’t need to configure this: it happens transparently.
Pre-warming the cache
Section titled “Pre-warming the cache”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:
vendor/bin/swarm-icons cache:warm --prefix=heroicons --icons=home,user,star,settingsYou can also batch-fetch programmatically:
$provider->fetchMany(['home', 'user', 'star', 'settings']);After warming, those icons resolve from cache with zero latency.
Tradeoffs
Section titled “Tradeoffs”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).
Popular sets
Section titled “Popular sets”A few commonly used sets to get you started:
| Prefix | Set | Icons |
|---|---|---|
bi | Bootstrap Icons | 2,000+ |
bx | Boxicons | 1,600+ |
carbon | Carbon Icons | 2,000+ |
fa7-brands | Font Awesome 7 Brands | 586+ |
fa7-regular | Font Awesome 7 Regular | 272+ |
fa7-solid | Font Awesome 7 Solid | 1,999+ |
flowbite | Flowbite Icons | 500+ |
fluent | Fluent UI Icons | 14,000+ |
heroicons | Heroicons | 300+ |
icon-park-outline | IconPark Outline | 2,600+ |
iconoir | Iconoir | 1,600+ |
ion | Ionicons | 1,300+ |
line-md | Material Line Icons | 300+ |
lucide | Lucide | 1,500+ |
mdi | Material Design Icons | 7,000+ |
mingcute | MingCute Icons | 2,800+ |
octicon | GitHub Octicons | 600+ |
ph | Phosphor Icons | 7,000+ |
ri | Remix Icons | 2,800+ |
simple-icons | Simple Icons | 3,000+ |
solar | Solar Icons | 7,500+ |
tabler | Tabler Icons | 5,000+ |
uil | Unicons Line | 1,200+ |
Browse all 200+ sets from the CLI:
vendor/bin/swarm-icons json:browse