Crates.io | google-places-api |
lib.rs | google-places-api |
version | |
source | src |
created_at | 2023-06-11 17:10:11.033049+00 |
updated_at | 2025-03-03 19:42:26.775154+00 |
description | Unofficial Google Places API for rust. |
homepage | |
repository | https://github.com/Arete-Innovations/google-places-api-rs |
max_upload_size | |
id | 887490 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A comprehensive Rust library to interact with the Google Places API, providing modules for Place Search, Place Details, Photos, and more. This library is designed to make working with the Google Places API intuitive and efficient for developers.
This library is a work in progress. Some features may not be fully implemented or could be subject to breaking changes. Use it at your own risk.
Add the following to your project
cargo add google_places_api
To start using the library, initialize the GooglePlacesAPI
instance:
use google_places_api::GooglePlacesAPI;
let api = GooglePlacesAPI::new(); // API key is loaded from the `GOOGLE_PLACES_API_KEY` environment variable.
use google_places_api::models::Location;
use google_places_api::GooglePlacesAPI;
use google_places_api::place_search::NearbySearchResult;
#[tokio::main]
async fn main() {
let api = GooglePlacesAPI::new();
let mut place_search = api.place_search();
let result: NearbySearchResult = place_search
.nearby_search() // San Francisco coordinates with a 1.5 km radius
.with_location(Location::new(37.7749, -122.4194))
.with_radius(1500)
.execute()
.await
.unwrap();
println!("Nearby Places: {:?}", result.display());
}
use google_places_api::GooglePlacesAPI;
use google_places_api::models::PlaceDetailsResult;
#[tokio::main]
async fn main() {
let api = GooglePlacesAPI::new();
let place_search = api.place_search();
let result: PlaceDetailsResult = place_search
.place_details() // Replace with a valid Place ID
.with_place_id("ChIJVXealLU_xkcRja_At0z9AGY")
.execute()
.await
.unwrap();
println!("Place Details: {:?}", result.display());
}
use google_places_api::GooglePlacesAPI;
use google_places_api::place_search::FindPlaceSearchResult;
#[tokio::main]
async fn main() {
let api = GooglePlacesAPI::new();
let mut place_search = api.place_search();
let result: FindPlaceSearchResult = place_search
.find_place()
.with_input("Googleplex")
.with_input_type("textquery")
.execute()
.await
.unwrap();
println!("Find Place Result: {:?}", result.display());
}
This library relies on the GOOGLE_PLACES_API_KEY
environment variable. Ensure it is set before running your application.
export GOOGLE_PLACES_API_KEY=your_api_key_here
Contributions are welcome! Please follow the guidelines below:
This project is licensed under the MIT License. See the LICENSE
file for details.
For support or questions, please open an issue in the GitHub repository.
This library is not an official Google product and is not affiliated with or endorsed by Google.