npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pretto/places

v0.46.1

Published

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

Readme

@pretto/places

npm version

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

The library is typed but you can retrieve the types in the dist/types folder if needed

FAQ

How to implement the library?

yarn add @pretto/places

For municipality and zipcode

import { searchPlaces } from '@pretto/places';
import { MunicipalitySearchResult } from '@pretto/places/dist/types';

const result = await searchPlaces("paris", { limit: 21 })

// result object format :
[
    {
        label: "Paris 1er Arrondissement 75001",
        value: {
            center: [2.3359, 48.862],
            city: "Paris 1er Arrondissement",
            country: "fr",
            outline: [[{"latitude": 48.870688, "longitude": 2.347918},...]],
            zipcode: "75001",
        },
    },
    {
        label: "Paris 2e Arrondissement 75002",
        value: {
            center: [2.3411, 48.8677],
            city: "Paris 2e Arrondissement",
            country: "fr",
            outline: [Array],
            zipcode: "75002",
        },
    },
    ...
]

For department only

import { searchDepartment } from '@pretto/places'
import { DepartmentSearchResult } from '@pretto/places/dist/types';

const result = await searchDepartment("pa", { limit: 21 })

// result object format :
[
    {
        label: "Paris (75)",
        value: {
            code: "75",
            codeRegion: "11",
            country: "fr",
            region: {
                code: "11",
                nom: "Île-de-France"
            }
        },
    },
    {
        label: "Pas-de-Calais (62)",
        value: {
            code: "62",
            codeRegion: "32",
            country: "fr",
            region: {
                code: "32",
                nom: "Hauts-de-France"
            }
        },
    },
    ...
]

For Address (France only)

import { addressSearch } from '@pretto/places'
import { AddressSearchResult } from '@pretto/places/dist/types';

const result = await addressSearch.get("55 rue de paradis", { limit: 10 })

// result object format :
[
  {
    label: "42 Rue de Paradis 75010, Paris",
    value: {
      city: "Paris",
      country: "fr",
      street: "42 Rue de Paradis",
      zipcode: "75010",
    },
  },
  {
    label: "42 Rue de Paradis 95100, Argenteuil",
    value: {
      city: "Argenteuil",
      country: "fr",
      street: "42 Rue de Paradis",
      zipcode: "95100",
    },
  },
    ...
]

For country

import { searchCountry } from '@pretto/places'

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

For reverse geolocalisation

import { searchByCoordinates } from '@pretto/places'
import { MunicipalitySearchResult } from '@pretto/places/dist/types';

const results = await searchByCoordinates({ latitude: 48.87571729159758, longitude: 2.3503000982950883 })

// result object format :
[
  {
    label: "Paris 10e Arrondissement 75010",
    value: {
      center: [Object],
      city: "Paris 10e Arrondissement",
      country: "fr",
      outline: [Array],
      zipcode: "75010",
    },
  },
];

Options

You can pass options to the search function.

| Option | Type | Default Value | | ------------ | ----------- | --------------- | | debouncetime | number | 300 | | limit | number | 10 | | signal | AbortSignal | AbortController |

const debounceValue = 1000 // --- 1000 = 1s
const results = await searchPlaces('paris', { debouncetime: debounceValue, limit: 100 })

The signal allows you to abort a request if you no longer want to wait for the response. If it's not defined in the options, the library will use a locally managed AbortController(). If you need to manage your own abort, you can do it like this:

let controller = null
...
if(!search) {
   controller.abort()
   setResults([])
   return
}

if(controller) {
  controller.abort()
}

controller = new AbortController()
const places = await searchPlaces(search, {signal: controller.signal})

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