diff --git a/website/docs/clients/guides/send-data-to-algolia.mdx b/website/docs/clients/guides/send-data-to-algolia.mdx index 0b3967a121..9e60fad7ff 100644 --- a/website/docs/clients/guides/send-data-to-algolia.mdx +++ b/website/docs/clients/guides/send-data-to-algolia.mdx @@ -15,7 +15,7 @@ To push data to Algolia, you need an Application ID and a valid API key with the ## Setting up the API client -> [Make sure to also read the `installation` page](/docs/clients/installation). +> [Make sure to also read the `usage` page](/docs/clients/usage). diff --git a/website/docs/clients/introduction.md b/website/docs/clients/introduction.md index 4f5bb462a7..1221f84d2f 100644 --- a/website/docs/clients/introduction.md +++ b/website/docs/clients/introduction.md @@ -4,7 +4,9 @@ title: Introduction # Introduction -This section hosts informations about the [usage of the API clients](https://github.com/algolia/api-clients-automation). For informations regarding the automation and how to contribute, see [the automation page](/docs/contributing/introduction). +This section holds information about [the generated Algolia API clients](https://github.com/algolia/api-clients-automation). + +If you wish to contribute, please see [the contributing page](/docs/contributing/introduction). ## Repositories @@ -13,8 +15,8 @@ Generated code in production can be find on repository of the clients. - [C#](https://github.com/algolia/algoliasearch-client-csharp/tree/next) - [Dart](https://github.com/algolia/algoliasearch-client-dart/) - [Go](https://github.com/algolia/algoliasearch-client-go/tree/next/) -- [Java](https://github.com/algolia/algoliasearch-client-java/tree/next/) - [JavaScript](https://github.com/algolia/algoliasearch-client-javascript/tree/next/) +- [Java](https://github.com/algolia/algoliasearch-client-java/tree/next/) - [Kotlin](https://github.com/algolia/algoliasearch-client-kotlin/tree/next/) - [PHP](https://github.com/algolia/algoliasearch-client-php/tree/next/) - [Python](https://github.com/algolia/algoliasearch-client-python/tree/next) @@ -23,13 +25,12 @@ Generated code in production can be find on repository of the clients. ## Usage -See [the installation](/docs/clients/installation) page. +See [the usage](/docs/clients/usage) page. -You can also check the [playground](/docs/contributing/testing/playground) if you'd like to test clients locally. +## Example -## Feedbacks +Code snippets are available for every APIs, clients and endpoints, [browse our OpenAPI specs](/specs/search). -To report feedbacks, please use: +## Feedbacks -- [GitHub issues](https://github.com/algolia/api-clients-automation/issues) -- [#api-clients-beta-testers slack channel](https://algolia.slack.com/archives/C0341QDM3EG) +Please use [GitHub issues](https://github.com/algolia/api-clients-automation/issues) diff --git a/website/docs/clients/migration-guides/csharp.md b/website/docs/clients/migration-guides/csharp.md deleted file mode 100644 index 872fa546ea..0000000000 --- a/website/docs/clients/migration-guides/csharp.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: C# ---- - -### Usage - -To get started, first install the `Algolia.Search` client. - -You can get the last version of the client from [NuGet](https://www.nuget.org/packages/Algolia.Search/). - -If you are using the .NET CLI, you can install the package using the following command: - -```bash -dotnet add package Algolia.Search --version -``` - -You can continue this guide on [our installation page](/docs/clients/installation). - -### Instantiating the client - -```csharp -// Without custom configuration -new SearchClient("", ""); - -// With custom configuration -new SearchClient(new SearchConfig("", "") -{ - ReadTimeout = TimeSpan.FromMinutes(1) -}); -``` - -### Methods targeting an `indexName` - -Prior to the `initIndex` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `initIndex` level requires the `indexName` to be sent with the query. - -That also mean you need to explicit the type you want to be returned from your queries, when it applies. - -```csharp -using Algolia.Search.Clients; -using Algolia.Search.Models.Search; - -var client = new SearchClient("", ""); - -client.Search(new SearchMethodParams(new List -{ - new(new SearchForHits("") { Query = "" }) -})); -``` - - - - diff --git a/website/docs/clients/migration-guides/go.md b/website/docs/clients/migration-guides/go.md deleted file mode 100644 index 8f1e235924..0000000000 --- a/website/docs/clients/migration-guides/go.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: Go ---- - -### Methods targeting an `indexName` - -Prior to the `initIndex` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `initIndex` level requires the `indexName` to be sent with the query. - -That also mean you need to explicit the type you want to be returned from your queries, when it applies. - -```go -import ( - "github.com/algolia/algoliasearch-client-go/v4/algolia/search" -) - -indexName := "" -appID := "" -apiKey := "" - -searchClient, _ := search.NewClient(appID, apiKey) - -results, err := searchClient.Search( - searchClient.NewApiSearchRequest( - search.NewSearchMethodParams( - []search.SearchQuery{ - search.SearchForHitsAsSearchQuery( - search.NewSearchForHits( - indexName, - search.WithSearchForHitsQuery(""), - ), - ), - }, - ), - ), -) -``` diff --git a/website/docs/clients/migration-guides/index.mdx b/website/docs/clients/migration-guides/index.mdx index f3cf5e6e74..4ce6465f6f 100644 --- a/website/docs/clients/migration-guides/index.mdx +++ b/website/docs/clients/migration-guides/index.mdx @@ -51,27 +51,54 @@ const searchResults = await client.search({ ```py from algoliasearch.search.client import SearchClient -client = SearchClient.create("YOUR_APP_ID", "YOUR_API_KEY") +client = SearchClient("YOUR_APP_ID", "YOUR_API_KEY") + +# using a raw dict + +search_resp = await client.search(search_method_params={"requests": [{"indexName": "nvim"}]}) + +# using the given models + +from algoliasearch.search.models.search_method_params import SearchMethodParams +from algoliasearch.search.models.search_for_hits import SearchForHits +from algoliasearch.search.models.search_query import SearchQuery + +search_resp = await client.search( + search_method_params=SearchMethodParams( + requests=[ + SearchQuery(SearchForHits(index_name="nvim")), + ], + ), +) -searchResults = await client.search(search_method_params={"requests": [{"indexName": "nvim"}]}) +print(search_resp.to_json()) ``` ```php -$client = Algolia\AlgoliaSearch\Api\SearchClient::create( +use Algolia\AlgoliaSearch\Api\SearchClient; + +$client = SearchClient::create( '', '' ); -$client->search([ +// only query string +$searchResults = $client->search([ + 'requests' => [ + ['indexName' => '', 'query' =>''], + ], +]); + +$searchResults2 = $client->search([ 'requests' => [ [ - 'indexName' => '', + 'indexName' => '', 'query' => '', 'attributesToRetrieve' => ['firstname', 'lastname'], - 'hitsPerPage': 50, + 'hitsPerPage' => 50, ], ], ]); @@ -101,6 +128,51 @@ client.search( ); ``` + + + +```kotlin +import com.algolia.client.api.SearchClient +import com.algolia.client.model.search.* + +val client = SearchClient("", "") +val response = client.search( + SearchMethodParams( + requests = listOf(SearchForHits(indexName = "", query = "")) + ) +) +``` + + + + +```go +import ( + "github.com/algolia/algoliasearch-client-go/v4/algolia/search" +) + +indexName := "" +appID := "" +apiKey := "" + +searchClient, _ := search.NewClient(appID, apiKey) + +results, err := searchClient.Search( + searchClient.NewApiSearchRequest( + search.NewSearchMethodParams( + []search.SearchQuery{ + search.SearchForHitsAsSearchQuery( + search.NewSearchForHits( + indexName, + search.WithSearchForHitsQuery(""), + ), + ), + }, + ), + ), +) +``` + @@ -110,14 +182,10 @@ using Algolia.Search.Models.Search; var client = new SearchClient("", ""); -client.Search(new SearchMethodParams([ - new SearchQuery(new SearchForHits("") - { - Query = "", - AttributesToRetrieve = ["firstname", "lastname"], - HitsPerPage = 50 - }) -])); +client.Search(new SearchMethodParams(new List +{ + new(new SearchForHits("") { Query = "" }) +})); ``` @@ -759,10 +827,5 @@ foreach (var synonym in browseSynonyms) You can find specific client breaking changes in their own section: -- [Go migration guide](/docs/clients/migration-guides/go) -- [Java migration guide](/docs/clients/migration-guides/java) - [JavaScript migration guide](/docs/clients/migration-guides/javascript) -- [Kotlin migration guide](/docs/clients/migration-guides/kotlin) - [PHP migration guide](/docs/clients/migration-guides/php) -- [Python migration guide](/docs/clients/migration-guides/python) -- [C# migration guide](/docs/clients/migration-guides/csharp) diff --git a/website/docs/clients/migration-guides/java.md b/website/docs/clients/migration-guides/java.md deleted file mode 100644 index 3f5356a5de..0000000000 --- a/website/docs/clients/migration-guides/java.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: Java ---- - -### Methods targeting an `indexName` - -Prior to the `initIndex` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `initIndex` level requires the `indexName` to be sent with the query. - -That also mean you need to explicit the type you want to be returned from your queries, when it applies. - -```java -import com.algolia.api.SearchClient; -import com.algolia.model.search.*; - -SearchClient client = new SearchClient("", ""); - -client.search( - new SearchMethodParams() - .addRequests( - new SearchForHits() - .setIndexName("") - .setQuery("") - ) -); -``` - - - - diff --git a/website/docs/clients/migration-guides/javascript.md b/website/docs/clients/migration-guides/javascript.md index ded1a919df..d67ec84d43 100644 --- a/website/docs/clients/migration-guides/javascript.md +++ b/website/docs/clients/migration-guides/javascript.md @@ -6,47 +6,3 @@ title: JavaScript |-----------|:---------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `search` | `searchClient` | Exported clients are suffixed by `Client`. | | `destroy` | **removed** | This method has not been implemented in the new clients, if you feel the need for it, [please open an issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&template=Feature_request.md) | - -### Usage - -To get started, first install the `algoliasearch` client. - -```bash -yarn add algoliasearch@alpha -# or -npm install algoliasearch@alpha -``` - -You can continue this guide on [our installation page](/docs/clients/installation). - -### Methods targeting an `indexName` - -Prior to the `initIndex` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `initIndex` level requires the `indexName` to be sent with the query. - -```js -import { algoliasearch } from 'algoliasearch'; - -const client = algoliasearch('', ''); - -// only query string -const searchResults = await client.search({ - requests: [ - { - indexName: '', - query: '', - }, - ], -}); - -// with params -const searchResults2 = await client.search({ - requests: [ - { - indexName: '', - query: '', - attributesToRetrieve: ['firstname', 'lastname'], - hitsPerPage: 50, - }, - ], -}); -``` diff --git a/website/docs/clients/migration-guides/kotlin.md b/website/docs/clients/migration-guides/kotlin.md deleted file mode 100644 index 910f5786aa..0000000000 --- a/website/docs/clients/migration-guides/kotlin.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: Kotlin ---- - -### Methods targeting an `indexName` - -Prior to the `initIndex` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `initIndex` level requires the `indexName` to be sent with the query. - -That also mean you need to explicit the type you want to be returned from your queries, when it applies. - -```kotlin -import com.algolia.client.api.SearchClient -import com.algolia.client.model.search.* - -val client = SearchClient("", "") -val response = client.search( - SearchMethodParams( - requests = listOf(SearchForHits(indexName = "", query = "")) - ) -) -``` diff --git a/website/docs/clients/migration-guides/php.md b/website/docs/clients/migration-guides/php.md index ab649d0cd2..fd1e043d8d 100644 --- a/website/docs/clients/migration-guides/php.md +++ b/website/docs/clients/migration-guides/php.md @@ -10,50 +10,3 @@ title: PHP | `Algolia\AlgoliaSearch\Support\UserAgent` | `Algolia\AlgoliaSearch\Support\AlgoliaAgent` | `UserAgent` class has been renamed to `AlgoliaAgent` for consistency across client languages (`addCustomUserAgent` method also became `addAlgoliaAgent`). | | `Algolia\AlgoliaSearch\SearchIndex` | **removed** | Since the method `initIndex` doesn't exist anymore, we decided to merge the `SearchIndex` class inside the `SearchClient` one, now all the methods related to search endpoints are located there. | | `Algolia\AlgoliaSearch\Cache\FileCacheDriver` | **removed** | This implementation of the `CacheInterface` is not available anymore in the Client. If you feel the need for it, [please open an issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&template=Feature_request.md) | - -### Usage - -To get started, first uninstall the previously added clients. - -```bash -composer remove algolia/algoliasearch-client-php -``` - -You can now install the `Algoliasearch` clients. - -```bash -composer require algolia/algoliasearch-client-php "^4.0@alpha" -``` - -You can continue this guide on [our installation page](/docs/clients/installation). - -### Methods targeting an `indexName` - -Prior to the `initIndex` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `initIndex` level requires the `indexName` to be sent with the query. - -```php -use Algolia\AlgoliaSearch\Api\SearchClient; - -$client = SearchClient::create( - '', - '' -); - -// only query string -$searchResults = $client->search([ - 'requests' => [ - ['indexName' => '', 'query' =>''], - ], -]); - -$searchResults2 = $client->search([ - 'requests' => [ - [ - 'indexName' => '', - 'query' => '', - 'attributesToRetrieve' => ['firstname', 'lastname'], - 'hitsPerPage' => 50, - ], - ], -]); -``` diff --git a/website/docs/clients/migration-guides/python.md b/website/docs/clients/migration-guides/python.md deleted file mode 100644 index 5192399951..0000000000 --- a/website/docs/clients/migration-guides/python.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: Python ---- - -### Usage - -To get started, first install the `algoliasearch` client. - -```bash -pip install --upgrade 'algoliasearch>=4.0,<5.0' -``` - -You can continue this guide on [our installation page](/docs/clients/installation). - -### Instantiation - -In order to instantiate the client, you had to call the `create` method which wasn't really following the principles of the `__init__` method as many of you reported. You can now instantiate any client by calling the class directly: - -```py -from algoliasearch.search.client import SearchClient -from algoliasearch.search.config import SearchConfig - -# ordered - -client = SearchClient("YOUR_APP_ID", "YOUR_API_KEY") - -# named - -client = SearchClient(app_id="YOUR_APP_ID", api_key="YOUR_API_KEY") - -# custom - -client = SearchClient(app_id="YOUR_APP_ID", api_key="YOUR_API_KEY", config=SearchConfig(...)) - -``` - -### Methods targeting an `index_name` - -Prior to the `init_index` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `init_index` level requires the `index_name` to be sent with the query. - -```py -from algoliasearch.search.client import SearchClient - -client = SearchClient("YOUR_APP_ID", "YOUR_API_KEY") - -# using a raw dict - -search_resp = await client.search(search_method_params={"requests": [{"indexName": "nvim"}]}) - -# using the given models - -from algoliasearch.search.models.search_method_params import SearchMethodParams -from algoliasearch.search.models.search_for_hits import SearchForHits -from algoliasearch.search.models.search_query import SearchQuery - -search_resp = await client.search( - search_method_params=SearchMethodParams( - requests=[ - SearchQuery(SearchForHits(index_name="nvim")), - ], - ), -) - -print(search_resp.to_json()) -``` diff --git a/website/docs/clients/installation.mdx b/website/docs/clients/usage.mdx similarity index 86% rename from website/docs/clients/installation.mdx rename to website/docs/clients/usage.mdx index 9826e4ce60..201f812d2b 100644 --- a/website/docs/clients/installation.mdx +++ b/website/docs/clients/usage.mdx @@ -1,5 +1,5 @@ --- -title: Installation +title: Usage --- :::warning @@ -8,6 +8,8 @@ The amount of changes in this new version is significant. **If you are upgrading ::: +## Installation + import { TabsLanguage } from '../../src/components/TabsLanguage'; import TabItem from '@theme/TabItem'; import { versions } from '../../src/generated/variables'; @@ -22,17 +24,17 @@ To get started, you first need to install `algoliasearch` (or any other availabl All of our clients comes with type definition, and are available for both `browser` and `node` environments. ```bash -yarn add algoliasearch@alpha +yarn add algoliasearch@beta # or -npm install algoliasearch@alpha +npm install algoliasearch@beta ``` Or use a specific package: ```bash -yarn add @algolia/client-search@alpha +yarn add @algolia/client-search@beta # or -npm install @algolia/client-search@alpha +npm install @algolia/client-search@beta ``` **Without a package manager** @@ -40,7 +42,7 @@ npm install @algolia/client-search@alpha Add the following JavaScript snippet to the `` of your website: ```html - + ``` @@ -58,7 +60,7 @@ pip install --upgrade 'algoliasearch>=4.0,<5.0' First, install Algolia PHP API Client via the composer package manager: ```bash -composer require algolia/algoliasearch-client-php +composer require algolia/algoliasearch-client-php "^4.0@beta" ``` @@ -66,7 +68,6 @@ composer require algolia/algoliasearch-client-php To get started, add the algoliasearch-client-java dependency to your project, either with [Maven](https://maven.apache.org/): - {` com.algolia @@ -102,9 +103,9 @@ dependencies { 2. Choose and add to your dependencies one of [Ktor's engines](https://ktor.io/docs/http-client-engines.html). - - **BOM** +**BOM** - Alternatively, you can use `algoliasearch-client-kotlin-bom` by adding the following dependency to your `build.gradle` file +Alternatively, you can use `algoliasearch-client-kotlin-bom` by adding the following dependency to your `build.gradle` file {`dependencies { @@ -133,27 +134,26 @@ go get github.com/algolia/algoliasearch-client-go/v4 - To get started, add the Algolia.Search Nugget dependency to your project: +To get started, first install the `Algolia.Search` client. - With dotnet CLI: +You can get the last version of the client from [NuGet](https://www.nuget.org/packages/Algolia.Search/). - - {`dotnet add package Algolia.Search --version ${versions.csharp}`} - +If you are using the .NET CLI, you can install the package using the following command: - Or directly in your `.csproj` file: +```bash +dotnet add package Algolia.Search --version +``` - - {` - -`} - +Or directly in your `.csproj` file: +```xml + +``` -## Using the client +## Example You can now import the Algolia API client in your project and play with it. @@ -438,23 +438,13 @@ func main() { ```csharp using Algolia.Search.Clients; using Algolia.Search.Models.Search; -using Algolia.Search.Utils; -// Instantiate the client var client = new SearchClient("", ""); -// Add a new record to your Algolia index -var saveResponse = await client.SaveObjectAsync("", - new { objectID = "123", firstName = "john", lastname = "doe" }); - -// Wait for the task to be processed on the Algolia side (optional) -await client.WaitForTaskAsync("", saveResponse.TaskID); - -// Fetch search results -var request = new SearchQuery(new SearchForHits("") { Query = "john" }); -var response = await client.SearchAsync(new SearchMethodParams(new List { request })); - -Console.WriteLine(response); +client.Search(new SearchMethodParams(new List +{ + new(new SearchForHits("") { Query = "" }) +})); ``` diff --git a/website/docs/contributing/add-new-api-client.md b/website/docs/contributing/add-new-api-client.md index b116c29a84..3082badba2 100644 --- a/website/docs/contributing/add-new-api-client.md +++ b/website/docs/contributing/add-new-api-client.md @@ -113,7 +113,7 @@ It also improves the readability of the specs. description: The single quotes are required. ``` -For information about documenting properties and parameters, see [Properties and parameters](./docs.md#properties-and-parameters). +For information about documenting properties and parameters, see [Properties and parameters](/docs/contributing/docs#properties-and-parameter-descriptions). ### Troubleshooting diff --git a/website/docs/contributing/add-new-language.md b/website/docs/contributing/add-new-language.md index 8c5e17eb83..a380735a94 100644 --- a/website/docs/contributing/add-new-language.md +++ b/website/docs/contributing/add-new-language.md @@ -71,7 +71,7 @@ The retry strategy cannot be generated and needs to be implemented outside of th Some Algolia clients (search and recommend) targets the default appId host (`${appId}-dsn.algolia.net`, `${appId}.algolia.net`, etc.), while clients like `personalization` have their own regional `host` (`eu` | `us` | `de`). -As the generator does not support reading `servers` in a spec file **yet**, hosts methods and variables are extracted with a custom script and create variables for you to use in the mustache templates, [read more here](/docs/contributing/add-new-api-client#generators). +As the generator does not support reading `servers` in a spec file **yet**, hosts methods and variables are extracted with a custom script and create variables for you to use in the mustache templates, [read more here](/docs/contributing/add-new-api-client#2-configure-the-generator). ### User Agent diff --git a/website/docs/contributing/setup-repository.md b/website/docs/contributing/setup-repository.md index 61960ccdb6..15559daba9 100644 --- a/website/docs/contributing/setup-repository.md +++ b/website/docs/contributing/setup-repository.md @@ -66,7 +66,7 @@ Once you've successfully built and mounted the Docker image, you can now play wi :::caution -You should run the commands via the [Docker container](#mounting-the-docker-image) to avoid issues. +You should run the commands via the [Docker container](#mounting-the-docker-images) to avoid issues. ::: diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 51a56c2cfd..ab19e6a961 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -114,6 +114,7 @@ function getLabel(str) { 'go', 'groovy', 'csharp', + 'python', ], }, navbar: { diff --git a/website/sidebars.js b/website/sidebars.js index b03040a9d6..e39eba6f5b 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -59,7 +59,7 @@ const sidebars = { label: 'Getting Started', collapsed: false, items: [ - 'clients/installation', + 'clients/usage', { type: 'category', label: 'Migration guide', @@ -69,13 +69,8 @@ const sidebars = { id: 'clients/migration-guides/index', }, items: [ - 'clients/migration-guides/go', - 'clients/migration-guides/java', 'clients/migration-guides/javascript', - 'clients/migration-guides/kotlin', 'clients/migration-guides/php', - 'clients/migration-guides/python', - 'clients/migration-guides/csharp', ], }, ],