Example request:
https://ailookup.app/search/v1/?q=bananas&apikey=1234
Base URL:
https://ailookup.app/search/v1/
Query Parameters:
-
q
- a URL-encoded string containing the the product or sector, with optional country, to search for. Examples:bananas
orbananas%20from%20ecduador
.Tip: To URL-encode text you can use the function encodeURIComponent() in JavaScript, or the ENCODEURL() function in Google Sheets, or in Python use urllib.parse.quote().
-
target
- The classification codename to use. The available classifications are: TSV files for each classification are available for download below. -
query_lang
- The system can accept queries in a number of languages. This parameter specifies the language used for the query text. If this is omitted the query is assumed to be in English (en). If this is any other language than English the query text will be machine-translated to English before semantic search is performed. The list of 100 available languages can be seen in the search form above. -
apikey
- Your API key. -
output
- Either json or html. Default is json. The "html" output is primarily intended for use with Google Sheets since the IMPORTHTML() function can only parse HTML tables, not JSON data.
Using POST:
The endpoint also optionally supports POST requests. The body can be either a JSON body or a FormData body. Use the Content-Type header 'application/json' or 'application/x-www-form-urlencoded' to indicate which type of body is being sent.
Results:
The system returns results in JSON format. If you are using
Google Sheets, add the output=html
parameter to the request.
Here are the details about
the two output types.
By default this service generates computer-readable JSON results. The API will return a result with this signature:
interface SemanticSearchResult {
ok: boolean,
message?: string,
search_query: string, /* Search query (in English) */
matches: SemanticSearchMatch[] /* Up to 5 matches */
}
interface SemanticSearchMatch {
zero_based_index: number,
code: string, /* The codename for this sector in the classification */
label: string,
cosine_similarity: number
/* Additional metadata may also be available for individual classifications... */
}
code
provides the codename for the matching sector.label
provides the text label for that matching sector.zero_based_index
provides the line index of the corresponding row in the sector list, using a zero-based index where the first line is line 0. Tab-delimted text files containing the list of sectors in each classification system are available in the documentation below.cosine_similarity
provides the cosine similarity score for the match.
To use Google Sheets, just add a output=html
parameter to your request.
The system will then return an HTML page with several tables and
these tables can be read by the IMPORTHTML()
function in Google Sheets.
To see how to use this feature, use the examples from the Example Google Sheet