Skip to main content

Bimiyun Search API Python SDK

Project description

Bimiyun Python SDK

A Python SDK for the Bimiyun Search API, providing a simple and intuitive interface for accessing Bimiyun's powerful search capabilities.

Table of Contents

Installation

You can install the Bimiyun Python SDK using pip:

pip install bimiyun-python

Quick Start

# To install: pip install bimiyun-python
from bimiyun import BimiyunClient
client = BimiyunClient("ak-********************")
response = client.search(
    query="artificial intelligence",
    safe=True,
    mode="fulltext",
    max_results=5
)
print(response)

Usage Examples

Basic Search

from bimiyun import BimiyunClient
client = BimiyunClient("ak-********************")
response = client.search("python programming")
print(response)

Search with All Parameters

from bimiyun import BimiyunClient
client = BimiyunClient("ak-********************")
response = client.search(query="machine learning tutorials", lang="en", safe=True, mode="fulltext", max_results=5)
print(response)

Custom Configuration

You can specify additional configuration options:

from bimiyun import BimiyunClient

client = BimiyunClient(
    "ak-********************",
    base_url="https://custom.bimiyun.com",
    timeout=60
)

response = client.search("test query")
print(response)

API Response Format

The search() method returns the raw API response in the following format:

{
  "organic": [
    {
      "title": "Result Title",
      "date": "",
      "link": "https://example.com",
      "position": 1,
      "site_name": "Example.com",
      "snippet": "Description text...",
      "text": "Full text..."
    }
  ]
}

Field descriptions:

  • title: Search result title
  • date: Publication date (if available)
  • link: URL of the search result
  • position: Position in the results list
  • site_name: Name of the website
  • snippet: Brief description or excerpt from the page
  • text: Full text of the page

API Reference

BimiyunClient

The main client class for interacting with the Bimiyun API.

Constructor

BimiyunClient(api_key: str, base_url: str = "https://search.bimiyun.com", timeout: int = 30)
  • api_key: Your Bimiyun API key (required)
  • base_url: Base URL for the API (default: https://search.bimiyun.com)
  • timeout: Request timeout in seconds (default: 30)

Methods

search(query: str = "", lang: str = "", safe: bool = True, mode: str = "fulltext", max_results: int = 5) -> Dict[str, Any]

Perform a search with the given query and return the raw API response.

Parameters:

  • query: Search query string (optional)
  • lang: Language code for search results (e.g., 'am' for Amharic, 'en' for English) (optional)
  • safe: Safe search mode: True or False (optional, default: True)
  • mode: Result detail mode: 'snippet' for brief descriptions or 'fulltext' for detailed content (optional, default: 'fulltext')
  • max_results: Maximum number of results to return (1-10, optional, default: 5)

Returns:

  • Raw API response dictionary containing the search results

Configuration

Environment Variables

You can configure the API key using environment variables:

export BIMIYUN_API_KEY="your-api-key"

Then in your code:

import os
from bimiyun import BimiyunClient

client = BimiyunClient(os.environ.get("BIMIYUN_API_KEY"))

Error Handling

The SDK raises exceptions for API errors:

from bimiyun import BimiyunClient

try:
    client = BimiyunClient("ak-********************")
    response = client.search("test query")
    results = response.get("organic", [])
    # Process results...

except Exception as e:
    if "timed out" in str(e):
        print("Network timeout error")
    elif "API request failed" in str(e):
        print("API error")
    else:
        print(f"Error: {e}")

Common error conditions:

  • Invalid API key
  • Rate limiting
  • Network timeouts
  • Invalid parameters

Testing

The SDK includes a simple test file. To run the test:

  1. First, replace the placeholder API key in tests/test_search.py with your actual API key
  2. Then run the test:
python tests/test_search.py

Contributing

Contributions are welcome! Please see our contributing guide for more information.

License

MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please:

  1. Check the documentation
  2. Open an issue on GitHub
  3. Contact support at support@bimiyun.com

Changelog

0.1.0

  • Basic search functionality
  • Advanced search with SearchRequest
  • Result extraction methods
  • API status check
  • Error handling
  • Comprehensive data models

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

bimiyun_python-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

bimiyun_python-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file bimiyun_python-0.1.0.tar.gz.

File metadata

  • Download URL: bimiyun_python-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for bimiyun_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9ad032cf84f29714d50c6c339bd027d1f56342e2550ae82d7d6fd745c569c967
MD5 171e5108763ca06bf1eced2cb002d15c
BLAKE2b-256 158a46a5b2b32a2e918f205c32672fab82ba71dbbeae970fc7f00c1127f8d8e3

See more details on using hashes here.

File details

Details for the file bimiyun_python-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bimiyun_python-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for bimiyun_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46bf116fb3ec290d71621b24c08b6cfcab3e3eb80ce6eaa404a48deace6c029b
MD5 02686b1b1db5fb37d390b1131d6e8149
BLAKE2b-256 2a299a73a1f3c6370d26baabfd70b6567cf7c66582500f7b41a00c205b0b4d1d

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