
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
google-place-fields
Advanced tools
TypeScript definitions for Google Places API v1 fields, providing strongly-typed interfaces for responses from the Google Places API.
npm install google-place-fields
# or
pnpm install google-place-fields
# or
yarn add google-place-fields
This package provides TypeScript interfaces for Google Places API v1 responses. You can use these interfaces to type-check your Google Places API responses.
import {
Place,
PlaceDetailsResponse,
SearchPlacesResponse,
GooglePlaceConverter
} from 'google-place-fields';
// Example: Using with fetch API
async function getPlaceDetails(placeName: string): Promise<Place> {
const response = await fetch(`https://places.googleapis.com/v1/${placeName}?key=YOUR_API_KEY`);
const data = await response.json();
// Convert the raw JSON to a typed PlaceDetailsResponse
const typedResponse = GooglePlaceConverter.toPlaceDetailsResponse(data);
return typedResponse.place;
}
// Example: Using with a search response
async function searchPlaces(query: string): Promise<Place[]> {
const response = await fetch(`https://places.googleapis.com/v1/places:searchText`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Goog-Api-Key': 'YOUR_API_KEY'
},
body: JSON.stringify({ textQuery: query })
});
const data = await response.json();
// Convert the raw JSON to a typed SearchPlacesResponse
const typedResponse = GooglePlaceConverter.toSearchPlacesResponse(data);
return typedResponse.places;
}
This package includes comprehensive type definitions for Google Places API v1 responses, including:
Place
: The main interface representing a place with all its propertiesLocalizedText
: Interface for localized text content with language codeAddressComponent
: Interface for structured address componentsPlusCode
: Interface for Plus Code location referenceLatLng
: Interface for geographical coordinatesViewport
: Interface for location viewportAuthorAttribution
: Interface for author informationReview
: Interface for place reviewsPhoto
: Interface for place photosOpeningHours
: Interface for opening hours dataPeriod
: Interface for time periods when a place is openPoint
: Interface for opening/closing time pointsTimePeriod
: Interface for time periodsBusinessStatus
: Enum for business operation statusPriceRange
: Interface for price level informationMoney
: Interface for representing currency amountsFuelOptions
: Interface for fuel station informationEVChargeOptions
: Interface for EV charging station dataAccessibilityOptions
: Interface for accessibility informationGoogleMapsLinks
: Interface for various Google Maps action linksAll types are fully documented with JSDoc comments directly from the Google Places API documentation.
All interfaces are based on the Google Places API v1 Reference.
MIT
FAQs
TypeScript definitions for Google Places API v1 fields
The npm package google-place-fields receives a total of 3 weekly downloads. As such, google-place-fields popularity was classified as not popular.
We found that google-place-fields demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.