mindat-rs
A Rust client library for the Mindat API.
Mindat is the world's largest open database of minerals, rocks, meteorites, and the localities where they come from. This crate provides a type-safe, async interface to access mineralogical data.
Features
- Full coverage of the Mindat API endpoints
- Strongly-typed request builders and response models
- Async/await support using tokio
- Pagination helpers
- Comprehensive error handling
- Optional GUI application built with Tauri (supports desktop and mobile)
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Quick Start
use ;
async
Authentication
Most API endpoints require authentication with a Mindat API token. You can obtain a token from your Mindat account settings.
Some endpoints (like minerals_ima) can be accessed without authentication:
use ;
let client = anonymous;
let minerals = client.minerals_ima.await?;
Examples
Search for minerals by element composition
use ;
let client = new;
// Find minerals containing copper and sulfur
let query = new
.with_elements
.ima_approved
.page_size;
let minerals = client.geomaterials.await?;
Filter by physical properties
use ;
let client = new;
// Find hard, dense minerals in the cubic system
let query = new
.crystal_systems
.hardness_range
.density_range;
let minerals = client.geomaterials.await?;
Search localities
use ;
let client = new;
// Find gold localities in Brazil
let query = new
.country
.with_elements;
let localities = client.localities.await?;
Browse IMA minerals
use ;
// IMA list doesn't require authentication
let client = anonymous;
let query = new
.search
.page_size;
let minerals = client.minerals_ima.await?;
Pagination
use ;
let client = new;
// Get first page
let query = new.page.page_size;
let page1 = client.geomaterials.await?;
println!;
// Check if there are more pages
if page1.has_next
Custom client configuration
use MindatClient;
use Duration;
let client = builder
.token
.timeout
.build?;
Available Endpoints
| Endpoint | Method | Description |
|---|---|---|
countries() |
GET | List all countries |
country(id) |
GET | Get a specific country |
geomaterials(query) |
GET | Search minerals with filters |
geomaterial(id) |
GET | Get a specific geomaterial |
geomaterial_varieties(id) |
GET | Get varieties of a geomaterial |
geomaterials_search(q, size) |
GET | Quick search for geomaterials |
localities(query) |
GET | Search localities with filters |
locality(id) |
GET | Get a specific locality |
locality_ages(page) |
GET | List locality ages |
locality_age(id) |
GET | Get a specific age |
locality_statuses(page) |
GET | List locality statuses |
locality_status(id) |
GET | Get a specific status |
locality_types(page) |
GET | List locality types |
locality_type(id) |
GET | Get a specific type |
minerals_ima(query) |
GET | List IMA-approved minerals |
mineral_ima(id) |
GET | Get a specific IMA mineral |
dana8_groups() |
GET | Dana 8th ed. classification groups |
dana8_subgroups() |
GET | Dana 8th ed. classification subgroups |
dana8(id) |
GET | Get a specific Dana classification |
strunz10_classes() |
GET | Nickel-Strunz 10th ed. classes |
strunz10_subclasses() |
GET | Nickel-Strunz 10th ed. subclasses |
strunz10_families() |
GET | Nickel-Strunz 10th ed. families |
strunz10(id) |
GET | Get a specific Strunz classification |
Error Handling
The library provides detailed error types:
use ;
let client = new;
let query = new.name;
match client.geomaterials.await
GUI Application (Optional)
This crate includes an optional GUI application built with Tauri for testing and exploring the Mindat API. The GUI provides a user-friendly interface to:
- Search minerals by name, elements, or properties
- Browse IMA-approved minerals (no authentication required)
- Explore localities and countries
- View classification systems (Dana-8, Strunz-10)
- Get detailed mineral information
Prerequisites
Linux:
# Ubuntu/Debian
# Fedora
macOS:
Windows:
- Install Microsoft Visual Studio C++ Build Tools
- Install WebView2
Building the GUI
# From the repository root
# Or run in development mode
Running the GUI
After building, the executable will be at:
- Linux/macOS:
target/release/mindat-gui - Windows:
target\release\mindat-gui.exe
Using the GUI
- Launch the application
- Enter your Mindat API token (from mindat.org) and click "Connect"
- Use the sidebar to select different API endpoints
- The "IMA Minerals" endpoint works without authentication
Mobile Support (iOS/Android)
The GUI is built with Tauri 2.0, which supports mobile platforms. To build for iOS:
# Install Tauri CLI
# Initialize iOS (requires Xcode)
# Build for iOS
For Android:
# Initialize Android (requires Android Studio)
# Build for Android
See the Tauri Mobile Guide for detailed setup instructions.
Related Projects
- OpenMindat - R package for Mindat API
- mindat_api_test - Python examples
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- Mindat.org for providing the mineralogical database and API
- The OpenMindat R package for implementation reference