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 🙏

© 2024 – Pkg Stats / Ryan Hefner

geo-api-gouv-adresse

v0.1.0

Published

Everything you can do from the Geo API Gouv adresse endpoint.

Downloads

94

Readme

geo-api-gouv-adresse

Everything you can do from the Geo API Gouv adresse endpoint.

Build Status codecov

Summary

About

This library is a wrapper for using the Data Gouv API Adresse endpoint.

It offers no more features than what is possible with the endpoint, and the options name are the exact same.

I created the library because I have only seen one package, that was not tested, and not up to date.

Requirements

If you use it via the CDN link, you need to use axios alongside the library (check the examples).

If you use it on Node.JS, you already have NPM and (Node or Yarn) installed in your machine, and axios will be pulled at the installation.

Installation

Browser

In the <body> of your HTML document, add these CDNs links (don't add axios if it is already present).

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Some website</title>
    </head>
    <body>
        <!-- ... -->
        <script
            type="text/javascript"
            src="https://unpkg.com/[email protected]/dist/axios.min.js"
        ></script>
        <script
            type="text/javascript"
            src="https://unpkg.com/[email protected]/dist/index.min.js"
        ></script>
        <script type="text/javascript">
            // Call the library here...
        </script>
    </body>
</html>

Node.JS

In your root folder, open a terminal and install the library:

npm install --save-dev geo-api-gouv-adresse

Examples

For a complete list of options, see the online documentation.

Search from an address

In this example, we will use a partially complete address, and get the results for this address.

Browser

geoApiGouvAdresse
    .search("8 bd du port")
    .then(function (response) {
        response.forEach(function (address) {
            console.log(
                "found a matching street name:",
                address.properties.name
            );
        });
    })
    .catch(function (error) {
        console.log("an error occured");
    });

Node.JS

import { search } from "geo-api-gouv-adresse";
// or
// const { search } = require("geo-api-gouv-adresse");

const main = async () => {
    let results = {};

    try {
        results = await search("8 bd du");
    } catch (exception) {
        console.error("an error occured");

        return;
    }

    for (const address of results.features) {
        console.log(`found a matching street name: ${address.properties.name}`);
    }
};

main();

For a detail on how the response is composed, see the official Geo API gouv adresse website, and the Geocode JSON spec.

Limiting search results

In this example, we will limit the number of results for the street we are searching for.

Browser

geoApiGouvAdresse
    .search("8 bd du port", { limit: 10 })
    .then(function (response) {
        response.forEach(function (address) {
            console.log(
                "found a matching street name:",
                address.properties.name
            );
        });
    })
    .catch(function (error) {
        console.log("an error occured");
    });

Node.JS

import { search } from "geo-api-gouv-adresse";
// or
// const { search } = require("geo-api-gouv-adresse");

const main = async () => {
    let response = {};

    try {
        response = await search("8 bd du", {
            limit: 10,
        });
    } catch (exception) {
        console.error("an error occured");

        return;
    }

    for (const address of response.features) {
        console.log(`found a matching street name: ${address.properties.name}`);
    }
};

main();