{"id":22386,"library":"snowflake-id","title":"Snowflake ID Generator","description":"A Python library for generating Snowflake-like unique IDs, inspired by Twitter's Snowflake ID. Version 1.0.2 supports Python 3.8+ and provides a simple interface for distributed unique ID generation with configurable epoch, worker ID, and sequence. The library is stable but not frequently updated.","status":"active","version":"1.0.2","language":"python","source_language":"en","source_url":"https://github.com/vd2org/snowflake.git","tags":["snowflake","id-generation","distributed","unique-id"],"install":[{"cmd":"pip install snowflake-id","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The module name is 'snowflake', not 'snowflake_id' or 'snowflake_id_generator'.","symbol":"SnowflakeGenerator","correct":"from snowflake import SnowflakeGenerator"}],"quickstart":{"code":"from snowflake import SnowflakeGenerator\n\ngen = SnowflakeGenerator(42)  # instance (worker ID)\nsnowflake_id = next(gen)\nprint(snowflake_id)","lang":"python","description":"Create a generator with a worker ID (0-1023) and generate IDs by calling next()."},"warnings":[{"fix":"Use next(gen) or for id in gen: ...","message":"The SnowflakeGenerator is an iterator; you must call next() or iterate over it. Many users mistakenly call gen.generate() or gen.get_id() which don't exist.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure worker ID is an integer between 0 and 1023.","message":"The worker ID range is 0-1023 (10 bits). Using a value outside this range may cause unexpected behavior or errors. The library does not validate strictly.","severity":"gotcha","affected_versions":"all"},{"fix":"Use NTP or similar time synchronization across workers.","message":"Snowflake IDs are not guaranteed to be strictly increasing across multiple processes with different worker IDs if system clocks are not synchronized. This is by design but can cause confusion.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install snowflake-id, then import: from snowflake import SnowflakeGenerator","cause":"Incorrect import path. The package name on PyPI is 'snowflake-id', but the import module is 'snowflake'.","error":"ImportError: cannot import name 'SnowflakeGenerator' from 'snowflake_id'"},{"fix":"Use next(gen) to get the next ID.","cause":"Trying to call a method like gen.generate() instead of using the iterator protocol.","error":"AttributeError: 'SnowflakeGenerator' object has no attribute 'generate'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}