Web Search

FREEMIUM
Par Roi Krakovski | Mise à jour il y a un an | Data
Popularité

9.9 / 10

Latence

1,946ms

Niveau de service

100%

Abonnés : 1,269
Ressources :
Site Web du produit
Créateur d'API :
avatar
Roi Krakovski
contextualwebsearch
Évaluer l'API :
Connectez-vous pour évaluer l'API

LISEZ-MOI

Web Search API. News API. Image API. AutoSuggest API. Billions of webpages, images and news with a single API call. Visit us at: usearch.com

Getting started with our Search API is easy. This quick tutorial contains running code examples for the search APIs.

Simply copy and the paste the code snippet of the relevant API to your computer. If you need any help getting started, please don’t hesitate to reach out - we’d love to hear from you.

In this tutorial we used Python3.6.

Web Search API

import requests

URL = "https://rapidapi.p.rapidapi.com/api/Search/WebSearchAPI"
HEADERS = {
    'x-rapidapi-host': "contextualwebsearch-websearch-v1.p.rapidapi.com",
    'x-rapidapi-key': "Your-X-RapidAPI-Key"
}

query = "taylor swift"
page_number = 1
page_size = 10
auto_correct = True
safe_search = False

querystring = {"q": query,
               "pageNumber": page_number,
               "pageSize": page_size,
               "autoCorrect": auto_correct,
               "safeSearch": safe_search}
response = requests.get(URL, headers=HEADERS, params=querystring).json()

print(response)

total_count = response["totalCount"]

for web_page in response["value"]:

    url = web_page["url"]
    title = web_page["title"]
    description = web_page["description"]
    body = web_page["body"]
    date_published = web_page["datePublished"]
    language = web_page["language"]
    is_safe = web_page["isSafe"]
    provider = web_page["provider"]["name"]

    print("Url: {}. Title: {}.".format(url, title))

News Search API

import requests

URL = "https://rapidapi.p.rapidapi.com/api/search/NewsSearchAPI"
HEADERS = {
    "x-rapidapi-host": "contextualwebsearch-websearch-v1.p.rapidapi.com",
    "x-rapidapi-key": "Your-X-RapidAPI-Key"
}

query = "taylor swift"
page_number = 1
page_size = 10
auto_correct = True
safe_search = False
with_thumbnails = True
from_published_date = ""
to_published_date = ""

querystring = {"q": query,
               "pageNumber": page_number,
               "pageSize": page_size,
               "autoCorrect": auto_correct,
               "safeSearch": safe_search,
               "withThumbnails": with_thumbnails,
               "fromPublishedDate": from_published_date,
               "toPublishedDate": to_published_date}

response = requests.get(URL, headers=HEADERS, params=querystring).json()

print(response)

total_count = response["totalCount"]

for web_page in response["value"]:
    url = web_page["url"]
    title = web_page["title"]
    description = web_page["description"]
    body = web_page["body"]
    date_published = web_page["datePublished"]
    language = web_page["language"]
    is_safe = web_page["isSafe"]
    provider = web_page["provider"]["name"]

    image_url = web_page["image"]["url"]
    image_height = web_page["image"]["height"]
    image_width = web_page["image"]["width"]

    thumbnail = web_page["image"]["thumbnail"]
    thumbnail_height = web_page["image"]["thumbnailHeight"]
    thumbnail_width = web_page["image"]["thumbnailWidth"]

    print("Url: {}. Title: {}. Published Date: {}.".format(url, title, date_published))

Image Search API

import requests

URL = "https://rapidapi.p.rapidapi.com/api/Search/ImageSearchAPI"
HEADERS = {
    'x-rapidapi-host': "contextualwebsearch-websearch-v1.p.rapidapi.com",
    'x-rapidapi-key': "Your-X-RapidAPI-Key"
}

q = "taylor swift"
page_number = 1
page_size = 10
auto_correct = True
safe_search = False

querystring = {"q": q,
               "pageNumber": page_number,
               "pageSize": page_size,
               "autoCorrect": auto_correct,
               "safeSearch": safe_search}

response = requests.get(URL, headers=HEADERS, params=querystring).json()

print(response)

totalCount = response["totalCount"]

for image in response["value"]:

    url = image["url"]
    name = image["name"]
    title = image["title"]

    provider = image["provider"]["name"]

    image_url = image["url"]
    image_height = image["height"]
    imageWidth = image["width"]

    thumbnail = image["thumbnail"]
    thumbnail_height = image["thumbnailHeight"]
    thumbnail_width = image["thumbnailWidth"]

    print("Url: %s. Title: %s." % (url, name))

Autosuggest API

import requests

URL = "https://rapidapi.p.rapidapi.com/api/spelling/AutoComplete"
HEADERS = {
    "x-rapidapi-host": "contextualwebsearch-websearch-v1.p.rapidapi.com",
    "x-rapidapi-key": "Your-X-RapidAPI-Key"
}
text = "tay"

querystring = {"text": text}

response = requests.get(URL, headers=HEADERS, params=querystring)
print(response.json())

SpellCheck API

import requests

URL = "https://rapidapi.p.rapidapi.com/api/spelling/SpellCheck"
HEADERS = {
    'x-rapidapi-host': "contextualwebsearch-websearch-v1.p.rapidapi.com",
    'x-rapidapi-key': "Your-X-RapidAPI-Key"
}

text = "teylor swiift"
querystring = {"text": text}

response = requests.get(URL, headers=HEADERS, params=querystring)
print(response.text)
Note : 4 - Votes : 5