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

feat(recommend): introduce Recommend API client #1280

Merged
merged 10 commits into from
Jun 23, 2021

Conversation

francoischalifour
Copy link
Member

@francoischalifour francoischalifour commented Jun 21, 2021

This adds a new API client for Recommend.

Usage

import algoliarecommend from '@algolia/recommend';

const recommendClient = algoliarecommend('appId', 'apiKey');

recommendClient
  .getRelatedProducts({
    /* ... */
  })
  .then((response) => {
    console.log(response);
  });

API

getRelatedProducts

Returns items from the related-products AI model.

getFrequentlyBoughtTogether

Returns items from the bought-together AI model.

getRecommendations

Returns items from the provided AI model (other methods are based on that one).

Next steps

  • Add documentation on the Algolia website

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 21, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a42e67c:

Sandbox Source
javascript-client-app Configuration

@redox
Copy link

redox commented Jun 21, 2021

const recommendClient = recommend('appId', 'apiKey');

Shouldn't we rather use algoliarecommend like we do for algoliasearch?

@Haroenv
Copy link
Contributor

Haroenv commented Jun 21, 2021

algoliarecommend is quite hard to read, don't you think @redox ?

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

looks good overall, some small questions. Agreed with Sylvain that we need to be 100% sure of the client name before publishing

@redox
Copy link

redox commented Jun 21, 2021

algoliarecommend is quite hard to read, don't you think @redox ?

I think this is not worst than algoliasearch (we are just less used to it), and I thought we should rather keep consistency here.

@francoischalifour
Copy link
Member Author

@redox Is your reasoning that "specified" clients ready to be used shouldn't be imported with the @algolia npm namespace, but "productized" with algolia*?

(I'm fine with both naming.)

@redox
Copy link

redox commented Jun 22, 2021

@redox Is your reasoning that "specified" clients ready to be used shouldn't be imported with the @algolia npm namespace, but "productized" with algolia*?

(I'm fine with both naming.)

I like the new @algolia/recommend package naming (instead of algoliarecommend or algoliasearch), my point was more about the name of the exported function being recommend VS algoliarecommend. The same way we don't use search but algoliasearch.

@francoischalifour
Copy link
Member Author

@redox Right, the exported function isn't named (it's a default export, users can name it the way they want), so it's just a matter of documentation.

We can document the usage this way:

import algoliarecommend from '@algolia/recommend';

const recommendClient = algoliarecommend('appId', 'apiKey');

Wdyt?

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

we just need to add a readme, but ☑️ otherwise!

Haroenv
Haroenv previously approved these changes Jun 22, 2021
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

good call fixing that link!

shortcuts
shortcuts previously approved these changes Jun 22, 2021
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

Small question but looks good overall!

packages/recommend/src/methods/getRecommendations.ts Outdated Show resolved Hide resolved
shortcuts
shortcuts previously approved these changes Jun 22, 2021
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

Wonderful

@redox
Copy link

redox commented Jun 23, 2021

👏 well done team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants