We highly recommend using our native client with bindings for all major languages which handles caching and is very efficient (< 1μs).
This endpoint returns regexes that must be cached on the server side. Use the Cache-Control header to set the expiration or just default it to an hour. The regex is updated on a regular basis but no more frequently than daily.
This endpoint returns two sets of PCRE compliant regexes, a concise regex to preprocess your input string and then a list of large keyword regexes to match against.
Here’s an example response, with a small sample of keywords:
The preprocess regex takes any input string and strips it of spaces and non-word characters and replaces it with a single space. Preprocessing the input string on your end is an extra step, but it reduces the size of the keyword regexes dramatically.
Here’s an example (in python):
Some users will add spaces and non-word characters, in an effort to evade detection. Imagine a user searches for “#ano resic.”
Now we have a more standardized term (“i want to kill myself”).
We can then match this term against the list of keyword regexes.
>>> for r in koko_keywords["regexes"]["keywords"]:
... if regex.match(r['regex'], preprocessed_string, regex.IGNORECASE):
Make sure to use case-insensitive matching and, if possible, compile the regex and cache it to improve performance. Also note that support for unicode constructs is required and some platforms will require third party libraries. Python 3, for example, requires the regex library since the standard re library does not have unicode support.
Click Try It! to start a request and see the response here!