Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khalyomede/geo-api-gouv-adresse
Everything you can do from the Geo API Gouv adresse endpoint.
https://github.com/khalyomede/geo-api-gouv-adresse
address api geojson gouv
Last synced: about 1 month ago
JSON representation
Everything you can do from the Geo API Gouv adresse endpoint.
- Host: GitHub
- URL: https://github.com/khalyomede/geo-api-gouv-adresse
- Owner: khalyomede
- License: mit
- Created: 2020-08-27T10:26:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-27T11:05:38.000Z (over 4 years ago)
- Last Synced: 2024-11-14T12:02:09.040Z (about 1 month ago)
- Topics: address, api, geojson, gouv
- Language: TypeScript
- Homepage: https://npmjs.com/package/geo-api-gouv-adresse
- Size: 193 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# geo-api-gouv-adresse
Everything you can do from the Geo API Gouv adresse endpoint.
[![npm](https://img.shields.io/npm/v/geo-api-gouv-adresse)](https://www.npmjs.com/package/geo-api-gouv-adresse) [![NPM](https://img.shields.io/npm/l/geo-api-gouv-adresse)](https://github.com/khalyomede/geo-api-gouv-adresse/blob/master/LICENSE) [![npm (prod) dependency version](https://img.shields.io/npm/dependency-version/geo-api-gouv-adresse/axios)](https://www.npmjs.com/package/axios) [![Build Status](https://travis-ci.com/khalyomede/geo-api-gouv-adresse.svg?branch=master)](https://travis-ci.com/khalyomede/geo-api-gouv-adresse) [![codecov](https://codecov.io/gh/khalyomede/geo-api-gouv-adresse/branch/master/graph/badge.svg)](https://codecov.io/gh/khalyomede/geo-api-gouv-adresse) [![Maintainability](https://api.codeclimate.com/v1/badges/1b84e5be2b39745bbdbb/maintainability)](https://codeclimate.com/github/khalyomede/geo-api-gouv-adresse/maintainability) ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/geo-api-gouv-adresse) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/geo-api-gouv-adresse) ![npm type definitions](https://img.shields.io/npm/types/geo-api-gouv-adresse)
## Summary
- [About](#about)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [API](https://khalyomede.github.io/geo-api-gouv-adresse/globals.html)## 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](https://github.com/Raesta/gouv-geo-api), 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 `` of your HTML document, add these CDNs links (don't add axios if it is already present).
```html
Some website
// Call the library here...
```
### Node.JS
In your root folder, open a terminal and install the library:
```bash
npm install --save-dev geo-api-gouv-adresse
```## Examples
For a complete list of options, see the [online documentation](https://khalyomede.github.io/geo-api-gouv-adresse/interfaces/_isearchoptions_.isearchoptions.html).
- [Search from an address](#search-from-an-address)
- [Limiting search results](#limiting-search-results)### Search from an address
In this example, we will use a partially complete address, and get the results for this address.
#### Browser
```javascript
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
```javascript
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](https://geo.api.gouv.fr/adresse), and the [Geocode JSON spec](https://github.com/geocoders/geocodejson-spec/tree/master/draft).
### Limiting search results
In this example, we will limit the number of results for the street we are searching for.
#### Browser
```javascript
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
```javascript
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();
```