{"id":23173,"library":"stix","title":"stix - STIX Content API","description":"An API for parsing and generating Structured Threat Information Expression (STIX) content. Current version 1.2.0.11 is legacy, based on the older STIX 1.x standard; development has been superseded by stix2 for STIX 2.x. Low release cadence.","status":"maintenance","version":"1.2.0.11","language":"python","source_language":"en","source_url":"https://github.com/STIXProject/python-stix","tags":["stix","cyber threat intelligence","cti","xml","threat intelligence"],"install":[{"cmd":"pip install stix","lang":"bash","label":"Install stix from PyPI"}],"dependencies":[{"reason":"XML parsing and generation for STIX content","package":"lxml","optional":false},{"reason":"Date/time parsing","package":"python-dateutil","optional":false},{"reason":"CybOX objects used within STIX","package":"cybox","optional":true}],"imports":[{"note":"STIXPackage is in stix.core, not top-level stix","wrong":"import stix; stix.STIXPackage","symbol":"STIXPackage","correct":"from stix.core import STIXPackage"},{"symbol":"Indicator","correct":"from stix.indicator import Indicator"},{"symbol":"parse_xml","correct":"from stix.utils import parse_xml"}],"quickstart":{"code":"from stix.core import STIXPackage\nfrom stix.utils import parse_xml\nimport os\n\nstix_xml = os.environ.get('STIX_XML', '<stix:STIXPackage xmlns:stix=\"http://stix.mitre.org/stix-1\" id=\"example:package-1\"><stix:STIX_Header><stix:Title>Example</stix:Title></stix:STIX_Header></stix:STIXPackage>')\npackage = parse_xml(stix_xml)\nprint(package.stix_header.title)","lang":"python","description":"Parse a STIX 1.x XML document and access the package title."},"warnings":[{"fix":"Install stix2 (`pip install stix2`) and import from stix2.","message":"stix library is for STIX 1.x only. For STIX 2.x, use the stix2 library. Using stix with STIX 2.x XML will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to the stix2 library for STIX 2.x compatibility.","message":"The stix library is no longer actively developed. New features and STIX 2.x support are only in stix2.","severity":"deprecated","affected_versions":">=1.2"},{"fix":"with open('file.xml', 'r') as f: package = parse_xml(f.read())","message":"parse_xml() expects a string, not a file path. Use open().read() or handle file reading separately.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from stix.core import STIXPackage","cause":"STIXPackage is located in stix.core, not top-level stix.","error":"ImportError: cannot import name 'STIXPackage' from 'stix'"},{"fix":"Ensure the XML string is well-formed STIX 1.x. Print the XML before parsing.","cause":"parse_xml returned None because the XML was empty or invalid.","error":"AttributeError: 'NoneType' object has no attribute 'title'"},{"fix":"Validate the XML using an XML validator.","cause":"Input XML is malformed or not XML.","error":"lxml.etree.XMLSyntaxError: ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}