Skip to main content

A Python wrapper for the search API.

Project description

Certainly! Here is the documentation tailored for the WebSearchApi library:

WebSearchApi Library Documentation

Overview

The WebSearchApi library provides a simple interface to perform web searches using the SearchAPI class.

Installation

To install the WebSearchApi library, you can use pip. Assuming the library is available on PyPI, you can install it using the following command:

pip install WebSearchApi

If the library is not on PyPI, you can install it directly from the source by cloning the repository and installing it:

git clone https://github.com/ConsiousAI/WebSearchApi.git
cd WebSearchApi
pip install .

Usage

Importing the Library

First, import the necessary classes from the library:

from WebSearchApi.search import SearchAPI

Initializing the SearchAPI

Create an instance of the SearchAPI class:

search_api = SearchAPI()

Performing a Search

Use the search method to perform a web search. Handle possible exceptions such as InvalidQueryError and APIError.

try:
    result = search_api.search("OpenAI")
    print(result)
except:
    pass

API Reference

SearchAPI Class

The SearchAPI class provides the interface to perform web searches.

Methods
  • search(query: str) -> dict
    • Description: Performs a search query using the web search API.
    • Parameters:
      • query (str): The search query string.
    • Returns:
      • dict: The JSON response from the API.
    • Raises:
      • InvalidQueryError: If the query is invalid.
      • APIError: If the API returns an error.

Example

Here is a complete example demonstrating how to use the WebSearchApi library:

from websearchapi.search import SearchAPI

def main():
    search_api = SearchAPI()
    try:
        result = search_api.search("OpenAI")
        print(result)
    except InvalidQueryError as e:
        print(f"Invalid query: {e}")
    except APIError as e:
        print(f"API error: {e}")

if __name__ == "__main__":
    main()

Contributing

If you want to contribute to the project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -am 'Add new feature').
  5. Push to the branch (git push origin feature-branch).
  6. Create a new Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

websearchapi-1.0.1.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

WebSearchApi-1.0.1-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file websearchapi-1.0.1.tar.gz.

File metadata

  • Download URL: websearchapi-1.0.1.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for websearchapi-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3a8ead595c2250957174fbbb790698b33edb5de055c5157345e5d9bcfc1c05ed
MD5 4a941e16fd935a22bd2edf9623658dda
BLAKE2b-256 1246410ffbf25a817e610bbe43ef897738ca6209f79814e1b35ebb95299bb7ca

See more details on using hashes here.

File details

Details for the file WebSearchApi-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: WebSearchApi-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for WebSearchApi-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d41a546f664fd3ea96a4f6da212320c38883c438c1a12f40745e87ebaf656cd
MD5 1eed0f174adf474c6a65694397b7a261
BLAKE2b-256 2962fa2c6a0b2884fb69c9d399a5df1a960909defe2ac64a1653435c56f7b558

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page