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.2.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.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ellio_elq-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 adc56af8f4dcb71c273d9a0b978b5d0dc2be7e916226cf65f69b8d7915daefd9
MD5 ce01c09a3a41e41031488228d25bde3e
BLAKE2b-256 f315bcff7a452a67e10d543ccd695a8c7f8db8f4943ddc2aa960f967c9b218f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellio_elq-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: ellio_elq-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1beeec63660858f06be1a2c0b294d225d490822d4b002b7e4a0f5756bcd026b
MD5 53f29cb895cbe0faed39642b19a43e11
BLAKE2b-256 907930de8e801895287c438f22622880f828ad6016070d34f4ee262218e79faa

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellio_elq-0.1.2-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