Skip to content

sajari/sdk-python

Repository files navigation

sajari-client

Search.io offers a search and discovery service with Neuralsearch®, the world's first instant AI search technology. Businesses of all sizes use Search.io to build site search and discovery solutions that maximize e-commerce revenue, optimize on-site customer experience, and scale their online presence.

Authentication

Rate limiting

The Search.io API employs a number of safeguards against bursts of incoming traffic to help maximize its stability. Users who send many requests in quick succession may see error responses that show up as HTTP status code 429.

For the UpsertRecord call, Search.io allows up to 175 write operations per second.

Treat these limits as maximums and don't generate unnecessary load. See Handling limiting gracefully for advice on handling 429s.

We may reduce limits to prevent abuse.

Common causes and mitigations

Rate limiting can occur under a variety of conditions, but it's most common in these scenarios:

  • Running a large volume of closely-spaced requests. Often this is part of a user's long-running reindex job. When engaging in these activities, you should try to control the request rate (see Handling limiting gracefully).
  • Running batch operations in parallel. Often BatchUpsertRecords is used as part of a user's long-running reindex job. A batch of records of size N passed to BatchUpsertRecords is counted as N UpsertRecord calls for the purposes of rate limiting, as opposed to a single call. Treat batch API calls as a convenience rather than a way to get more write throughput.

Handling limiting gracefully

A basic technique for integrations to gracefully handle limiting is to watch for 429 HTTP status codes and build in a retry mechanism. The retry mechanism should follow an exponential backoff schedule to reduce request volume when necessary. We also recommend building some randomness into the backoff schedule to avoid a thundering herd effect.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 4.0.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://www.search.io/company/contact

Requirements.

Python >=3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/sajari/sdk-python.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/sajari/sdk-python.git)

Then import the package:

import sajari_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import sajari_client

Getting Started

Please follow the installation procedure and then run the following:

import time
import sajari_client
from pprint import pprint
from sajari_client.api import collections_api
from sajari_client.model.collection import Collection
from sajari_client.model.error import Error
from sajari_client.model.event import Event
from sajari_client.model.experiment_request import ExperimentRequest
from sajari_client.model.experiment_response import ExperimentResponse
from sajari_client.model.list_collections_response import ListCollectionsResponse
from sajari_client.model.query_collection_request import QueryCollectionRequest
from sajari_client.model.query_collection_response import QueryCollectionResponse
# Defining the host is optional and defaults to https://api.search.io
# See configuration.py for a list of all supported configuration parameters.
configuration = sajari_client.Configuration(
    host = "https://api.search.io"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: BasicAuth
configuration = sajari_client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)


# Enter a context with an instance of the API client
with sajari_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = collections_api.CollectionsApi(api_client)
    collection_id = "collection_id_example" # str | The ID to use for the collection.  This must start with an alphanumeric character followed by one or more alphanumeric or `-` characters. Strictly speaking, it must match the regular expression: `^[A-Za-z][A-Za-z0-9\\-]*$`.
collection = Collection(
        authorized_query_domains=[
            "authorized_query_domains_example",
        ],
        display_name="display_name_example",
    ) # Collection | Details of the collection to create.
