Keymate.AI Web Search API: Enhances knowledge grounded responses by fetching URLs optimized for specific needs and performing authenticated internet searches.
- upsert - Inserts record to Keymate Memory.
- query - Queries the user's Keymate Memory.
- browseurl - The plugin enables user to conduct web browsing by extracting the text content of a specified URL. It will generate title and content.
- browse - Fetch any URLs without proxy it would probably fail on major websites but quicker than browseurl
- search - Without proxies searches keyword on the internet and fetches urls and optimizes output
- ultrafastsearch - This plugin provides 10 ultra fast search results from multiple sources giving a more comprehensive view.
- gptsbrowse - Fetch memory.keymate.ai URLs
- internetsearch - Conduct an internet search
It records the passed string in q parameter to keymate memory
import keymateapi
s = keymateapi.Keymateapi(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.upsert(q='I prefer Costa over Starbucks.')
if res.object is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
q |
str |
✔️ |
The context you are insertin to user's personal Keymate Memory history. |
I prefer Costa over Starbucks. |
operations.UpsertResponse
Error Object |
Status Code |
Content Type |
errors.SDKError |
4xx-5xx |
/ |
It brings the data previously inserted by other sessions to user's Keymate Memory.
import keymateapi
s = keymateapi.Keymateapi(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.query(q='https://keymate.ai')
if res.object is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
q |
str |
✔️ |
The context you are searching from user's personal Keymate Memory history. |
https://keymate.ai |
operations.QueryResponse
Error Object |
Status Code |
Content Type |
errors.SDKError |
4xx-5xx |
/ |
This is the most powerful browsing endpoints it uses residential proxies and bypasses firewalls. Try this with Reddit, LinkedIn etc.
import keymateapi
from keymateapi.models import errors, operations
# Get your API token at https://my.keymate.ai/pricing
s = keymateapi.Keymateapi(
bearer_auth="",
)
item_url = "https://www.rona.ca/en/product/danby-12-000-btu-8-000-sacc-115-v-white-portable-air-conditioner-dpa080b1wdb-6-330987187"
req = operations.BrowseurlRequest(inputwindowwords="5000", q=item_url, percentile="1", numofpages="1", paging="1")
res = s.browseurl(req)
def handle_response(response):
content_type = response.http_res.headers.get('Content-Type', '')
# Attempt to parse the response as JSON regardless of Content-Type
try:
response_json = response.http_res.json()
return response_json
except ValueError:
# If JSON parsing fails, fall back to handling as plain text
if 'text/plain' in content_type:
return {'text': response.http_res.text}
else:
raise errors.SDKError(f'Unknown content-type received: {content_type}', response.http_res.status_code, response.http_res.text, response.http_res)
if res is not None and hasattr(res, 'object'):
# handle response
try:
parsed_response = handle_response(res)
print(res)
except errors.SDKError as e:
print(f"An error occurred: {e}")
print(res)
operations.BrowseurlResponse
Error Object |
Status Code |
Content Type |
errors.BrowseurlResponseBody |
400 |
application/json |
errors.SDKError |
4xx-5xx |
/ |
Fetches URLs optimized for non heavily guarded websites
import keymateapi
s = keymateapi.Keymateapi(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.browse(q='http://impressive-silence.info', percentile='1', numofpages='1', paging='1')
if res.two_hundred_application_json_object is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
q |
str |
✔️ |
URL starting with https://memory.keymate.ai. Must be a valid URL. |
|
percentile |
str |
✔️ |
For adjusting response scope in case of 'ResponseTooLarge' error. Starts with 1. |
1 |
numofpages |
str |
✔️ |
Specifies the number of pages to return. Starts with 1 by default. |
1 |
paging |
Optional[str] |
➖ |
Used for pagination. Increments for subsequent pages. |
1 |
operations.BrowseResponse
Error Object |
Status Code |
Content Type |
errors.BrowseResponseBody |
400 |
application/json |
errors.BrowseResponseResponseBody |
401 |
application/json |
errors.SDKError |
4xx-5xx |
/ |
Searches web using google and fetches URLs optimized for non heavily guarded websites
import keymateapi
s = keymateapi.Keymateapi(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.search(q='http://fake-flume.name', percentile='1', numofpages='1')
if res.two_hundred_application_json_object is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
q |
str |
✔️ |
URL starting with https://memory.keymate.ai. Must be a valid URL. |
|
percentile |
str |
✔️ |
For adjusting response scope in case of 'ResponseTooLarge' error. Starts with 1. |
1 |
numofpages |
str |
✔️ |
Specifies the number of pages to return. Starts with 1 by default. |
1 |
operations.SearchResponse
Error Object |
Status Code |
Content Type |
errors.SearchResponseBody |
400 |
application/json |
errors.SearchResponseResponseBody |
401 |
application/json |
errors.SDKError |
4xx-5xx |
/ |
This plugin uses official Google Plugin so it provides the fastest results available with edge processors. Use this endpoint first to give ultra fast quick and accurate responses, the results are structured with clear summaries, making it easier for the user to quickly grasp the information.
import keymateapi
s = keymateapi.Keymateapi(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.ultrafastsearch(q='https://keymate.ai', percentile='100', numofpages='10')
if res.two_hundred_application_json_object is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
q |
str |
✔️ |
URL of the website. |
https://keymate.ai |
percentile |
str |
✔️ |
Set it as '100' |
100 |
numofpages |
str |
✔️ |
Set it as '10' |
10 |
operations.UltrafastsearchResponse
Error Object |
Status Code |
Content Type |
errors.UltrafastsearchResponseBody |
400 |
application/json |
errors.SDKError |
4xx-5xx |
/ |
Fetches URLs optimized for https://memory.keymate.ai, requiring bearer token authentication. Reflects user info and provides contextually relevant rules for actions performed.
import keymateapi
s = keymateapi.Keymateapi(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.gptsbrowse(q='http://puzzled-advertisement.com', percentile='1', numofpages='1', paging='1')
if res.two_hundred_application_json_object is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
q |
str |
✔️ |
URL starting with https://memory.keymate.ai. Must be a valid URL. |
|
percentile |
str |
✔️ |
For adjusting response scope in case of 'ResponseTooLarge' error. Starts with 1. |
1 |
numofpages |
str |
✔️ |
Specifies the number of pages to return. Starts with 1 by default. |
1 |
paging |
Optional[str] |
➖ |
Used for pagination. Increments for subsequent pages. |
1 |
operations.GptsbrowseResponse
Error Object |
Status Code |
Content Type |
errors.GptsbrowseResponseBody |
400 |
application/json |
errors.GptsbrowseResponseResponseBody |
401 |
application/json |
errors.SDKError |
4xx-5xx |
/ |
Performs an internet search based on provided query. Utilizes 'Authorization' and custom headers for user identification and search customization.
import keymateapi
import json
from keymateapi.models import errors, operations
# Get your API token at https://my.keymate.ai/pricing
s = keymateapi.Keymateapi(
bearer_auth="<YOUR_API_KEY>", #DONT FORGET TO GET YOUR API KEY FROM https://my.keymate.ai/pricing requires paid plan, insert to this string
)
try:
res = s.internetsearch(inputwindowwords="5000",q="python", percentile="1", numofpages="1")
if res.two_hundred_application_json_object is not None:
# handle response
print(res.two_hundred_application_json_object)
else:
print(res)
except errors.SDKError as e:
print("broken json")
res = str(e).split("Status 200")[1]
dict_data = json.loads(res)
print("result in python dict_data start")
print(f"{dict_data}")
print("result in python dict_data end")
Parameter |
Type |
Required |
Description |
Example |
inputwindowwords |
str |
✔️ |
Set it as '8000' first if responsetoolarge occurs reduce it to 1000. |
8000 |
q |
str |
✔️ |
Search query |
python |
percentile |
str |
✔️ |
Start it as '1', increase to '6' if ResponseTooLarge occurs, only reduce to '3' or '4' if user requests it. |
1 |
numofpages |
str |
✔️ |
Start it as '6'. Retry the request by decreasing only this one if 'ResponseTooLarge' occurs. Should be between 1 and 10. |
6 |
operations.InternetsearchResponse
Error Object |
Status Code |
Content Type |
errors.InternetsearchResponseBody |
400 |
application/json |
errors.InternetsearchResponseResponseBody |
401 |
application/json |
errors.SDKError |
4xx-5xx |
/ |