Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

@pretto/places

Package Overview
Dependencies
3
Maintainers
1
Versions
8
Issues
File Explorer

Advanced tools

@pretto/places

[![npm version](https://img.shields.io/npm/v/@pretto/places.svg?style=flat)](https://www.npmjs.com/package/@pretto/places)

    0.10.0latest

Version published
Maintainers
1
Yearly downloads
611

Weekly downloads

Readme

Source

@pretto/places

npm version

Allows you to search for an address, a postcode or a French department. You can also search a country.

FAQ

How to implement the library?

yarn add @pretto/places

For municipality and zipcode

import { municipalitySearch } from '@pretto/places' const result = await municipalitySearch.get("paris", { limit: 21 }) // expected result : Paris (75001), Paris (75002), Paris (75003), ..., Paris (75020) // result object format : [ { "label": "Paris (75001)", "value": { "city": "Paris", "country": "fr", "zipcode": "75001" } }, { "label": "Paris (75002)", "value": { "city": "Paris", "country": "fr", "zipcode": "75002" } }, ... ]

For department only

import { municipalitySearch } from '@pretto/places' const result = await municipalitySearch.get("paris", { departmentOnly: true, limit: 21 }) // expected result : Paris (75), Parisot(81), Parisot (82), Cormeilles-en-Parisis (95), ... // result object format : [ { "label": "Paris (75)", "value": { "city": "Paris", "country": "fr", "zipcode": "75" } }, { "label": "Parisot (81)", "value": { "city": "Parisot", "country": "fr", "zipcode": "81" } }, ... ]

For Address (France only)

import { addressSearch } from '@pretto/places' const result = await addressSearch.get("55 rue de paradis", { limit: 10 }) // expected result : 55 Rue de Paradis 75010 Paris (75010), 55 Rue de Paradis 51160 Hautvillers (51160)... // result object format : [ { "label": "55 Rue de Paradis 75010 Paris (75010)", "value": { "city": "Paris", "country": "fr", "street": "55 Rue de Paradis", "zipcode": "75010" } }, { "label": "55 Rue de Paradis 51160 Hautvillers (51160)", "value": { "city": "Hautvillers", "country": "fr", "street": "55 Rue de Paradis", "zipcode": "51160" } }, ... ]

For country

import { countrySearch } from '@pretto/places' const countriesApi = countrySearch.init(ALGOLIA_COUNTRIES_APP_ID, ALGOLIA_COUNTRIES_API_KEY) const results = await countriesApi.get("al", { limit: 10 }) // expected result : Allemagne (99109), Albanie (99125), Algerie (99352) // result object format : [ { "label": "Allemagne (99109)", "value": "de" }, { "label": "Albanie (99125)", "value": "al" }, { "label": "Algerie (99352)", "value": "dz" } ]

How to publish a new version?

When a branch is merged into master, it will automatically deploy a new version to npm.

How it works?

This library is based on the API of data.gouv. These data are quite precise and are regularly updated: title

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc