#meilisearch #api-client #library

meilisearch-api-client

A api client for Meilisearch

1 unstable release

0.0.1 Apr 2, 2023

#15 in #meilisearch

MIT license

23KB
477 lines

meilisearch-api-client

crate

API Documentation


lib.rs:

A well designed api client for MeiliSearch.

CAVEAT: WIP

Quick Start

To get you started quickly, the easiest and highest-level way to create index is to use create_index;

use meilisearch_api_client::{Config, client::Client, CreateIndexRequest};

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
   let uid  = "demo".to_string();
   let name = "demoname".to_string();

   // construct a request param
   let req_data = CreateIndexRequest { uid, name, primary_key: None};

   // config contains MeiliSearch server's host and port
   let config = Config::new("http://127.0.0.1".to_string(), 7700);

   // Client is api interface, using async/await.
   let res = Client::new(config).create_index(req_data).await;
   match res {
       Ok(index) => {
           println!("ceate index: {:?}", index);
       },
       Err(err) => {
           println!("err: {:?}", err);
       }
    }
    
    Ok(())
}

Output:

{"name":"demoname","uid":"demo","createdAt":"2020-05-14T08:56:24.483670375Z","updatedAt":"2020-05-14T08:56:24.484410846Z","primaryKey":null}

Installation

This crate requires a MeiliSearch server to run. See here to install and run MeiliSearch.
For the user guide and further documentation, can be found here

Dependencies

~29MB
~595K SLoC