Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: insights api reference #2859

Merged
merged 27 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5eeab4e
docs: reference overhaul
kai687 Mar 3, 2024
37b77ce
docs: update redocly settings
kai687 Mar 5, 2024
cea3fcf
docs: change primary color for API reference
kai687 Mar 5, 2024
3c65e26
docs: improve Search API reference
kai687 Mar 5, 2024
9029b64
fix: no default value for language enum
kai687 Mar 6, 2024
7843ecd
fix: language must be nullable
kai687 Mar 6, 2024
830e2f8
fix: not null as an array
kai687 Mar 6, 2024
f512cf3
fix: no language enum for now
kai687 Mar 6, 2024
d5859e5
fix: no format date-time for now
kai687 Mar 6, 2024
af92092
Merge branch 'main' into docs/reference-overhaul
kai687 Mar 6, 2024
d94472e
fix: no sortFacetValuesBy enum for now
kai687 Mar 6, 2024
18791a4
fix: update yarn website script
kai687 Mar 6, 2024
0d39c7c
docs: search api hopefully done
kai687 Mar 7, 2024
6188c4a
fix: remove attributes from test
kai687 Mar 7, 2024
058ed47
fix search dictionary response
millotp Mar 9, 2024
53a868b
Merge branch 'main' into docs/reference-overhaul
kai687 Mar 11, 2024
ee50585
Update specs/search/paths/rules/clearRules.yml
kai687 Mar 11, 2024
a934041
docs: update helpers docs
kai687 Mar 11, 2024
bf48362
docs: update get settings
kai687 Mar 11, 2024
c5ef13a
fix: rename CSharp to C#
kai687 Mar 11, 2024
d30872e
Merge branch 'main' into docs/reference-overhaul
kai687 Mar 11, 2024
2b59c41
Revert "fix: rename CSharp to C#"
kai687 Mar 11, 2024
232f2b4
docs: insights api reference
kai687 Mar 7, 2024
917afca
Merge branch 'main' into docs/insights-api
kai687 Mar 13, 2024
7587f56
Merge branch 'main' into docs/insights-api
kai687 Mar 13, 2024
92a3fa5
chore: uncomment in specs
shortcuts Mar 13, 2024
56c5b2b
Update specs/insights/paths/deleteUserToken.yml
kai687 Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions specs/insights/common/schemas/EventAttributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ eventName:
maxLength: 64
pattern: '[\x20-\x7E]{1,64}'
description: |
The name of the event, up to 64 ASCII characters.
Event name, up to 64 ASCII characters.

Consider naming events consistently—for example, by adopting Segment's
[object-action](https://segment.com/academy/collecting-data/naming-conventions-for-clean-data/#the-object-action-framework)
Expand All @@ -13,7 +13,7 @@ eventName:

index:
type: string
description: The name of an Algolia index.
description: Index name to which the event's items belong.
example: YourIndexName

userToken:
Expand All @@ -22,9 +22,10 @@ userToken:
maxLength: 129
pattern: '[a-zA-Z0-9_=/+-]{1,129}'
description: |
An anonymous or pseudonymous user identifier.
Anonymous or pseudonymous user identifier.

> **Note**: Never include personally identifiable information in user tokens.
Don't use personally identifiable information in user tokens.
For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
example: test-user-1

authenticatedUserToken:
Expand All @@ -33,16 +34,19 @@ authenticatedUserToken:
maxLength: 129
pattern: '[a-zA-Z0-9_=/+-]{1,129}'
description: |
An identifier for authenticated users.
Identifier for authenticated users.

> **Note**: Never include personally identifiable information in user tokens.
When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`.
This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions.
Don't use personally identifiable information in user tokens.
For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
example: c6a52c02-d0c7-4b53-8ce3-2b8fd202f3f9

timestamp:
type: integer
format: int64
description: |
The timestamp of the event in milliseconds in [Unix epoch time](https://wikipedia.org/wiki/Unix_time).
Timestamp of the event in milliseconds in [Unix epoch time](https://wikipedia.org/wiki/Unix_time).
By default, the Insights API uses the time it receives an event as its timestamp.
example: 1687193127

Expand All @@ -60,7 +64,7 @@ queryID:

objectIDs:
type: array
description: The object IDs of the records that are part of the event.
description: Object IDs of the records that are part of the event.
items:
type: string
minItems: 1
Expand All @@ -70,9 +74,10 @@ objectIDs:
filters:
type: array
description: |
Facet filters.
Applied facet filters.

Each facet filter string must be URL-encoded, such as, `discount:10%25`.
Facet filters are `facet:value` pairs.
Facet values must be URL-encoded, such as, `discount:10%25`.
items:
type: string
minItems: 1
Expand All @@ -87,15 +92,13 @@ positions:
minItems: 1
maxItems: 20
description: |
The position of the clicked item the search results.
Position of the clicked item the search results.

The first search result has a position of 1 (not 0).
You must provide 1 `position` for each `objectID`.
example: [1, 2, 5]

price:
description: |
The total price of a product, including any discounts, in units of `currency`.
description: Total price of a product, including any discounts, in units of `currency`.
oneOf:
- type: number
format: double
Expand All @@ -104,8 +107,7 @@ price:
example: '9.99'

discount:
description: |
The absolute value of the discount for this product, in units of `currency`.
description: Absolute value of the discount for this product, in units of `currency`.
oneOf:
- type: number
format: double
Expand All @@ -118,8 +120,8 @@ quantity:
format: int32
example: 2
description: |
The quantity of a product that has been purchased or added to the cart.
The total value of a purchase is the sum of `quantity` multiplied with the `price` for each purchased item.
Quantity of a product that has been purchased or added to the cart.
The total purchase value is the sum of `quantity` multiplied with the `price` for each purchased item.

objectData:
type: object
Expand Down Expand Up @@ -174,7 +176,6 @@ objectDataAfterSearchList:

currency:
type: string
format: ISO 4217
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too technical? The description properly explains it anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the guidance given in the OpenAPI spec.
For the format parameter of a type: string field, there are optional formatters, but it also seems to be a free-form field. Since this is probably the only use of this, I thought it's better to remove it (as you said, we're explaining it in the description.

description: Three-letter [currency code](https://www.iso.org/iso-4217-currency-codes.html).
example: EUR

Expand Down
17 changes: 7 additions & 10 deletions specs/insights/paths/deleteUserToken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,30 @@ delete:
operationId: deleteUserToken
summary: Delete user token.
description: |
Delete all events related to a certain user token from events metrics and analytics.
To delete a personalization user profile, see [Delete a user profile](https://www.algolia.com/doc/rest-api/personalization/#delete-a-user-profile).
Deletes all events related to the specified user token from events metrics and analytics.
To delete a personalization user profile, see [Delete a user profile](/specs/personalization#tag/profiles/operation/deleteUserProfile).
parameters:
- name: userToken
in: path
description: The user token for which to delete all associated events.
description: User token for which to delete all associated events.
required: true
schema:
type: string
kai687 marked this conversation as resolved.
Show resolved Hide resolved
minLength: 1
maxLength: 129
pattern: '[a-zA-Z0-9_=/+]{1,129}'
example: test-user-1
$ref: '../common/schemas/EventAttributes.yml#/userToken'
responses:
'204':
description: No content.
headers:
x-ratelimit-limit:
description: The current rate limit. The maximum number of requests you can make to this endpoint.
description: Maximum number of requests you can make to this endpoint.
schema:
type: integer
x-ratelimit-remaining:
description: The number of remaining API requests you can make to this endpoint before reaching the rate limit.
description: Number of remaining API requests you can make to this endpoint before reaching the rate limit.
schema:
type: integer
x-ratelimit-reset:
description: The timestamp in Unix epoch time when the rate limit will reset.
description: Timestamp in Unix epoch time when the rate limit will reset.
schema:
type: integer

Expand Down
46 changes: 22 additions & 24 deletions specs/insights/paths/pushEvents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ post:
operationId: pushEvents
summary: Send events.
description: |
Send a list of events to the Insights API.
Sends a list of events to the Insights API.

You can include up to 1,000 events in a single request,
but the request body must be smaller than 2 MB.
Expand All @@ -22,11 +22,7 @@ post:
events:
type: array
description: |
List of click and conversion events.

An event is an object representing a user interaction.
Events have attributes that describe the interaction,
such as an event name, a type, or a user token.
Click and conversion events.

**All** events must be valid, otherwise the API returns an error.
minItems: 1
Expand Down Expand Up @@ -130,24 +126,26 @@ post:
- price: 19.99
quantity: 1
currency: EUR
Purchased:
summary: Purchase event.
value:
events:
- eventName: Products Purchased
eventType: conversion
eventSubtype: purchase
index: test-index
userToken: anonymous-user-1
authenticatedUserToken: user-1
objectIDs: ['product-1', 'product-2']
objectData:
- price: 49.99
quantity: 1
- price: 9.99
quantity: 2
currency: USD
value: 69.97
# Having this throws warning for the OpenAPI validation.
# I think it's because the schema can't be uniquely resolved.
# Purchased:
# summary: Purchase event.
# value:
# events:
# - eventName: Products Purchased
# eventType: conversion
# eventSubtype: purchase
# index: test-index
# userToken: anonymous-user-1
# authenticatedUserToken: user-1
# objectIDs: ['product-1', 'product-2']
# objectData:
# - price: 49.99
# quantity: 1
# - price: 9.99
# quantity: 2
# currency: USD
# value: 69.97
ClickFilter:
summary: Click event with filters.
value:
Expand Down
60 changes: 57 additions & 3 deletions specs/insights/spec.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,66 @@
openapi: 3.0.2
info:
title: Insights API
description: >-
The Algolia Insights API lets you collect events related to your search and discovery experience.
Events represent actions that users take on your app or website.
description: |
The Insights API lets you collect events related to your search and discovery experience.
Events represent user interactions with your app or website.
They unlock powerful features, such as recommendations, personalization, smarter search results,
and analytics that help you optimize your user experience.

# Client libraries

Use Algolia's API clients, libraries, and integrations to collect events from your UI and send them to the Insights API.
See: [Algolia's ecosystem](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/in-depth/ecosystem/)

# Base URLs

The base URLs for making requests to the Insights API are:

- `https://insights.us.algolia.io` (`https://insights.algolia.io` is an alias)
- `https://insights.de.algolia.io`

**All requests must use HTTPS.**

# Authentication

To authenticate your API requests, add these headers:

<dl>
<dt><code>x-algolia-application-id</code></dt>
<dd>Your Algolia application ID.</dd>
<dt><code>x-algolia-api-key</code></dt>
<dd>
An API key with the necessary permissions to make the request.
The required access control list (ACL) to make a request is listed in each endpoint's reference.
</dd>
</dl>

You can find your application ID and API key in the [Algolia dashboard](https://dashboard.algolia.com/account).

# Request format

Request bodies must be JSON objects.

# Response status and errors

Response bodies are JSON objects.
Deleting a user token returns an empty response body with rate-limiting information as headers.

Successful responses return a `2xx` status. Client errors return a `4xx` status. Server errors are indicated by a `5xx` status.
Error responses have a `message` property with more information.

The Insights API doesn't validate if the event parameters such as `indexName`, `objectIDs`, or `userToken`,
correspond to anything in the Search API. It justs checks if they're formatted correctly.
Check the [Events](https://dashboard.algolia.com/events/health) health section,
whether your events can be used for Algolia features such as Analytics, or Dynamic Re-Ranking.

# Version

The current version of the Insights API is version 1, as indicated by the `/1/` in each endpoint's URL.
version: 1.0.0
externalDocs:
url: https://www.algolia.com/doc/guides/sending-events/getting-started/
description: Events
components:
securitySchemes:
appId:
Expand Down
Loading