{"id":8048,"library":"curies","title":"Idiomatic conversion between URIs and compact URIs (CURIEs)","description":"The `curies` Python package provides efficient, faultless, and idiomatic utilities for converting between Uniform Resource Identifiers (URIs) and Compact URIs (CURIEs). It is a crucial low-level tool for linked data applications, enabling data scientists, curators, and software developers to handle prefix maps, expand CURIEs to URIs, and compress URIs to CURIEs. The library is actively developed, currently at version 0.13.3, with ongoing enhancements for robustness and usability.","status":"active","version":"0.13.3","language":"en","source_language":"en","source_url":"https://github.com/biopragmatics/curies.git","tags":["curie","uri","linked data","semantic web","identifiers","data conversion"],"install":[{"cmd":"pip install curies","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or higher.","package":"python","optional":false}],"imports":[{"note":"Standard import for accessing all top-level functions and classes.","symbol":"curies","correct":"import curies"},{"note":"For direct instantiation of the Converter class, though often created via helper functions.","symbol":"Converter","correct":"from curies import Converter"}],"quickstart":{"code":"import curies\n\n# Option 1: Load a predefined converter (e.g., OBO Foundry)\nconverter = curies.get_obo_converter()\n\n# Option 2: Load a custom prefix map\n# prefix_map = {\"CHEBI\": \"http://purl.obolibrary.org/obo/CHEBI_\"}\n# converter = curies.load_prefix_map(prefix_map)\n\n# Expand a CURIE to a URI\ncurie_example = \"CHEBI:1\"\nexpanded_uri = converter.expand(curie_example)\nprint(f\"Expanded '{curie_example}' to '{expanded_uri}'\")\n# Expected: Expanded 'CHEBI:1' to 'http://purl.obolibrary.org/obo/CHEBI_1'\n\n# Compress a URI to a CURIE\nuri_example = \"http://purl.obolibrary.org/obo/CHEBI_2\"\ncompressed_curie = converter.compress(uri_example)\nprint(f\"Compressed '{uri_example}' to '{compressed_curie}'\")\n# Expected: Compressed 'http://purl.obolibrary.org/obo/CHEBI_2' to 'CHEBI:2'\n","lang":"python","description":"This quickstart demonstrates how to load a predefined CURIE converter and then use it to expand CURIEs to URIs and compress URIs back to CURIEs. Alternatively, you can define and load your own prefix map."},"warnings":[{"fix":"Always review the release notes and changelog when upgrading `curies` to a new minor version to identify any necessary code adjustments.","message":"As a library in the 0.x.x version range, `curies` is not yet considered stable. Breaking changes to the API may occur between minor versions (e.g., from 0.12 to 0.13).","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure that your custom prefix maps are ordered from most specific to least specific, or be aware that the first definition for a prefix/URI prefix pair will take precedence in resolution.","message":"When loading prefix maps, especially with overlapping URI prefixes (e.g., 'http://purl.obolibrary.org/obo/' and 'http://purl.obolibrary.org/obo/CHEBI_'), `curies` prioritizes the first matching prefix encountered. This behavior ensures 'faultless' conversion but may differ from expectations if not explicitly considered.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `import curies` at the top of your Python script or interactive session before using any functions or classes from the library.","cause":"The `curies` module was used without being imported first.","error":"NameError: name 'curies' is not defined"},{"fix":"Verify that your prefix map input is valid, or that the predefined converter could be loaded successfully. Always check that the `converter` object is not `None` before attempting to use its methods.","cause":"A converter object (e.g., returned by `curies.load_prefix_map()` or `curies.get_obo_converter()`) was `None`, indicating that it failed to initialize properly, and subsequently, a method like `compress()` was called on this `None` object.","error":"AttributeError: 'NoneType' object has no attribute 'compress'"}]}