| 1 |
# Censys Python Library |
| 2 |
|
| 3 |
[](https://pypi.org/project/censys/) |
| 4 |
[](https://www.python.org/downloads/) |
| 5 |
[](https://censys-python.readthedocs.io/en/stable/?badge=stable) |
| 6 |
[](https://github.com/censys/censys-python/discussions) |
| 7 |
[](http://makeapullrequest.com) |
| 8 |
[](https://github.com/censys/censys-python/blob/main/LICENSE) |
| 9 |
|
| 10 |
> [!WARNING] |
| 11 |
> **DEPRECATION NOTICE**: The Censys Search v1 and v2 APIs will be deprecated soon. Please migrate to the new **Censys Platform**. |
| 12 |
> |
| 13 |
> - 📖 **New API Documentation**: [https://docs.censys.com/reference/get-started#/](https://docs.censys.com/reference/get-started#/) |
| 14 |
> - 📦 **New Python SDK**: Install with `pip install censys-platform` - [https://pypi.org/project/censys-platform/](https://pypi.org/project/censys-platform/) |
| 15 |
> - 🖥️ **New CLI Tool** (`cencli`): [https://docs.censys.com/docs/platform-cli](https://docs.censys.com/docs/platform-cli) |
| 16 |
> - ⚠️ **If you plan to use the new CLI, you will need to uninstall this package's CLI first** as both use the `censys` command name |
| 17 |
> |
| 18 |
> The **Censys ASM APIs in this library are NOT deprecated** and will continue to be supported. |
| 19 |
|
| 20 |
An easy-to-use and lightweight API wrapper for Censys APIs ([censys.io](https://censys.io/)). Python 3.9+ is currently supported. This library has been tested on Python 3.9 and 3.x (Currently version 3.13). |
| 21 |
|
| 22 |
## Features |
| 23 |
|
| 24 |
- [Search Censys data](https://censys-python.readthedocs.io/en/stable/usage-v2.html) |
| 25 |
- [Bulk Certificate lookups](https://censys-python.readthedocs.io/en/stable/usage-v2.html#bulk-view) |
| 26 |
- [Download Bulk Data](https://censys-python.readthedocs.io/en/stable/usage-v1.html#data) |
| 27 |
- [Manage assets, events, and seeds in Censys ASM](https://censys-python.readthedocs.io/en/stable/usage-asm.html) |
| 28 |
- [Command-line interface](https://censys-python.readthedocs.io/en/stable/cli.html) |
| 29 |
|
| 30 |
<!-- markdownlint-disable MD033 --> |
| 31 |
|
| 32 |
<a href="https://asciinema.org/a/500416" target="_blank"><img src="https://asciinema.org/a/500416.svg" width="600"/></a> |
| 33 |
|
| 34 |
<!-- markdownlint-enable MD033 --> |
| 35 |
|
| 36 |
## Getting Started |
| 37 |
|
| 38 |
The library can be installed using `pip`. |
| 39 |
|
| 40 |
```sh |
| 41 |
pip install censys |
| 42 |
``` |
| 43 |
|
| 44 |
To upgraded using `pip`. |
| 45 |
|
| 46 |
```sh |
| 47 |
pip install --upgrade censys |
| 48 |
``` |
| 49 |
|
| 50 |
Alternatively, you can install the library using `uv`. |
| 51 |
|
| 52 |
```sh |
| 53 |
git clone https://github.com/censys/censys-python.git |
| 54 |
cd censys-python/ |
| 55 |
uv install |
| 56 |
``` |
| 57 |
|
| 58 |
Optionally, you can enable tab completion for the CLI by adding this line to your `~/.bashrc`, `~/.zshrc`, or equivalent. |
| 59 |
|
| 60 |
> Please note that autocomplete is supported for field names in the `search` command. |
| 61 |
|
| 62 |
```sh |
| 63 |
eval "$(register-python-argcomplete censys)" |
| 64 |
``` |
| 65 |
|
| 66 |
To configure your search credentials run `censys config` or set both `CENSYS_API_ID` and `CENSYS_API_SECRET` environment variables. |
| 67 |
|
| 68 |
```sh |
| 69 |
$ censys config |
| 70 |
|
| 71 |
Censys API ID: XXX |
| 72 |
Censys API Secret: XXX |
| 73 |
Do you want color output? [y/n]: y |
| 74 |
|
| 75 |
Successfully authenticated for [email protected] |
| 76 |
``` |
| 77 |
|
| 78 |
If you have a Censys ASM account, you can configure your ASM credentials by running `censys asm config` or set both `CENSYS_ASM_API_KEY` environment variables. |
| 79 |
|
| 80 |
```sh |
| 81 |
$ censys asm config |
| 82 |
|
| 83 |
Censys ASM API Key: XXX |
| 84 |
Do you want color output? [y/n]: y |
| 85 |
|
| 86 |
Successfully authenticated |
| 87 |
``` |
| 88 |
|
| 89 |
## Examples |
| 90 |
|
| 91 |
The examples located in the [`examples/`](examples/) directory are a great place to start. You can also find more examples in the [usage documentation](https://censys-python.readthedocs.io/en/stable/usage-v2.html). |
| 92 |
|
| 93 |
## [Documentation](https://censys-python.readthedocs.io/) |
| 94 |
|
| 95 |
[](https://censys-python.readthedocs.io/) |
| 96 |
|
| 97 |
## Resources |
| 98 |
|
| 99 |
- [Source](https://github.com/censys/censys-python) |
| 100 |
- [Issue Tracker](https://github.com/censys/censys-python/issues) |
| 101 |
- [Changelog](https://github.com/censys/censys-python/releases) |
| 102 |
- [Documentation](https://censys-python.rtfd.io) |
| 103 |
- [Discussions](https://github.com/censys/censys-python/discussions) |
| 104 |
- [Censys Homepage](https://censys.com/) |
| 105 |
- [Censys Search](https://search.censys.io/) |
| 106 |
|
| 107 |
## Contributing |
| 108 |
|
| 109 |
All contributions (no matter how small) are always welcome. See [Contributing to Censys Python](.github/CONTRIBUTING.md) |
| 110 |
|
| 111 |
## Development |
| 112 |
|
| 113 |
This project uses [uv](https://docs.astral.sh/uv/) for dependency management. Please ensure you have [installed the latest version](https://docs.astral.sh/uv/getting-started/installation/). |
| 114 |
|
| 115 |
```sh |
| 116 |
git clone [email protected]:censys/censys-python.git |
| 117 |
cd censys-python/ |
| 118 |
uv install |
| 119 |
``` |
| 120 |
|
| 121 |
## Testing |
| 122 |
|
| 123 |
```sh |
| 124 |
# Run tests |
| 125 |
uv run pytest |
| 126 |
# With coverage report |
| 127 |
uv run pytest --cov-report html |
| 128 |
``` |
| 129 |
|
| 130 |
## License |
| 131 |
|
| 132 |
This software is licensed under [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) |
| 133 |
|
| 134 |
- Copyright (C) 2026 Censys, Inc. |