Skip to main content

Query builder for ELQ, the ELLIO Search API query language

Project description

ELLIO

ellio-elq

Query builder for ELQ, the query language of the ELLIO Search API. Field metadata and operator capabilities are generated from the Search API field catalog; an operator a field's type does not support raises ValueError naming the field, its type, and the allowed operators. No dependencies; Python 3.10+.

Install

pip install ellio-elq

Usage

from ellio_elq import and_, f, not_, or_

query = and_(
    or_(f("src.geo.country.code").term("CN"), f("src.geo.country.code").term("RU")),
    not_(f("spoofable").term(True)),
    f("network.port").in_(22, 23),
).build()
# (src.geo.country.code:"CN" OR src.geo.country.code:"RU") AND NOT spoofable:true AND network.port IN (22, 23)

f("last_seen").within("7d").build()      # last_seen:7d
f("ip").term("203.0.113.0/24").build()   # ip:203.0.113.0/24

Operators map to methods: term (:), not_term (!:), match (~:), not_match (!~:), eq/ne/gt/gte/lt/lte, in_, range ([a TO b]), exists, not_exists, and within for relative time windows on date fields.

The builder emits the canonical text form produced by the Search API's query printer: string values are quoted (single quotes when the value contains a double quote; ELQ has no escape sequences), while numbers, booleans, IPs, CIDRs, dates, and relative times stay bare. Parentheses appear exactly where mixed AND/OR precedence requires them. Invalid combinations fail early: unsupported operators and non-IP values on the ip field raise ValueError. raw() is the escape hatch for query text the builder cannot express; it is parenthesized when composed.

More of the surface:

# Time windows, ranges, and comparisons
f("last_seen").within("7d")                         # last_seen:7d
f("first_seen").range("2026-06-01", "2026-06-30")   # first_seen:[2026-06-01 TO 2026-06-30]
f("active_days").gt(30)                             # active_days > 30

# Presence, analysed-text match, wildcards
f("cve").exists()                                   # cve exists
f("http.user_agent").match("zgrab")                 # http.user_agent~:"zgrab"
f("rdns").term("*.censys-scanner.com")              # rdns:"*.censys-scanner.com"

Query the Search API

The built string goes into the q parameter:

import os
import requests

res = requests.get(
    "https://api.ellio.tech/v1/cti/search",
    params={"q": query},
    headers={"apikey": os.environ["ELLIO_API_KEY"]},
)

The language

The full ELQ reference (operators, bare indicators, every searchable field) lives at https://docs.ellio.tech/threat-intel/elq. Built queries go into the q parameter of the Search API endpoints.

Conformance

The test suite includes a cross-language conformance table shared with the TypeScript SDK (@ellio_tech/elq): both SDKs must produce byte-identical output for every case, and each expected string is verified against the server grammar before release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ellio_elq-0.1.3.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ellio_elq-0.1.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file ellio_elq-0.1.3.tar.gz.

File metadata

  • Download URL: ellio_elq-0.1.3.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ellio_elq-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1a708aaf612e3f0110ba3cf2cd188dcfb6dee01cc6c75a36ab758732d497581f
MD5 321a8eab32d37f200a1d59408e2c5c6b
BLAKE2b-256 afd4832ce82fc4b2fe6f36ecd17de91735728fc789f7aab897299bf2b7dfb926

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellio_elq-0.1.3.tar.gz:

Publisher: promote.yml on ELLIO-Technology/elq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ellio_elq-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ellio_elq-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ellio_elq-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6cb373112feaff7e3102dc19583fc30471d13aab7ae355e86ecef6a699682665
MD5 6ef4386b5cb501eb36b97828140c0c14
BLAKE2b-256 ee4a4df29b0f92b17703df9e461ae091cfb6de1fac5ba7c2bccabaebe5c3f1d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellio_elq-0.1.3-py3-none-any.whl:

Publisher: promote.yml on ELLIO-Technology/elq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page