2gis-api 中文文档教程

发布于 11年前 浏览 25 更新于 3年前

2GIS API for Node.js

About module

该模块实现了对 NodeJS 的 API 2GIS 调用。 目前,以下部分 API:

  • Catalog API
  • Geo data API

Installation

npm install 2gis-api

Usage

    var api = require ('2gis-api');

    api.configure({
        serviceUrl: 'catalog.api.2gis.ru', // This is optional default path.
        version: 1.3, // This is optional default version.

        key: 'YOUR_API_KEY' // Required. Get it from the vendor.
    });

    api.projectList({}, function (err, data) {
        console.log('projectList', err, data);
    });

    api.rubricator({
        where: 'Красноярск',
        show_children: 1
    }, function (err, data) {
        console.log('rubricator', err, data);
    });

重要! 要获取填写申请表所需的 API 密钥。

Catalog API

"projectList"

该方法返回一个项目列表(一个大城市和周围的村庄)。 传入和传出参数的值在 API 方法文档 中列出。

"rubricator"

选择此评分细则为其父级的评分细则。 API 方法文档

从给定的查询中搜索公司并显示分页的找到的结果列表。 API 方法文档

"firms"

search 的别名。

"searchInRubric"

在此类别中搜索给定的查询公司并给出分页的匹配列表。 API 方法文档

"firmsByFilialId"

通过唯一标识符返回公司办公室列表。 API 方法文档

"adsSearch"

在给定查询中搜索广告商。 API 方法文档

"ads"

adsSearch 的别名。

"profile"

通过其唯一标识符返回有关分支机构配置文件的详细信息。 API 方法文档

"firmProfile"

配置文件 的别名。

Geo data API

"geoSearch"

选择符合搜索条件的地理对象。 API 方法文档

"geoGet"

通过其标识符返回有关地理对象的信息。 API 方法文档

Features of the implementation under Node.js

  • query parameters with commas in the original API can be represented as an array:
    ...
    api.firms({
        what: 'установка окон',

        filters: {
            worktime: ['sat', '15:00'] // <- This is it.
        }

    }, function (err, data) {
        console.log('firms', err, data);
    });
    ...
  • complex structure of the form bound [point1] = 37.432,55.836 & bound [point2] = 37.633,55.637 can be represented as an object:
    ...
    api.firms({
        what: 'установка окон',

        bound: {
                point1: '37.432,55.836', // <- This is it...
                point2: [37.633, 55.637] // <- Or an array.
            }

    }, function (err, data) {
        console.log('firms', err, data);
    });
    ...

Issues

有错误吗? 请在 GitHub 上创建问题!

https://github.com/Staltec/2gis-api/issues

License

(麻省理工学院许可证)

版权所有 (c) 2013 Alexander Prozorov (staltec@gmail.com)

特此免费授予任何获得本软件和相关文档文件(“软件”),不受限制地处理本软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售本软件副本的权利,并允许获得软件的人这样做,但须满足以下条件:

上述版权声明和本许可声明应包含在软件的所有副本或重要部分中。

本软件“按原样”提供,不提供任何明示或暗示的保证,包括但不限于对适销性、特定用途的适用性和非侵权性的保证。 在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任负责,无论是在合同诉讼、侵权行为还是其他方面,由软件或软件的使用或其他交易引起、由软件引起或与之相关软件。

2GIS API for Node.js

About module

This module implements API 2GIS calls for NodeJS. At the moment the following sections API:

  • Catalog API
  • Geo data API

Installation

npm install 2gis-api

Usage

    var api = require ('2gis-api');

    api.configure({
        serviceUrl: 'catalog.api.2gis.ru', // This is optional default path.
        version: 1.3, // This is optional default version.

        key: 'YOUR_API_KEY' // Required. Get it from the vendor.
    });

    api.projectList({}, function (err, data) {
        console.log('projectList', err, data);
    });

    api.rubricator({
        where: 'Красноярск',
        show_children: 1
    }, function (err, data) {
        console.log('rubricator', err, data);
    });

Important! To obtain the API-key necessary to fill in the application form.

Catalog API

"projectList"

The method returns a list of projects (a large city and surrounding villages). Values ​​of incoming and outgoing parameters are listed in the API method documentation.

"rubricator"

Selects rubrics for which this rubric is the parent. API method documentation.

Searches for firms from the given query and displays a list of found results paginated. API method documentation.

"firms"

Alias of search.

"searchInRubric"

Searches for the given query firms in this category and gives the list of matches paginated. API method documentation.

"firmsByFilialId"

Returns a list of offices of the company by a unique identifier. API method documentation.

"adsSearch"

Searches for advertisers within a given query. API method documentation.

"ads"

Alias of adsSearch.

"profile"

Returns detailed information about the profile of the branch by its unique identifier. API method documentation.

"firmProfile"

Alias of profile.

Geo data API

"geoSearch"

Selects geoobjects that match the search criteria. API method documentation.

"geoGet"

Returns information about the geo object by its identifier. API method documentation.

Features of the implementation under Node.js

  • query parameters with commas in the original API can be represented as an array:
    ...
    api.firms({
        what: 'установка окон',

        filters: {
            worktime: ['sat', '15:00'] // <- This is it.
        }

    }, function (err, data) {
        console.log('firms', err, data);
    });
    ...
  • complex structure of the form bound [point1] = 37.432,55.836 & bound [point2] = 37.633,55.637 can be represented as an object:
    ...
    api.firms({
        what: 'установка окон',

        bound: {
                point1: '37.432,55.836', // <- This is it...
                point2: [37.633, 55.637] // <- Or an array.
            }

    }, function (err, data) {
        console.log('firms', err, data);
    });
    ...

Issues

Have a bug? Please create an issue here on GitHub!

https://github.com/Staltec/2gis-api/issues

License

(The MIT License)

Copyright (c) 2013 Alexander Prozorov (staltec@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文