Skip to main content

Official Python SDK for Objective, Inc. APIs

Project description

Objective, Inc. Python Library

This is the official python library for the Objective APIs. It provides convenient methods for using Objective's APIs.

Documentation

Our documentation can be found at docs.objective.inc.

Install and configure API key

To get an API key today join the waitlist.

pip install objective-sdk

Quickstart

Upload your objects

Push schemaless JSON objects to the Object Store. This enables their contents to be indexed for search.

from objective import Client

client = Client(api_key="sk_...")

objects = []

objects.append(
    {
        "id": "1",
        "object": {
            "title": "Sevendayz Men's Shady Records Eminem Hoodie Hoody Black Medium",
            "brand": "sevendayz"
        },
    },
)


client.object_store.upsert_objects(objects)

which will upsert your objects and let you know once the operation is complete:

Successfully upserted 1 object.

You can use client.object_store.delete_objects(["1"]) to delete this object from the object store.

Create an index and wait for indexing to be completed

Create a search Index, which triggers the objects in the Object Store to be indexed. See our docs for all options.

from objective import Client

client = Client(api_key="sk_...")

index = client.indexes.create_index(
    index_type="text-neural-base", fields={"searchable": ["title", "brand"]}
)
index.status(watch=True)

which returns information on how the objects are being processed and indexed:

Index idx_wXRUedqJkPof successfully created.
Progress: [---------------------------------------------------------------] 0%

Search

Once the objects are live in the index, issue search requests.

from objective import Client
import json

client = Client(api_key="sk_...")
index = client.indexes.get_index(<<INSERT INDEX ID HERE>>)

results = index.search(query="rapper hoodies", object_fields="*")
print(json.dumps(results, indent=4))

which outputs the following search result format:

{
    "results": [
        {
            "id": 1,
            "object": {"title": "Sevendayz Men's Shady Records Eminem Hoodie Hoody Black Medium", "brand": "sevendayz"}
        }
    ],
    "pagination": {
        "pages": 1,
        "page": 1,
        "next": null
    }
}

Congratulations, you just indexed and searched your first objects. To learn more and see more example code, check out our docs.

Development

Use python build to build this package:

python -m pip install --upgrade pip

# Install dependencies
pip install .

# Build package:
pip install build
python -m build

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

objective_sdk-4.0.3.tar.gz (13.0 kB view hashes)

Uploaded Source

Built Distribution

objective_sdk-4.0.3-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

Supported by

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