pyconify

0.2.1 · active · verified Thu Apr 16

pyconify is a Python wrapper for the universal Iconify API, providing access to over 100 icon sets and more than 100,000 icons from popular collections like FontAwesome and Material Design Icons. It allows fetching icon data, SVGs, and CSS, and includes caching for faster retrieval. The library is actively maintained, with its current version being 0.2.1, and receives irregular but ongoing updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import `pyconify`, search for icons, retrieve SVG data for a specific icon, and get the local file path for a cached SVG. It also highlights the caching mechanism and how to configure or clear it.

import pyconify
import os

# Note: pyconify makes network requests to fetch icon data.
# Initial fetches require internet access. Data is then cached.

# Get info on available collections (requires network access initially)
# collections = pyconify.collections()
# print(f"Available collections: {list(collections.keys())[:5]}...")

# Search for icons (e.g., 'python')
hits = pyconify.search("python")
if hits:
    print(f"Found {len(hits)} icons for 'python'. First one: {hits[0]['icon']}")
    # Get SVG for a specific icon (e.g., 'fa-brands:python')
    icon_name = 'fa-brands:python'
    svg_data = pyconify.svg(icon_name)
    print(f"SVG for {icon_name} (first 100 chars):\n{svg_data[:100]}...")

    # Get path to cached SVG on disk
    # This will either return a path to an existing cached file or write to a temp file.
    svg_file_path = pyconify.svg_path(icon_name)
    print(f"SVG file path for {icon_name}: {svg_file_path}")

    # You can configure the cache directory using an environment variable
    # os.environ['PYCONIFY_CACHE'] = '/path/to/custom/cache'
    # To disable caching:
    # os.environ['PYCONIFY_CACHE'] = '0'

# Example of clearing the cache
# pyconify.clear_cache()
# print("Cache cleared.")

view raw JSON →