new Search(agent, categories, characterId, accessToken)
Create a new Search api wrapper with the given configuration. If
categories
is provided then the search is restricted to those
categories,
otherwise it will search over all categories. If categories
is a single
item, the return result of the search is simplified to be the array of ids
for that category (instead of an outer object with keys per category).
Categories must from the following enumeration:
agent
alliance
character
constellation
corporation
faction
inventorytype
region
solarsystem
station
wormhole
If characterId
and accessToken
are provided then the search will use
character specific search end point, and the structure
category can also
be used.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
agent |
ESIAgent | The ESI agent |
|
categories |
Array.<String> | Optional; the categories search to through |
|
characterId |
Number | 0 | Optional; the character id of the search |
accessToken |
String | Optional; SSO token for the provided
character,
must be provided if |
Methods
-
get(text)
-
Search for entities that match a given sub-string. This route is cached for up to 3600 seconds.
This makes an HTTP GET request to
/search/
. The route version isv1
.The string length of
text
must be at least3
. This function invokes the route withstrict
set tofalse
.On success, this resolves to a list of search results. An example result is:
{ "agent": [ 0 ], "alliance": [ 0 ], "character": [ 0 ], "constellation": [ 0 ], "corporation": [ 0 ], "faction": [ 0 ], "inventorytype": [ 0 ], "region": [ 0 ], "solarsystem": [ 30002510 ], "station": [ 60004588 ], "wormhole": [ 0 ] }
However, if the Search instance is configured to search over only a single category then the Promise simply resolves to the array of ids (e.g. the category was fetched from the response dictionary of category to array).
Parameters:
Name Type Description text
String The string to search on. The search terms of the query
Returns:
Or a
Promise.<Array.<Number>>
for a single-category search. A Promise that resolves to the parsed JSON of the response.- Type
- Promise.<Object>
-
strict(text)
-
Search for entities that match a given sub-string. This route is cached for up to 3600 seconds.
This makes an HTTP GET request to
/search/
. The route version isv1
.The string length of
text
must be at least3
. This function invokes the route withstrict
set totrue
.On success, this resolves to a list of search results. An example result is:
{ "agent": [ 0 ], "alliance": [ 0 ], "character": [ 0 ], "constellation": [ 0 ], "corporation": [ 0 ], "faction": [ 0 ], "inventorytype": [ 0 ], "region": [ 0 ], "solarsystem": [ 30002510 ], "station": [ 60004588 ], "wormhole": [ 0 ] }
However, if the Search instance is configured to search over only a single category then the Promise simply resolves to the array of ids (e.g. the category was fetched from the response dictionary of category to array).
Parameters:
Name Type Description text
String The string to search on. The search terms of the query
Returns:
Or a
Promise.<Array.<Number>>
for a single-category search. A Promise that resolves to the parsed JSON of the response.- Type
- Promise.<Object>