account_id = "Account-Id_example" # str | The account that owns the collection, e.g. `1618535966441231024`. (optional)

    try:
        # Create collection
        api_response = api_instance.create_collection(collection_id, collection, account_id=account_id)
        pprint(api_response)
    except sajari_client.ApiException as e:
        print("Exception when calling CollectionsApi->create_collection: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.search.io

Class Method HTTP request Description
CollectionsApi create_collection POST /v4/collections Create collection
CollectionsApi delete_collection DELETE /v4/collections/{collection_id} Delete collection
CollectionsApi experiment POST /v4/collections/{collection_id}:experiment Experiment
CollectionsApi get_collection GET /v4/collections/{collection_id} Get collection
CollectionsApi list_collections GET /v4/collections List collections
CollectionsApi query_collection POST /v4/collections/{collection_id}:query Query collection
CollectionsApi query_collection2 POST /v4/collections/{collection_id}:queryCollection Query collection
CollectionsApi track_event POST /v4/collections/{collection_id}:trackEvent Track event
CollectionsApi update_collection PATCH /v4/collections/{collection_id} Update collection
EventsApi send_event POST /v4/events:send Send event
EventsApi send_event2 POST /v4/events:sendEvent Send event
PipelinesApi create_pipeline POST /v4/collections/{collection_id}/pipelines Create pipeline
PipelinesApi generate_pipelines POST /v4/collections/{collection_id}:generatePipelines Generate pipelines
PipelinesApi get_default_pipeline GET /v4/collections/{collection_id}:getDefaultPipeline Get default pipeline
PipelinesApi get_default_version GET /v4/collections/{collection_id}/pipelines/{type}/{name}:getDefaultVersion Get default pipeline version
PipelinesApi get_pipeline GET /v4/collections/{collection_id}/pipelines/{type}/{name}/{version} Get pipeline
PipelinesApi list_pipelines GET /v4/collections/{collection_id}/pipelines List pipelines
PipelinesApi set_default_pipeline POST /v4/collections/{collection_id}:setDefaultPipeline Set default pipeline
PipelinesApi set_default_version POST /v4/collections/{collection_id}/pipelines/{type}/{name}:setDefaultVersion Set default pipeline version
PromotionsApi create_promotion POST /v4/collections/{collection_id}/promotions Create promotion
PromotionsApi delete_promotion DELETE /v4/collections/{collection_id}/promotions/{promotion_id} Delete promotion
PromotionsApi get_promotion GET /v4/collections/{collection_id}/promotions/{promotion_id} Get promotion
PromotionsApi list_promotions GET /v4/collections/{collection_id}/promotions List promotions
PromotionsApi update_promotion PATCH /v4/collections/{collection_id}/promotions/{promotion_id} Update promotion
RecordsApi batch_update_records POST /v4/collections/{collection_id}/records:batchUpdate Batch update records
RecordsApi batch_upsert_records POST /v4/collections/{collection_id}/records:batchUpsert Batch upsert records
RecordsApi delete_record POST /v4/collections/{collection_id}/records:delete Delete record
RecordsApi get_record POST /v4/collections/{collection_id}/records:get Get record
RecordsApi update_record POST /v4/collections/{collection_id}/records:update Update record
RecordsApi upsert_record POST /v4/collections/{collection_id}/records:upsert Upsert record
RedirectsApi create_redirect POST /v4/collections/{collection_id}/redirects Create redirect
RedirectsApi delete_redirect DELETE /v4/collections/{collection_id}/redirects/{redirect_id} Delete redirect
RedirectsApi get_redirect GET /v4/collections/{collection_id}/redirects/{redirect_id} Get redirect
RedirectsApi list_redirects GET /v4/collections/{collection_id}/redirects List redirects
RedirectsApi update_redirect PATCH /v4/collections/{collection_id}/redirects/{redirect_id} Update redirect
SchemaApi batch_create_schema_fields POST /v4/collections/{collection_id}/schemaFields:batchCreate Batch create schema fields
SchemaApi create_schema_field POST /v4/collections/{collection_id}/schemaFields Create schema field
SchemaApi delete_schema_field DELETE /v4/collections/{collection_id}/schemaFields/{schema_field_name} Delete schema field
SchemaApi list_schema_fields GET /v4/collections/{collection_id}/schemaFields List schema fields
SchemaApi update_schema_field PATCH /v4/collections/{collection_id}/schemaFields/{schema_field_name} Update schema field

Documentation For Models

Documentation For Authorization

BasicAuth

  • Type: HTTP basic authentication

Author

[email protected]

Notes for Large OpenAPI documents

If the OpenAPI document is large, imports in sajari_client.apis and sajari_client.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1: Use specific imports for apis and models like:

  • from sajari_client.api.default_api import DefaultApi
  • from sajari_client.model.pet import Pet

Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:

import sys
sys.setrecursionlimit(1500)
import sajari_client
from sajari_client.apis import *
from sajari_client.models import *