Skip to main content

Qryma Search API Python SDK

Project description

Qryma Python SDK

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

Table of Contents

Installation

You can install the Qryma Python SDK using pip:

pip install qryma-python

Quick Start

# To install: pip install qryma-python
from qryma import QrymaClient
client = QrymaClient("ak-********************")
response = client.search(
    query="artificial intelligence",
    start=0,
    safe=False,
    mode="snippet"
)
print(response)

Usage Examples

Basic Search

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

Search with All Parameters

from qryma import QrymaClient
client = QrymaClient("ak-********************")
response = client.search(query="machine learning tutorials", lang="en", start=0, safe=False, mode="snippet")
print(response)

Custom Configuration

You can specify additional configuration options:

from qryma import QrymaClient

client = QrymaClient(
    "ak-********************",
    base_url="https://custom.qryma.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..."
    }
  ]
}

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

API Reference

QrymaClient

The main client class for interacting with the Qryma API.

Constructor

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

Methods

search(query: str = "", lang: str = "", start: int = 0, safe: bool = False, mode: str = "snippet") -> 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)
  • start: Starting position of results (optional, default: 0)
  • safe: Safe search mode: True or False (optional, default: False)
  • mode: Result detail mode: 'snippet' for brief descriptions or 'fulltext' for detailed content (optional, default: 'snippet')

Returns:

  • Raw API response dictionary containing the search results

Configuration

Environment Variables

You can configure the API key using environment variables:

export QRYMA_API_KEY="your-api-key"

Then in your code:

import os
from qryma import QrymaClient

client = QrymaClient(os.environ.get("QRYMA_API_KEY"))

Error Handling

The SDK raises exceptions for API errors:

from qryma import QrymaClient

try:
    client = QrymaClient("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@qryma.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

qryma_python-0.1.1.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.

qryma_python-0.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file qryma_python-0.1.1.tar.gz.

File metadata

  • Download URL: qryma_python-0.1.1.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 qryma_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9a5f039bc4cb245cad6118858aa2b9bf07c971516a99ba4427108b4e2359bb89
MD5 532851ceffb8420cdfc3169e8ab284ee
BLAKE2b-256 eb8ae8ce107bffde70c85ab543794f5e9dca030d7f05ac2b18d2d30d51ab55fd

See more details on using hashes here.

File details

Details for the file qryma_python-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: qryma_python-0.1.1-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 qryma_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fae3c6cc44742f1db6abe6b710928e21dabee6f3ba38eec6330d5d83badb0a89
MD5 fad9f9dd53a064a263604736a316a4ee
BLAKE2b-256 f9a01727ebe99832ee0d37c5babb08dd8c111ffab472e1975792a1910977c698

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