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, create an account at app.objective.inc.
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.2.tar.gz
.
File metadata
- Download URL: objective_sdk-4.0.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53c950546217d76d45be7e7e6153ec33d40214fec2c65efa5fa2ce3cfbca7b98 |
|
MD5 | fbb3001fa058d5a90ffb881f4ebe95ac |
|
BLAKE2b-256 | 8ee6bdedccbd9b0f5f0faced7e74991346098ac7697d12cf6fc45dc5421cbd99 |
File details
Details for the file objective_sdk-4.0.2-py3-none-any.whl
.
File metadata
- Download URL: objective_sdk-4.0.2-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d04031540912f93aed2a124bca87f657e506e52820205dfb1a4f97976d85ef8 |
|
MD5 | e3cb633904b0e9d89c364a2add8562c8 |
|
BLAKE2b-256 | da25ed81024141c639b608e762a5301eceebef68e4f1364ed9302a20d678b125 |