Developer guide

Connect a custom store to Zeronode

Zeronode is a shopping assistant that runs on your store. It searches your catalogue and recommends real products with their current price and stock. Stores on WooCommerce and Magento connect without development work. If your store runs on its own platform, this guide is everything we need from you.

01

Overview

Three parts. Only the product API is required to go live.

Required

Product API

Read-only JSON over HTTPS. Search, plus three recommended endpoints.

Optional

Cart hooks

Lets the assistant put products in the visitor’s cart. We write the code.

One line

Widget tag

A script tag on every page. We send you the key.

02

API basics

How we call your API, and what to expect from us.

  • Called from our serversNot from the visitor’s browser, so you need no CORS headers.
  • GET with JSON backEvery call is a GET request with query parameters.
  • FastWe wait up to 8 seconds per call; aim for under one second. Searches run while the assistant is replying.
  • Your names are fineField and parameter names are your choice; we map them on our side. An existing internal API may already be enough, so send us what you have.
  • Lists anywhereA list can be the whole response or sit inside one field, such as items or data.products.
  • Published products onlyReturn only products a visitor can open and buy.
  • One language per callWith several languages, accept a parameter such as lang=en or serve each language under its own base URL. Names, descriptions and URLs in that language.

Authentication

Pick one. Give the key read access to the catalogue only.

Bearer token
Authorization: Bearer …
Basic auth
Authorization: Basic …A username and password.
Key in the URL
?key=…Works, but the key ends up in access logs.
03

Endpoints

The paths are examples. Use whatever fits your platform.

GET/products/search
Required

Search products

The endpoint the assistant uses most. Its quality decides the quality of the recommendations.

q
The search words.
limit
Number of results, up to 20.
min_price
Optional. Lowest price.
max_price
Optional. Highest price.
  • Match the product name, product code (SKU), brand and words from the description.
  • Accept several words, and rank products that match all of them first.
  • Ignore case and accents: “ūdens” also matches “udens”.
  • Return full products with every field below, best matches first.
GET/categories
Recommended

List categories

Lets the assistant browse the catalogue when a visitor asks for a kind of product rather than a name.

q
Optional. Filters categories by name.
limit
Number of categories.
  • Each category needs its id, name and parent id. A product count helps.
GET/categories/{id}/products
Recommended

Products in a category

A category’s products, narrowed by words and price.

limit
Number of products; 20 is typical.
q
Optional. Words that narrow the listing.
page
Optional. Page number, from 1.
min_price, max_price
Optional. Price range.
sort
Optional. price, date, title or popularity.
order
Optional. asc or desc.
  • Include products from subcategories.
GET/products/{id}
Recommended

One product by id

We check price and stock before showing a product, and use it to compare products.

id
The product id, in the path.
  • Return the same fields as search, or 404 when the id is unknown.
Try it
curl -H "X-Api-Key: YOUR_KEY" \
  "https://shop.example.com/api/products/search?q=beaker&limit=20"
04

Product fields

Every endpoint that returns products returns these fields.

idRequired

Stable. The same id your cart uses.

nameRequired

The product’s own name, without the category path or site name.

priceRequired

A number: what the visitor pays, including VAT. If you only have net prices, tell us the VAT rate.

urlRequired

The product page, as an absolute URL.

imageRecommended

The main image, as an absolute URL.

stockRecommended

instock, outofstock or onbackorder.

descriptionRecommended

Plain text or simple HTML. We read the first 600 characters, so put the facts first.

skuRecommended

The product code visitors and your staff use.

brandRecommended

The manufacturer or brand.

categoryIdsRecommended

The categories the product is in.

attributesOptional

Name and value pairs, such as Volume: 250 ml.

currencyOptional

An ISO code such as EUR, or tell us once if every price is in one currency.

regularPriceOptional

The price before a discount, when the product is on sale.

Example search response
{
  "items": [
    {
      "id": "48213",
      "name": "Glass beaker, low form, 250 ml",
      "price": 4.90,
      "currency": "EUR",
      "stock": "instock",
      "url": "https://shop.example.com/labware/glass-beaker-250-ml-48213",
      "image": "https://shop.example.com/images/48213.jpg",
      "sku": "BK-250",
      "brand": "Example Glassworks",
      "categoryIds": [12, 31],
      "description": "Borosilicate glass 3.3, heat resistant to 500 °C. Graduated from 50 to 200 ml, with spout.",
      "attributes": [
        { "name": "Volume", "value": "250 ml" },
        { "name": "Material", "value": "Borosilicate glass" }
      ]
    }
  ]
}

Errors

200
No results: an empty list.
404
Unknown product id.
401 / 403
Wrong or missing key. Our app flags the connection as broken, so it never fails silently.
JSON
Errors as JSON, never an HTML error page or a bot-protection challenge. If a firewall sits in front of the API, let our requests through.
05

Cart hooks

Optional. Without them, product cards link to the product page and the visitor adds to cart there.

With cart hooks, the assistant can add products to the visitor’s cart. We write that code. It runs in the visitor’s browser on your pages, in their own session, and you don’t paste anything. Tell us how a script on your page can do these four things:

  1. Add to cartProduct id, quantity and variant (if you have variants), added to the current visitor’s cart.
  2. Read the cartThe product ids and quantities in it.
  3. Open the cartUsually just the cart page URL.
  4. Apply a couponOnly if you offer coupons.

A JavaScript function or a same-origin endpoint both work. Use the same product ids as the API.

Two shapes that work (yours can differ)
// A function on the page …
await window.shop.cart.add({ id: '48213', quantity: 1 })

// … or a same-origin endpoint that uses the session cookie
await fetch('/cart/add', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ id: '48213', quantity: 1 }),
})
06

Install the widget

Add the tag to every page, in the head or before the closing body tag. We send you the public key.

HTML
<script src="https://content.zeronode.ai/zeronode-plugin.js"
        data-public-key="YOUR_PUBLIC_KEY" data-zeronode defer></script>

If your site sends a Content-Security-Policy, allow these hosts. The widget needs neither unsafe-eval nor inline scripts.

Content-Security-Policy
Content-Security-Policy:
  script-src https://content.zeronode.ai https://api.zeronode.ai;
  connect-src https://api.zeronode.ai wss://api.zeronode.ai;
07

Send it to us

When the API answers, send us these and we connect the store.

  1. The API base URL and a read-only key.
  2. One search URL that returns results.
  3. One product id we can test with.
  4. For cart hooks: the function or endpoint, and the cart page URL.
Questions, or ready to connect?info@zeronode.ai
Email us