Skip to content

docs: add code samples APIC-348 #202

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

Merged
merged 3 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
97 changes: 97 additions & 0 deletions website/docs/gettingStarted.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: Getting started
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs
groupId="language"
defaultValue="js"
values={[
{ label: 'JavaScript', value: 'js', }
]
}>
<TabItem value="js">

## Installation

To get started, you first need to install `algoliasearch` (or any other available API client package)

```bash
yarn add @experimental-api-clients-automation/algoliasearch
```

Or use a specific package to reduce bundle size:

```bash
yarn add @experimental-api-clients-automation/client-search
```

You can find the full list of available packages [here](https://www.npmjs.com/org/experimental-api-clients-automation).

### Without a package manager

Add the JavaScript to your `<head>`

```html
<script src="https://cdn.jsdelivr.net/npm/@experimental-api-clients-automation/[email protected]/dist/algoliasearch.umd.browser.js"></script>
```

## Using the client

Then you need to import the correct package, depending on your choice:

```js
import { algoliasearch } from 'algoliasearch';

const client = algoliasearch(appId, apiKey);

// And access analytics or personalization client
const analyticsClient = algoliaClient.initAnalytics(analyticsAppId, analyticsApiKey);
const personalizationCilent = client.initPersonalization(personalizationAppId, personalizationApiKey, 'eu');
```

```js
import { searchApi } from '@algolia/client-search';

const client = searchApi(appId, apiKey);
```

It is possible to customize the client by passing optional parameters:

```js
const client = searchApi(appId, apiKey, {
requester: customRequester(),
hosts: [{
url: 'my.custom.host.net',
accept: 'read',
protocol: 'https',
}]
})
```

Once the client is setup, you can enjoy all of Algolia API !

```js
const res = await client.search({
indexName: 'my-index',
searchParams: { query: 'words to query' },
});

console.log('Search result', res.hits);
```


Or with the `personalization` client

```js
const res = await personalizationCilent.getUserTokenProfile({
userToken: 'token',
});

console.log('User scores', res.scores);
```

</TabItem>
</Tabs>
28 changes: 15 additions & 13 deletions website/docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ title: Introduction

# Introduction

API Clients Automation by Algolia
This documentation hosts informations about the [Generated Algolia API clients](https://github.com/algolia/api-clients-automation)

## Available specs
## Contributing

- [A/B Testing specs](/specs/abtesting)
- [analytics specs](/specs/analytics)
- [insights specs](/specs/insights)
- [personalization specs](/specs/personalization)
- [query-suggestions specs](/specs/query-suggestions)
- [recommend specs](/specs/recommend)
- [search specs](/specs/search)
- [sources specs](/specs/sources)
- [predict specs](/specs/predict)
To contribute to the repository, make sure to take a look at our guidelines and recommendations:

## Repository
- [Setup the repository tooling](/docs/setupRepository): to install our tooling.
- [Add a new client](/docs/addNewClient): to add a new client spec to generate.
- [Support a new language](/docs/addNewLanguage): to add a new supported language to the API clients.

[API Clients Automation](https://github.com/algolia/api-clients-automation)
CLI commands can be found at [CLI > specs commands](/docs/specsCommands) and [CLI > generation commands](/docs/generationCommands)

## Testing

Generated clients can be tested via the [Common Test Suite](/docs/commonTestSuite) or the [playground](/docs/playground)

## Feedbacks

Any feedbacks can be reported using [GitHub issues](https://github.com/algolia/api-clients-automation/issues)
15 changes: 0 additions & 15 deletions website/docs/setupRepository.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ Stops `dev` container and clean the built image
yarn docker:clean
```

## Contributing

To contribute to the repository, take a look at our guidelines and recommendations:

- [Add a new client](/docs/addNewClient): to add a new client spec to generate.
- [Support a new language](/docs/addNewLanguage): to add a new supported language to the API clients.

CLI commands can be found at [CLI > specs commands](/docs/specsCommands) and [CLI > generation commands](/docs/generationCommands)

## Testing

Generated clients can be tested via the [Common Test Suite](/docs/commonTestSuite) or the [playground](/docs/playground)

You can make changes locally and run commands through the docker container.

## Troubleshooting

:::caution
Expand Down
2 changes: 1 addition & 1 deletion website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const sidebars = {
{
type: 'category',
label: 'Getting Started',
items: ['introduction'],
items: ['introduction', 'gettingStarted'],
},
{
type: 'category',
Expand Down