Registry / data / currency-symbols

currency-symbols

JSON →
library2.0.4pypypi✓ verified 85d ago

A tiny Python library (version 2.0.4) that provides currency symbols by their ISO 4217 currency codes. It's actively maintained with a focus on simple lookups and no external dependencies, making it suitable for applications needing quick access to currency symbols.

pip install currency-symbols
INSTALL
IMPORT
SIG · CURRENCY-SYMBOLS
C
currency-symbols
datapythonv2.0.4
Install
1.5s avg
Import
11ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.012s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.007s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CurrencySymbols
from currency_symbols import CurrencySymbols
import currency_symbols; currency_symbols.get_symbol('USD')
Prior to v1.0.0, the import or access pattern for the main functionality might have been different, possibly via a top-level function or direct module import. The current API requires importing the `CurrencySymbols` class.

This example demonstrates how to import the `CurrencySymbols` class and use its `get_symbol` method to retrieve the Unicode symbol for a given ISO 4217 currency code. It also shows the behavior for an unknown currency code.

from currency_symbols import CurrencySymbols dollar_symbol = CurrencySymbols.get_symbol('USD') euro_symbol = CurrencySymbols.get_symbol('EUR') print(f"USD: {dollar_symbol}") print(f"EUR: {euro_symbol}") # Handling an invalid currency code invalid_symbol = CurrencySymbols.get_symbol('XXX') print(f"XXX: {invalid_symbol} (Expected None for invalid code)")
Debug
Known issues
breakingVersion 1.0.0 (released August 2021) introduced a breaking change by switching from a default export to a named export. For Python users, this means ensuring you explicitly import the `CurrencySymbols` class (`from currency_symbols import CurrencySymbols`) rather than relying on previous module-level access patterns.
fix
Update your import statements to `from currency_symbols import CurrencySymbols` and access symbols via `CurrencySymbols.get_symbol('CODE')`.
affects: Before 1.0.0
gotchaThis library is designed solely to retrieve the Unicode symbol for a given currency code. It does NOT provide functionality for currency formatting (e.g., adding thousands separators, decimal precision, locale-specific symbol placement), currency conversion, or exchange rates. For such features, consider libraries like `locale`, `Babel`, or `forex-python`.
fix
Use specialized libraries for formatting (`locale`, `Babel`) or conversion (`forex-python`) if you need more than just the raw currency symbol.
affects: All versions
gotchaThe project's GitHub README contains usage examples for both Python and JavaScript. Always ensure you are following the Python-specific examples and import patterns to avoid confusion, which consistently use `from currency_symbols import CurrencySymbols`.
fix
Refer to the Python-specific usage examples on the PyPI page or within the Python code itself, or carefully distinguish between Python and JavaScript examples in the GitHub README.
affects: All versions
gotchaWhen an invalid or unknown currency code is provided to `CurrencySymbols.get_symbol()`, the method returns `None`. Your application code should handle this `None` return value gracefully to prevent errors.
fix
Add checks for `None` when calling `CurrencySymbols.get_symbol()` (e.g., `if symbol is not None: ... else: handle_missing_symbol()`).
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'currency-symbols'
Python uses underscores (`_`) for module names when importing, even if the package name on PyPI or when installed via pip uses hyphens (`-`).
fix
Use an underscore in the import statement: `from currency_symbols import CurrencySymbols`
KeyError: 'XXX' (where 'XXX' is a currency code)
This error occurs when you call `CurrencySymbols.get_symbol()` with an ISO 4217 currency code that is not present in the library's internal data, or if there is a typo in the currency code.
fix
Verify the ISO 4217 currency code for accuracy. The library's `CurrencySymbols.get_symbol()` method expects a valid, supported three-letter code. If uncertain, you can check for the key's existence before attempting to retrieve it: 
```python
from currency_symbols import CurrencySymbols

currency_code = 'XYZ' # Example of an unsupported code
try:
    symbol = CurrencySymbols.get_symbol(currency_code)
    print(f"Symbol for {currency_code}: {symbol}")
except KeyError:
    print(f"Error: Currency code '{currency_code}' not found or supported.")
```
Currency symbols displaying as '?' or square boxes in output
This is not an error from the `currency-symbols` library itself, but an environment issue. Your terminal, IDE console, or the font being used does not fully support or is not configured to correctly render the Unicode currency symbols provided by the library.
fix
Ensure your terminal, IDE, or environment is configured to use UTF-8 encoding and a font that includes a comprehensive set of Unicode glyphs for currency symbols (e.g., 'Consolas', 'DejaVu Sans Mono', 'Noto Color Emoji' for more exotic symbols). This often involves setting the locale or terminal font preferences.
Upgrade
Version history
2.0.4latest on PyPI · released May 16, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
42 hits · last 30 days
node
36
Bingbot
1
Perplexity
1
Resources
currency-symbols — pip install currency-symbols · libregistry