hey, i just remove my api here for forum :D.
i replaced code in action and add there my api key
My code:
import os
import requests
def serphouse_api_run():
"""
Get results of api serphouse.com run for defined ketowrd
"""
# Insert your PYTHON code below. You can access environment variables using os.environ[].
# Currently, only the requests library is supported, but more libraries will be available soon.
# Use print statements or return values to display results to the user.
# If you save a png, pdf, csv, jpg, webp, gif, or html file in the root directory, it will be automatically displayed to the user.
# You do not have to call this function as the bot will automatically call and fill in the parameters.
url = "https://api.serphouse.com/serp/live"
payload = {
"data": {
"q": "Hosting",
"domain": "google.com",
"loc": "Abernathy,Texas,United States",
"lang": "en",
"device": "desktop",
"serp_type": "web",
"page": "1",
"verbatim": "0"
}
}
headers = {
'accept': "application/json",
'content-type': "application/json",
'authorization': "Bearer I PUT HERE MY API"
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
print(response.json())
else:
print(f"Error {response.status_code}: {response.text}")
I even try code similar to Dalee:
import os
import requests
def serphouse_api_run(kewyord_query: str):
"""
Allow pickaxe to get results from api serphouse.com for user defined keyword
Args:
kewyord_query (string): Prompt for the keyword to get API results
"""
# Insert your PYTHON code below. You can access environment variables using os.environ[].
# Currently, only the requests library is supported, but more libraries will be available soon.
# Use print statements or return values to display results to the user.
# If you save a png, pdf, csv, jpg, webp, gif, or html file in the root directory, it will be automatically displayed to the user.
# You do not have to call this function as the bot will automatically call and fill in the parameters.
api_key = os.environ["XX"]
headers = {
"Content-Type": "application/json",
}
headers["Authorization"] = f"Bearer {api_key}"
url = "https://api.serphouse.com/serp/live"
payload = {
"data": {
"q": kewyord_query,
"domain": "google.com",
"loc": "Abernathy,Texas,United States",
"lang": "en",
"device": "desktop",
"serp_type": "web",
"page": "1",
"verbatim": "0"
}
}
headers = {
'accept': "application/json",
'content-type': "application/json",
'authorization': "Bearer I PUT HERE MY API"
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
print(response.json())
else:
print(f"Error {response.status_code}: {response.text}")
And it still crashing