Skip to main content

The python client for MeiliSearch API.

Project description

MeiliSearch Python Client

PyPI version Licence test Status

The python client for MeiliSearch API.

MeiliSearch provides an ultra relevant and instant full-text search. Our solution is open-source and you can check out our repository here.

Here is the MeiliSearch documentation 📖

Table of Contents

🔧 Installation

With pip in command line:

pip install meilisearch

Run MeiliSearch

There are many easy ways to download and run a MeiliSearch instance.

For example, if you use Docker:

$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest --api-key=apiKey

🚀 Getting started

Add documents

import meilisearch
client = meilisearch.Client("", "apiKey")
indexes = client.get_index('index_uid')

documents = [
  { "id": 123,  "title": 'Pride and Prejudice' },
  { "id": 456,  "title": 'Le Petit Prince' },
  { "id": 1,    "title": 'Alice In Wonderland' },
  { "id": 1344, "title": 'The Hobbit' },
  { "id": 4,    "title": 'Harry Potter and the Half-Blood Prince' },
  { "id": 42,   "title": 'The Hitchhiker\'s Guide to the Galaxy' }

index.add_documents(documents) # asynchronous

⚠️ The method add_documents is asynchronous.
It means that your new documents addition will be added to the stack of actions. It may not be instantly processed. Check for the updates tracking.

Search in index

# MeiliSearch is typo-tolerant:{
  "q": 'hary pottre'


  "hits" => [{
    "id" => 4,
    "title" => "Harry Potter and the Half-Blood Prince"
  "offset" => 0,
  "limit" => 20,
  "processingTimeMs" => 1,
  "query" => "hary pottre"

Create an index

If you don't have any index yet, you can create one with:

index = client.create_index(name='Books')

🎬 Examples

You can check out the API documentation.


Create an index

# Create an index
# Create an index with a specific uid (uid must be unique)
client.create_index(name= 'Books', uid= 'books')
# Create an index with a schema
schema = {
  "id":    ["displayed", "indexed", "identifier"],
  "title": ["displayed", "indexed"]
client.create_index(name= 'Books', schema= schema)

List all indexes


Get an index object

index = client.get_index(uid="books")


Fetch documents

# Get one document
# Get documents by batch
index.documents({ "offset": 10 , "limit": 20 })

Add documents

index.add_documents([{ "id": 2, "title": 'Madame Bovary' }])


    "updateId": 1

With this updateId you can track your operation status.

Delete documents

# Delete one document
# Delete several documents
index.delete_documents([1, 42])
# Delete all documents 

Update status

# Get one update
# Parameter: the updateId got after an asynchronous request (e.g. documents addition)
# Get all updates


Basic search{
  "q": "prince"
    "hits": [
            "id": 456,
            "title": "Le Petit Prince"
            "id": 4,
            "title": "Harry Potter and the Half-Blood Prince"
    "offset": 0,
    "limit": 20,
    "processingTimeMs": 13,
    "query": "prince"

Custom search

All the supported options are described in this documentation section.

response ={
  "q": "prince",
  "limit": 1
    "hits": [
            "id": 456,
            "title": "Le Petit Prince"
    "offset": 0,
    "limit": 1,
    "processingTimeMs": 10,
    "query": "prince"

🤖 Compatibility with MeiliSearch

This package works for MeiliSearch v0.8.x.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for meilisearch, version 0.8.1
Filename, size File type Python version Upload date Hashes
Filename, size meilisearch-0.8.1-py3-none-any.whl (16.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size meilisearch-0.8.1.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page