An alternative search box designed around search bangs. (Edit these docs!)
DuckDuckGo stores bangs as a list of JSON objects following this format:
s
summary/descriptiont
triggeru
target urld
domainr
rankingc
main categorysc
sub-category[
{
s: "Stack Overflow",
t: "so",
u: "http://stackoverflow.com/search?q=}"
d: "stackoverflow.com",
r: 665,
c: "Tech",
sc: "Programming",
}
// ...
]
Source: webapps.stackexchange.com
The bangtastic file format extends the DDG bang.js format.
t
is a list of triggersMultiple 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 urlsTarget URLs are normalized in bangtastic.json:
https://
protocol removedwww.
removedhttp://
protocol may be explicitly included to override normalization.Using a map allows the target url to change based on the type of input:
u.s
is required. (Search terms)u.e
defaults to the base path of u.s
(Empty: no search terms.)u.u
URLu.en
(Any two-letter ISO language codeu.n
numberu.d
dateExample:
{
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{s}
{s1}
… {s9}
gets individual terms from the query split on whitespace (quoted text is treated as a single term){s2:}
slice notation gets the remaining query after omitting the first 2 termsAccess to individual terms in a search query enables:
site:
in a site searchBangtasic 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.
Bangtastic bangs may be scoped. The concept is very similar to NPM scopes.
Scopes are useful for reusing bang triggers for different purposes/users:
@kagi!images
uses https://kagi.com/images?q={s}
@google!images
uses https://www.google.com/search?q={s}&tbm=isch
@ddg!images
uses https://duckduckgo.com/?q={s}&ia=images&iax=images
@leftium!images
uses the custom URL configured by user leftium!images
will use the default scope, which can be set by the user and/or service implementing the bangs.Note: Kagi “internal bangs” are simply bangs in the @kagi scope.
Group bangs have two purposes:
So group bangs constist of:
*
to a trigger includes the bang in the group, but excludes it from simultaneous launch.