Warning
The API is currently down at https://lychee-engine.pages.dev/ because it was hosted on the community tier of https://www.shuttle.dev/ which they have sunsetted. I have no plans for further maintaining the API anytime soon so feel free to fork it and modify on your own.
This repository contains the source code for Lychee API
The code works the same as mentioned in https://lychee-engine.pages.dev/
| Route | Description | Example |
|---|---|---|
| index | returns the number of documents | localhost:3000/index |
| linearsearch | returns the search results | localhost:3000/linearsearch?name=pokemon&platform=Gameboy Advance |
| indexedsearch | returns the search results | localhost:3000/indexedsearch?name=pokemon&platform=Gameboy Advance |
| Parameter | Description | Required | Example |
|---|---|---|---|
| name | name of the game | Yes | localhost:3000/search?name=pokemon |
| platform | platform of the game | Yes | localhost:3000/search?name=pokemon&platform=Gameboy Advance |
| Limit | number of results to return | No | localhost:3000/search?name=pokemon&platform=Gameboy Advance&limit=10 |
- Put your MongoDB URI in the fetch_games function in
lib.rsfile.
async fn fetch_games() -> Result<HashMap<String, Item>, Box<dyn Error>> {
let uri= "Your MongoDB URI";
let client_options= ClientOptions::parse_with_resolver_config(uri, ResolverConfig::cloudflare()).await?;
let client= Client::with_options(client_options)?;
let collection= client.database("Game_Cache").collection::<Item>("Games");
let mut cursor= collection.find(None, None).await?;
let mut cache= HashMap::new();
while let Some(document)= cursor.try_next().await.unwrap() {
let id= document._id.to_string();
cache.insert(id, document);
}
return Ok(cache);
}- Run the main file, the API will run on
localhost:3000