Skip to Content

Getting Started

This guide takes you from an API key to your first price prediction. You'll describe a product, send it to /price/predict, and read the price that comes back.

Get an API key

Sign in to the Bencha Console and create an API key there.

Every request sends the key as a bearer token:

Authorization: Bearer {api_key}

Keep your key secret. Call the API from your server, not from code that runs in your users' browsers or apps. See Authentication for more.

Describe the product

A prediction starts with a query: what you know about the product. Here, a children's top from Newbie in very good condition, sold in Sweden in June on a marketplace with mixed prices:

Body
{
  "query": {
    "brand": "Newbie",
    "category": "tops",
    "condition": "very_good",
    "demography": "children",
    "target": "mixed",
    "month": 6,
    "country": 752,
    "region": 150
  },
  "currency": "EUR"
}

Brand and category can be names, like above, or the IDs from brand and category search.

Send every attribute you know. The models are trained on detailed products, and a query with only a brand and a category gives a rough estimate at best. See Query attributes for everything you can send.

Send the request

curl --request POST \
  --url https://api.bencha.io/v1/price/predict \
  --header "Authorization: Bearer $BENCHA_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "query": {
      "brand": "Newbie",
      "category": "tops",
      "condition": "very_good",
      "demography": "children",
      "target": "mixed",
      "month": 6,
      "country": 752,
      "region": 150
    },
    "currency": "EUR"
  }'

Rather try it without writing code? Open the playground, paste your key and press Send. It's filled in with the request above.

POST
/price/predict

Read the response

The response holds the price under prediction, and the brand and category your query was matched to under query.

Response
{
  "id": "prediction_01JAMTTKZDYZF4SDWCACZAN87Z",
  "created_at": "2024-10-20T13:26:00.685292+02:00",
  "query": {
    "brand": {
      "search_score": 1,
      "id": "brand_01JAMA6HRRJT8958ZAF8JMSN0D",
      "name": "Newbie"
    },
    "category": {
      "search_score": 1,
      "id": "category_01JAMAZ0C11EPHQCN3SJ0FJ7NH",
      "name": "apparel.tops",
      "name_en": "Tops",
      "name_se": "Överdelar"
    },
    "condition": "very_good",
    "demography": "children",
    "target": "mixed",
    "month": 6
  },
  "model": "spot-5-turbo",
  "prediction": {
    "price": 9.5,
    "lower_bound": 9.5,
    "upper_bound": 9.5,
    "score": 1,
    "currency": "EUR",
    "autocompleted_fields": [],
    "execution_time_ms": 96
  }
}
  • prediction.price is the predicted price, in prediction.currency.
  • query.brand and query.category show what your names were matched to. If they're not what you meant, send the IDs instead.
  • model is the model that made the prediction. Without a model in the request, you get the latest, spot-5-turbo.

Next steps

On this page