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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file objective_sdk-4.0.3.tar.gz
.
File metadata
- Download URL: objective_sdk-4.0.3.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a599cad74c19d60bcf429e89be91144bfee06250e977f7239fa43d45deeac88 |
|
MD5 | 2199524a9dd8b74293c6e1c94293c8f0 |
|
BLAKE2b-256 | 4d928aa6c3f6410f8a5f8b01cccc3a264387ca37d72b65a6cc1c5de54a9c2037 |
File details
Details for the file objective_sdk-4.0.3-py3-none-any.whl
.
File metadata
- Download URL: objective_sdk-4.0.3-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed0b4925c3eb0729fdb49a576d4983bf8035a2a07a767bbe96d28a1aaa098165 |
|
MD5 | 3bd09342496e8e34f028d3d259d1bd87 |
|
BLAKE2b-256 | 2c6ce185fe2442ce8068ab41469d9bac0c237b5f56115d9a84106a98a2659cd7 |