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",
    safe=False,
    mode="snippet",
    max_results=5
)
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", safe=False, mode="snippet", max_results=5)
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...",
      "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

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 = "", safe: bool = False, mode: str = "snippet", 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: False)
  • mode: Result detail mode: 'snippet' for brief descriptions or 'fulltext' for detailed content (optional, default: 'snippet')
  • 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 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.2.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.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qryma_python-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e67ea3dd7d5e7c62c480666905f8b1a17b2409fd2c6baa31026673f9da58843d
MD5 52f0586dd959505006a47e9c033d59df
BLAKE2b-256 a0cf2ee57e66d990988b55dcb9eded3f7e3a07d4fc2d1bbbf89821b94c961575

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qryma_python-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e189afc468b0d5e43485f400ca9c2c6a90fa61f96634def6c084a0e32a6e0b9
MD5 2b91144ce7a73aaea34b830a27d17626
BLAKE2b-256 f7da22092986b18d0fd477fb2d6aae7c5fab5c0920c04c791584f3966b170548

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