{"id":21029,"library":"censys","title":"Censys Python SDK","description":"An easy-to-use and lightweight API wrapper for Censys APIs (censys.io). Current version 2.2.19, supports Python 3.8+. Released roughly monthly.","status":"active","version":"2.2.19","language":"python","source_language":"en","source_url":"https://github.com/censys/censys-python","tags":["censys","api","security","network","threat-intelligence"],"install":[{"cmd":"pip install censys","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP client for API calls","package":"requests","optional":false}],"imports":[{"note":"CensysAsm is in the censys.asm submodule, not top-level.","wrong":"from censys import CensysAsm","symbol":"CensysAsm","correct":"from censys.asm import CensysAsm"},{"note":"CensysSearch is in the censys.search submodule.","wrong":"from censys import CensysSearch","symbol":"CensysSearch","correct":"from censys.search import CensysSearch"},{"note":"CensysCertificates is in the censys.certificates submodule. Deprecated in v2.2.18.","wrong":"from censys import CensysCertificates","symbol":"CensysCertificates","correct":"from censys.certificates import CensysCertificates"},{"note":"CensysIPv4 is in the censys.ipv4 submodule. Deprecated in v2.2.18.","wrong":"from censys import CensysIPv4","symbol":"CensysIPv4","correct":"from censys.ipv4 import CensysIPv4"}],"quickstart":{"code":"from censys.search import CensysSearch\nfrom censys.asm import CensysAsm\n\n# Initialize with credentials (set via env or directly)\napi_id = os.environ.get('CENSYS_API_ID', '')\napi_secret = os.environ.get('CENSYS_API_SECRET', '')\nc = CensysSearch(api_id=api_id, api_secret=api_secret)\n\n# Search for hosts\nresults = c.hosts.search(\"services.service_name: HTTP\", per_page=1)\nfor host in results():\n    print(host)\n\n# Use ASM\nasm = CensysAsm(api_id=api_id, api_secret=api_secret)\nseeds = asm.seeds.list()\nprint(seeds)","lang":"python","description":"Initialize CensysSearch and CensysAsm with credentials and perform basic queries."},"warnings":[{"fix":"Replace imports: from censys.certificates import CensysCertificates → from censys.search import CensysSearch. See migration guide.","message":"The v1 Search API (CensysCertificates, CensysIPv4) is deprecated since v2.2.18. Use the v2 Search API (CensysSearch) instead.","severity":"deprecated","affected_versions":">=2.2.18"},{"fix":"Use 'from censys.asm import CensysAsm' instead of 'from censys.asm.asm import CensysAsm'.","message":"The CensysAsm class moved from censys.asm.asm to censys.asm in v2.2.x. Old import path breaks.","severity":"breaking","affected_versions":">=2.2.0"},{"fix":"Always set API_ID and API_SECRET before creating any client.","message":"Credentials must be set via environment variables (CENSYS_API_ID, CENSYS_API_SECRET) or passed directly. If both are missing, initialization fails silently.","severity":"gotcha","affected_versions":"all"},{"fix":"Always iterate over results: for result in search_results(): ...","message":"Search results are lazy and require iteration. The search() method returns a generator; if you don't iterate, no API call is made.","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":"Change import to: from censys.asm import CensysAsm","cause":"Import path changed in v2.2.x; the old subpackage was flattened.","error":"ModuleNotFoundError: No module named 'censys.asm.asm'"},{"fix":"Set CENSYS_API_ID and CENSYS_API_SECRET environment variables correctly, or pass api_id and api_secret to the constructor.","cause":"Invalid or missing API credentials.","error":"censys.exceptions.CensysUnauthorizedException: Unauthorized"},{"fix":"Call the object: results = c.hosts.search(...); for host in results(): ...","cause":"Trying to iterate over the SearchResult object directly instead of calling it.","error":"TypeError: 'SearchResult' object is not iterable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}