|
1 | | -<p align="center"> |
2 | | - <h4 align="center">The readme/code you are seeing it's part of upcoming release</h4> |
3 | | - <h2 align="center">Algolia API Client Python v2</h2> |
4 | | -</p> |
| 1 | +# Algolia Search API Client for Python |
5 | 2 |
|
6 | | -**[Algolia Search](https://www.algolia.com)** is a hosted search engine capable of delivering real-time results from the first keystroke. |
| 3 | +[Algolia Search](https://www.algolia.com) is a hosted search engine capable of delivering realtime results from the first keystroke. |
7 | 4 |
|
8 | | -This readme/code introduces the upcoming Algolia API Client Python v2, the next major release of our API Client. This release includes several new features along with the latest bug fixes and improvements: |
| 5 | +The **Algolia Search API Client for Python** lets |
| 6 | +you easily use the [Algolia Search REST API](https://www.algolia.com/doc/rest-api/search) from |
| 7 | +your Python code. |
9 | 8 |
|
10 | | -- Supports Python: 2.7, 3.4, 3.5, 3.6, and 3.7. |
11 | | -- Works in synchronous and **asynchronous** environments. |
12 | | -- Tons of new methods: waitable response objects, `replace_all_objects`,`clear_objects`, and more! |
| 9 | +[](https://travis-ci.org/algolia/algoliasearch-client-python) [](http://badge.fury.io/py/algoliasearch) |
13 | 10 |
|
14 | | -**Development Status**: 4 - Beta. |
15 | 11 |
|
16 | | -**Upgrade Guide**: [Upgrade Guide](https://gist.github.com/nunomaduro/ddc2364465314390c9cfa94482ad2774) |
| 12 | +We implemented an asynchronous version of the client that may suit your need if |
| 13 | +you are using a framework such as `aiohttp` in your backend. This version can |
| 14 | +be found [here](https://github.com/algolia/algoliasearch-client-python-async). |
17 | 15 |
|
18 | | -You'd like to contribute? Before start, we want to let you know that your **feedback** is important to us! Please consider start using this `v2` today! Found a bug or see something that can improved? Report it here: [github.com/algolia/algoliasearch-client-python/issues](https://github.com/algolia/algoliasearch-client-python/issues). |
19 | 16 |
|
20 | | -First, install Algoliasearch - API Client Python v2: |
21 | | -``` |
22 | | -pip install --pre algoliasearch |
23 | | -``` |
24 | 17 |
|
25 | | -### Example with synchronous usage: |
26 | 18 |
|
27 | | -```py |
28 | | -import os |
| 19 | +## API Documentation |
29 | 20 |
|
30 | | -from algoliasearch.search_client import SearchClient |
| 21 | +You can find the full reference on [Algolia's website](https://www.algolia.com/doc/api-client/python/). |
31 | 22 |
|
32 | | -client = SearchClient.create( |
33 | | - 'ALGOLIA_APPLICATION_ID', |
34 | | - 'ALGOLIA_ADMIN_KEY' |
35 | | -) |
| 23 | +## Getting Help |
36 | 24 |
|
37 | | -index = client.init_index('articles') |
38 | | - |
39 | | -index.save_objects([ |
40 | | - {'objectID': 1, 'firstname': 'Jimmie', 'lastname': 'Barninger'}, |
41 | | - {'objectID': 2, 'firstname': 'Warren', 'lastname': 'Speach'} |
42 | | -]).wait() |
43 | | - |
44 | | -hits = index.search('Jimmie') |
45 | | - |
46 | | -print(hits) |
47 | | -``` |
48 | | - |
49 | | -### Example with asynchronous usage: |
50 | | - |
51 | | -First, require asynchronous libraries: |
52 | | - |
53 | | -``` |
54 | | -pip install 'asyncio>=3.4,<4.0' 'aiohttp>=2.0,<4.0' 'async_timeout>=2.0,<4.0' |
55 | | -``` |
56 | | - |
57 | | -Then, asynchronous methods are available using the `async` suffix: |
58 | | - |
59 | | -| synchronous | asynchronous | |
60 | | -|-------------- |-------------------- | |
61 | | -| search | search_async | |
62 | | -| save_objects | save_objects_async | |
63 | | -| set_settings | set_settings_async | |
64 | | -| save_synonyms | save_synonyms_async | |
65 | | -| ... | ... | |
66 | | - |
67 | | - |
68 | | -```py |
69 | | -import asyncio |
70 | | - |
71 | | -from algoliasearch.search_client import SearchClient |
72 | | -from algoliasearch.responses import MultipleResponse |
73 | | - |
74 | | -app_id = 'ALGOLIA_APPLICATION_ID' |
75 | | -api_key = 'ALGOLIA_ADMIN_KEY' |
76 | | - |
77 | | -async def main(): |
78 | | - async with SearchClient.create(app_id, api_key) as client: |
79 | | - index = client.init_index('articles') |
80 | | - |
81 | | - response = await index.save_objects_async([ |
82 | | - {'objectID': 1, 'foo': 'bar'}, |
83 | | - {'objectID': 2, 'foo': 'foo'} |
84 | | - ]) |
85 | | - |
86 | | - for raw_response in response.raw_responses: |
87 | | - await index.wait_task_async(raw_response['taskID']) |
88 | | - |
89 | | - print(await index.search_async('')) |
90 | | - |
91 | | -asyncio.run(main()) |
92 | | - |
93 | | -``` |
94 | | - |
95 | | -### License |
96 | | - |
97 | | -Algolia API Client Python is an open-sourced software licensed under the [MIT license](LICENSE). |
| 25 | +- **Need help**? Ask a question to the [Algolia Community](https://discourse.algolia.com/) or on [Stack Overflow](http://stackoverflow.com/questions/tagged/algolia). |
| 26 | +- **Found a bug?** You can open a [GitHub issue](https://github.com/algolia/algoliasearch-client-python/issues). |
0 commit comments