|
1 |
| -.... |
2 |
| - |
3 | 1 | <p align="center">
|
4 | 2 | <a href="https://www.algolia.com">
|
5 | 3 | <img alt="Algolia for JavaScript" src="https://raw.githubusercontent.com/algolia/algoliasearch-client-common/master/banners/javascript.png" >
|
|
16 | 14 | </p>
|
17 | 15 |
|
18 | 16 | <p align="center">
|
19 |
| - <a href="https://api-clients-automation.netlify.app/docs/clients/introduction" target="_blank">Documentation</a> |
| 17 | + <a href="https://www.algolia.com/doc/api-client/getting-started/install/javascript/" target="_blank">Documentation</a> • |
| 18 | + <a href="https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/" target="_blank">InstantSearch</a> • |
| 19 | + <a href="https://discourse.algolia.com" target="_blank">Community Forum</a> • |
| 20 | + <a href="http://stackoverflow.com/questions/tagged/algolia" target="_blank">Stack Overflow</a> • |
| 21 | + <a href="https://github.com/algolia/algoliasearch-client-javascript/issues" target="_blank">Report a bug</a> • |
| 22 | + <a href="https://www.algolia.com/doc/api-client/troubleshooting/faq/javascript/" target="_blank">FAQ</a> • |
| 23 | + <a href="https://alg.li/support" target="_blank">Support</a> |
20 | 24 | </p>
|
21 | 25 |
|
22 |
| -# Contributing to this repository |
| 26 | +**Migration note from v4.x to v5.x** |
| 27 | + |
| 28 | +> In July 2024, we released the v5 version of our JavaScript client. If you are using version 4.x of the client, read the [migration guide to version 5.x](https://api-clients-automation.netlify.app/docs/clients/migration-guides/). Version 4.x will **no longer** be under active development. |
| 29 | +
|
| 30 | +## ✨ Features |
| 31 | + |
| 32 | +- Thin & **minimal low-level HTTP client** to interact with Algolia's API |
| 33 | +- Works both on the **browser** and **node.js** |
| 34 | +- **UMD and ESM compatible**, you can use it with any module loader |
| 35 | +- Built with TypeScript |
| 36 | + |
| 37 | +## 💡 Getting Started |
| 38 | + |
| 39 | +First, install Algolia JavaScript API Client via your favorite package manager: |
| 40 | + |
| 41 | +```bash |
| 42 | +yarn add algoliasearch@beta |
| 43 | +# or |
| 44 | +npm install algoliasearch@beta |
| 45 | +``` |
| 46 | + |
| 47 | +Or Without a package manager: |
| 48 | + |
| 49 | +Add the following JavaScript snippet to the `<head>` of your website: |
| 50 | + |
| 51 | +```html |
| 52 | +<script src="https://cdn.jsdelivr.net/npm/algoliasearch@beta/dist/algoliasearch.umd.min.js"></script> |
| 53 | +``` |
| 54 | + |
| 55 | +Then, create objects on your index: |
| 56 | + |
| 57 | +```js |
| 58 | +import { algoliasearch } from 'algoliasearch'; |
| 59 | + |
| 60 | +const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey'); |
| 61 | + |
| 62 | +// Add a new record to your Algolia index |
| 63 | +const saveResponse = await client.saveObject({ |
| 64 | + indexName: '<YOUR_INDEX_NAME>', |
| 65 | + body: { objectID: 'id', test: 'val' }, |
| 66 | +}); |
| 67 | + |
| 68 | +// use typed response |
| 69 | +console.log(saveResponse); |
| 70 | + |
| 71 | +// Poll the task status to know when it has been indexed |
| 72 | +await client.waitForTask({ indexName: '<YOUR_INDEX_NAME>', taskID: saveResponse.taskID }); |
| 73 | + |
| 74 | +// Fetch search results, with typo tolerance |
| 75 | +const searchResponse = await client.search({ |
| 76 | + requests: [ |
| 77 | + { |
| 78 | + indexName: '<YOUR_INDEX_NAME>', |
| 79 | + query: '<YOUR_QUERY>', |
| 80 | + hitsPerPage: 50, |
| 81 | + }, |
| 82 | + ], |
| 83 | +}); |
| 84 | + |
| 85 | +// use typed response |
| 86 | +console.log(searchResponse); |
| 87 | +``` |
| 88 | + |
| 89 | +For the full documentation, visit the **[online documentation](https://api-clients-automation.netlify.app/docs/clients/usage)**. |
| 90 | + |
| 91 | +## ❓ Troubleshooting |
| 92 | + |
| 93 | +Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/api-client/troubleshooting/faq/javascript/) where you will find answers for the most common issues and gotchas with the client. |
| 94 | + |
| 95 | +## 📄 License |
| 96 | + |
| 97 | +Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE.md). |
23 | 98 |
|
24 |
| -The Algolia API clients are automatically generated, you can find everything here https://github.com/algolia/api-clients-automation |
|
0 commit comments