Skip to main content

Doofinder's search & management API client

Project description

PyDoof

Build Status

PyDoof is a Python client for Doofinder APIs (management and search). It provides easy access to Doofinder endpoint, including parameters-parsing and requests authentication.

Installation

PyDoof can be installed from PyPI:

pip install pydoof

Or directly from source code:

python setup.py install

Usage

To configure PyDoof, you need one of your user API keys, and your management and search URLs. You can find that information in the API Keys section of your Doofinder admin page. Set pydoof.token, pydoof.management_url, and pydoof.search_url with those values:

import pydoof
pydoof.token = "b8bcb..."
pydoof.management_url = "https://eu1-api.doofinder.com"
pydoof.search_url = "https://eu1-search.doofinder.com"

# Lists your search engines
search_engines = pydoof.search_engines.list()

# Search a term in one search engine
result = pydoof.search.query("abe16c8...", "some terms")

Per-request Configuration

You can configure individual requests via keywords arguments. For instance, setting a different token:

# List a search engine indices
pydoof.indices.list("abe16c8...", "product", token="cc83a..")

# Search suggestions for some terms
result = pydoof.search.suggest("cb12b...", "query", search_url = "https://eu1-search.doofinder.com")

Management and Search APIs

PyDoof includes clients for Doofinder management and search APIs. These two clients can work as separated modules. For instance, if you only want to use management API, you do not need to configure the pydoof.search_url parameter.

Management API

Management API allows you to handle search engines, indices and items. For instance, you can create an index for a search engine and index an item:

import pydoof
pydoof.token = "b8bcb..."
pydoof.management_url = "https://eu1-api.doofinder.com"

# Create an index
index = {
  "options": {
    "exclude_out_of_stock_items": False,
    "group_variants": False
  },
  "name": "product",
  "preset": "product"
}
pydoof.indices.create(hashid="abe16c8...", index=index)

# Index an item
item = {
  "categories": [
    "cat1",
    "cat2"
  ],
  "df_manual_boost": 1,
  "id": "1234",
  "link": "http://www.example.com/img/1234.png",
  "title": "Item Title"
}
pydoof.items.create(hashid="abe16c8...", name="product", item = item)

For a complete API reference, see the Management API docs.

Search API

Search API allows you to do queries to your search engines, and record data about your sales. For instance, you can search "cars" that are "blue" and with a price lower than €20.000.000.

import pydoof
pydoof.token = "b8bcb..."
pydoof.search_url = "https://eu1-search.doofinder.com"

# Search "cars" that are "blue" and with a price lower than €20.000.000
pydoof.search.query(
	hashid="abe16c8...",
	query="cars",
	filter_={"color": "blue"},
	exclude={"price": {"gt": 20000000}
)

And after that, record your sale:

# Add product to cart
pydoof.search_stats.add_to_cart(
	hashid="abe16c8...",
	index_name="product",
	session_id="4affa6",
	item_id="Ref001",
	amount=1,
	title="Ford Fiesta",
	price=8900
)

# And record that sale
pydoof.search_stats.checkout(hashid="abe16c8...", session_id="4affa6")

For a complete API reference, see the Search API docs.

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

PyDoof-3.3.3.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyDoof-3.3.3-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file PyDoof-3.3.3.tar.gz.

File metadata

  • Download URL: PyDoof-3.3.3.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6

File hashes

Hashes for PyDoof-3.3.3.tar.gz
Algorithm Hash digest
SHA256 dd049fee7198e2a9b94736e7d29d8a2a7f2a5d94cd568815c70530453bcc930a
MD5 ad0dd38d1b4ec550971aec302f27626b
BLAKE2b-256 f05e6c83095d99146026f05baf24adc72ec4078c2c97e2556a39cbfbc42c71cd

See more details on using hashes here.

File details

Details for the file PyDoof-3.3.3-py3-none-any.whl.

File metadata

  • Download URL: PyDoof-3.3.3-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6

File hashes

Hashes for PyDoof-3.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 313cec5e0fb528b088a816e084d9bde7ee2fa294499267d061e74c7feb5c274c
MD5 705dc87a760b82a39f51fbbbceea6c86
BLAKE2b-256 c8740e2f54016f57088beceb0bfd7bc821d1e462d10a42859da975240a6a4faa

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