bangtastic

Bangtastic!

An alternative search box designed around search bangs. (Edit these docs!)

Bang.js file format

DuckDuckGo stores bangs as a list of JSON objects following this format:

[
    {
        s: "Stack Overflow",
        t: "so",
        u: "http://stackoverflow.com/search?q=}"
        d: "stackoverflow.com",
        r: 665,
        c: "Tech",
        sc: "Programming",
    }
    // ...
]

Source: webapps.stackexchange.com

Bangtastic file format

The bangtastic file format extends the DDG bang.js format.

Major changes

t is a list of triggers

Multiple triggers often point to the same effective URL in DDG bang.js data.

Grouping triggers together:

By convention, the shortest trigger is ‘canonical’ and listed first, followed by the most descriptive/nmemonic triggers (usually the longest).

u is a map of urls

Target URLs are normalized in bangtastic.json:

Using a map allows the target url to change based on the type of input:

Example:

{
    u: {
        // Search terms: default to EN->KO translation
        s: 'https://papago.naver.com/?sk=en&tk=ko&hn=0&st={s}'

        // Empty (no search terms): Go to root page. 
        e: 'https://papago.naver.com/'

        // URL input: use URL that translates websites.
        u: 'https://papago.naver.net/website?locale=en&source=auto&target=en&url={s}',

        // Korean text input: use URL for KO->EN translation.
        ko: 'https://papago.naver.com/?sk=ko&tk=en&hn=0&st={s}' 
    }
}

{{{s}}} template syntax has been changed

Access to individual terms in a search query enables:

Cascading

Bangtasic files may extend other bangtastic files.

This is useful for adding onto or amending other bangtastic files.

If the bang does not exist in the parent file, the bang is simply added.

If the bang already exists in the parent file, the child file’s data is merged into the parent file’s data on a field-by-field basis.

Scopes

Bangtastic bangs may be scoped. The concept is very similar to NPM scopes.

Scopes are useful for reusing bang triggers for different purposes/users:

Note: Kagi “internal bangs” are simply bangs in the @kagi scope.

Group Bangs

Group bangs have two purposes:

So group bangs constist of: