3taps 中文文档教程
3taps API Node Client
这是 3taps 轮询、参考和搜索 API 端点的 API 客户端。
Getting Started
npm install 3taps
General Reference
Errors
如果 3taps API 返回不受支持的 HTTP 状态代码(即小于 200 或大于 299)或,当返回消息中的成功
字段为时false
,回调将包含具有以下属性的错误:
{
requestOptions: {
method: 'GET',
qs: { auth_token: 'test-api-key', timestamp: 1417789575187 },
url: 'https://polling.3taps.com/anchor'
},
response: {
success: false,
error: 'example error',
request: {
body: '',
uri: '/anchor?auth_token=test-api-key×tamp=1417789575187'
}
},
statusCode: 409
}
Options
选项对于每个方法调用都是可选的……但是,如果缺少预期参数,底层 3taps API 可能会返回错误。 初始化客户端库时可以全局指定所有参数,并且可以在每个模块方法调用中覆盖每个初始化参数值。
Base Constructor Options
创建客户端库时需要以下选项: 创建客户端库
apikey
: the API key for access to the 3taps API
时,以下选项是可选的:
maxRetryCount
: defaults to 0 - the number of retries in the event that any error is returned when calling the APIpollingUrl
: defaults to https://polling.3taps.comreferenceUrl
: defaults to https://reference.3taps.comsearchUrl
: defaults to https://search.3taps.comstrictSSL
: defaults to truetimeout
: defaults to 10000 (10 seconds)
Polling API
轮询端点支持两种特定功能:anchor
和 poll
Anchor
使用它来从一个时间点生成一个锚点……支持时间戳值作为日期值或 Unix 纪元(1970 年 1 月 1 日)的秒数。
var
anchorDate = new Date(),
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
// retrieve all postings new in the last hour
anchorDate.setHours(anchorDate.getHours() - 1);
threeTapsClient.anchor({
timestamp : anchorDate
}, function (err, data) {
// work with data here
});
其响应将类似于以下内容:
{
success: true,
anchor: 1570197959
}
Poll
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.poll({
anchor : 1570197959
}, function (err, data) {
// work with data here
});
库将使用类似于以下内容的响应:
{
success: true,
anchor: 124981255,
postings: [
{ id: 1570150577,
source: 'CRAIG',
category: 'RHFS',
external_id: '4757959490',
external_url: 'http://greensboro.craigslist.org/reb/4757959490.html',
heading: '6312 Settlement Road',
timestamp: 1417712270,
annotations: [Object],
deleted: false,
location: [Object] },
{ id: 1570150578,
source: 'CRAIG',
category: 'JMFT',
external_id: '4759338172',
external_url: 'http://fredericksburg.craigslist.org/mnu/4759338172.html',
heading: 'QA Technician',
timestamp: 1417711983,
annotations: [Object],
deleted: false,
location: [Object] },
// and so on...
]
}
Polling Options
Polling 支持一系列可以在 options
参数中传递的参数。 如需完整参考,请参阅位于 http://docs.3taps.com/polling_api.html 的 3taps 文档。 此外,许多参数支持传递逻辑运算符 |
(或)和 -
(非)的能力。
以下是选项列表的示例:
var options = {
anchor : 12345, // optional
category : '', // optional - 3taps category code, supports logical operators
'category_group' : '', // optional - 3taps category_group code, supports logical operators
'location' : {
'city' : '', // optional - desired City, supports logical operators
'country' : '', // optional - desired Country code, supports logical operators
'county' : '', // optional - desired County code, supports logical operators
'locality' : '', // optional - 3taps Locality code, supports logical operators
'metro' : '', // optional - 3taps Metro Area code, supports logical operators
'region' : '', // optional - 3taps Region code, supports logical operators
'state' : '', // optional - 3taps City code, supports logical operators
'zipcode' : '' // optional - desired Zip Code, supports logical operators
},
retvals : [''], // optional - list of fields to return (see below)
source : '', // optional - 3taps Data Source code, supports logical operators
state : '', // optional - state of the posting (see below), supports logical operators
status : '' // optional - status of the posting (see below), supports logical operators
};
threeTapsClient.poll(options, function (err, data) {
// filtered awesomeness in the data arg
});
retvals
retvals 参数支持数组或逗号分隔的值列表,来自
- id
- account_id
- source
- category
- category_group
- location
- external_id
- external_url
- heading
- body
- timestamp
- timestamp_deleted
- expires
- language
- price
- currency
- images
- annotations
- status
- state
- immortal
- deleted
- flagged_status
state
以下值: state 参数支持以下值:
- available
- unavailable
- expired
status
status 参数支持以下值:
- registered
- for_sale
- for_hire
- for_rent
- wanted
- lost
- stolen
- found
Reference API
3taps 中的参考 API 端点返回有关的信息categories
、category_groups
、sources
和 locations
除了提供查找特定位置以检索详细信息的能力.
重要说明:
参考 API 方法中的值会定期更改……它们可以被缓存,但应定期使用 lastModified 日期来确定值是否已更新. #getCategories
、#getCategoryGroups
、#getDataSources
和 #getLocations
的响应将包含一个 lastModified< /code> 可用于此目的的字段。
getCategories
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getCategories(function (err, data) {
// work with categories here
});
响应将类似于以下内容:
{
categories: [{
code: 'APET',
group_code: 'AAAA',
group_name: 'Animals',
name: 'Pets'
}, {
code: 'ASUP',
group_code: 'AAAA',
group_name: 'Animals',
name: 'Supplies'
}, {
// ... more categories, etc.
}],
success: true,
lastModified: 'Tue Sep 10 2013 00:34:25 GMT-0700 (PDT)'
}
getCategoryGroups
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getCategoryGroups(function (err, data) {
// work with category groups here
});
响应将类似于:
{ category_groups:
[ { code: 'AAAA', name: 'Animals' },
{ code: 'CCCC', name: 'Community' },
{ code: 'DISP', name: 'Dispatch' },
{ code: 'SSSS', name: 'For Sale' },
{ code: 'JJJJ', name: 'Jobs' },
{ code: 'MMMM', name: 'Mature' },
{ code: 'PPPP', name: 'Personals' },
{ code: 'RRRR', name: 'Real Estate' },
{ code: 'SVCS', name: 'Services' },
{ code: 'ZZZZ', name: 'Uncategorized' },
{ code: 'VVVV', name: 'Vehicles' } ],
success: true,
lastModified: 'Mon Sep 02 2013 00:34:25 GMT-0700 (PDT)'
}
getDataSources
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getDataSources(function (err, data) {
// work with data sources here
});
响应将类似于:
{ sources:
[ { code: 'APTSD', name: 'Apartments.com' },
{ code: 'AUTOC', name: 'autotraderclassic.com' },
{ code: 'AUTOD', name: 'autotrader.com' },
{ code: 'BKPGE', name: 'Backpage' },
{ code: 'CARSD', name: 'Cars.com' },
{ code: 'CCARS', name: 'classiccars.com' },
{ code: 'CRAIG', name: 'Craigslist' },
{ code: 'E_BAY', name: 'ebay.com' },
{ code: 'EBAYM', name: 'Ebay Motors' },
{ code: 'HMNGS', name: 'Hemmings Motor News' },
{ code: 'INDEE', name: 'Indeed' },
{ code: 'RENTD', name: 'Rent.com' } ],
success: true,
lastModified: 'Tue Sep 30 2014 00:34:25 GMT-0700 (PDT)'
}
getLocations
此方法需要参数 level
,该参数应包含以下字符串值之一:
- city
- country
- county
- locality
- metro
- region
- state
- zipcode
此外,结果可以通过传递以下任何参数在服务器上过滤返回的内容:
- city - only includes locations that exist within the specified 3taps city code
- country - only includes locations that exist within the specified 3taps country code
- county - only includes locations that exist within the specified 3taps county code
- locality - only includes locations that exist within the specified 3taps locality code
- metro - only includes locations that exist within the specified 3taps metro code
- region - only includes locations that exist within the specified 3taps region code
- state - only includes locations that exist within the specified 3taps state code
请参阅以下示例以提取旧金山内的邮政编码:
var
options = {
level : 'zipcode',
city : 'USA-SFO-SNF'
},
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getLocations(
options,
function (err, data) {
// work with locations here
});
返回的数据类似于以下内容:
{
locations: [{
bounds_max_lat: 37.78933,
bounds_max_long: -122.40438,
bounds_min_lat: 37.76963,
bounds_min_long: -122.42968,
code: 'USA-94102',
full_name: '94102',
short_name: '94102'
}, {
bounds_max_lat: 37.78823,
bounds_max_long: -122.39768,
bounds_min_lat: 37.76453,
bounds_min_long: -122.42615,
code: 'USA-94103',
full_name: '94103',
short_name: '94103'
}, {
// more results here...
}],
success: true,
lastModified: 'Mon Sep 02 2013 00:34:25 GMT-0700 (PDT)'
}
lookupLocation
提供根据其代码查找单个位置的详细信息的能力……
var
options = {
code : 'USA-94102'
},
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.lookupLocation(
options,
function (err, data) {
// work with location here
});
这将返回类似于以下的数据:
{ location:
{ bounds_max_lat: 37.78933,
bounds_max_long: -122.40438,
bounds_min_lat: 37.76963,
bounds_min_long: -122.42968,
code: 'USA-94102',
full_name: '94102',
level: 'zipcode',
short_name: '94102' },
success: true }
Search API
Search 支持一系列参数,这些参数可以在 options
参数中传递。 如需完整参考,请参阅位于 http://docs.3taps.com/search_api.html 的 3taps 文档。 此外,许多参数支持传递逻辑运算符 |
(或)和 -
(非)的能力。
以下是所有可选 选项的列表:
Reference Filters
- category
- category_group
- location.city
- location.country
- location.county
- location.locality
- location.metro
- location.region
- location.state
- location.zipcode
- source
Geographic Filters
- lat
- long
- radius
Posting Specific Filters
- annotations
- body
- currency
- external_id
- has_image
- has_price
- heading
- id
- include_deleted
- only_deleted
- price
- state
- status
- text
- timestamp
Response Shaping
- anchor - Helps in working with the constant changing of pages
- count - Puts search into count mode, the payload return is shifted considerably
- page - The page to return
- retvals - The specific fields in the response (similar to #poll, see 3taps docs for details)
- rpp - The number of posts per page
- sort - Sorts results, supports
timestamp
,-timestamp
,price
,-price
anddistance
- tier - The tier to return
以下示例对位于加利福尼亚州旧金山的正文中带有 fixie
的所有帖子执行搜索:
var
options = {
body : 'fixie',
'location.city' : 'USA-SFO-SNF'
},
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.search(
options,
function (err, data) {
// work with location here
});
响应类似于以下:
{
"next_page": 1,
"time_search": 4.912137985229492,
"success": true,
"time_taken": 163.88916969299316,
"anchor": 1574246415,
"time_fetch": 5.389928817749023,
"num_matches": 33,
"postings": [
{
"category": "SBIK",
"timestamp": 1417790322,
"id": 1573798080,
"source": "CRAIG",
"location": {
"city": "USA-SFO-SNF",
"geolocation_status": 3,
"metro": "USA-SFO",
"locality": "USA-SFO-BEN",
"country": "USA",
"region": "USA-SFO-SAF",
"zipcode": "USA-94110",
"long": "-122.4158",
"county": "USA-CA-SAF",
"state": "USA-CA",
"lat": "37.74299",
"formatted_address": "Bernal Heights Summit, San Francisco, CA 94110, USA",
"accuracy": 8
},
"external_id": "4787190734",
"heading": "2013 Ridley Excalibur Road Bike Frame PRICE DROP Or Best Offer",
"external_url": "http://sfbay.craigslist.org/sby/bik/4787190734.html"
},
{
"category": "VPAR",
"timestamp": 1417790193,
"id": 1573694799,
"source": "CRAIG",
"location": {
"city": "USA-SFO-SNF",
"geolocation_status": 3,
"metro": "USA-SFO",
"locality": "USA-SFO-BEN",
"country": "USA",
"region": "USA-SFO-SAF",
"zipcode": "USA-94110",
"long": "-122.4158",
"county": "USA-CA-SAF",
"state": "USA-CA",
"lat": "37.74299",
"formatted_address": "Bernal Heights Summit, San Francisco, CA 94110, USA",
"accuracy": 8
},
"external_id": "4788044842",
"heading": "3T IONIC 25 TEAM STEALTH CARBON SEATPOST",
"external_url": "http://sfbay.craigslist.org/sby/bop/4788044842.html"
},
// more results ...
],
"next_tier": 0
}
Development
Running Tests
package.json
文件已连接以运行 jshint、单元测试和代码覆盖率报告,但在运行 npm test
时不进行功能测试。
npm test
Unit Tests
gulp jshint
Unit Tests
gulp test-unit
Test Coverage
运行测试覆盖率时,将在 ./reports/lcov-report/lib/index.js.html
创建一份伊斯坦布尔报告
gulp test-coverage
open reports/lcov-report/lib/index.js.html
Functional Tests
要运行功能测试,您需要使用您的3taps API 密钥:
export THREETAPS_APIKEY=my-key-goes-here
要验证您的密钥是否已正确设置,只需从命令行回显:
echo $THREETAPS_APIKEY
注意:您可能需要考虑将此添加到您的 ~/.bash配置文件,以便在以下情况下始终设置它你打开一个终端
_现在,你可以使用 gulp 和以下命令运行功能测试:
gulp test-functional
3taps API Node Client
This is an API client for the 3taps polling, reference and search API endpoints.
Getting Started
npm install 3taps
General Reference
Errors
In the event that the 3taps API returns an unsupported HTTP status code (i.e. less than 200 or greater than 299) or when the success
field from the return message is false
, the callback will contain an error with the following properties:
{
requestOptions: {
method: 'GET',
qs: { auth_token: 'test-api-key', timestamp: 1417789575187 },
url: 'https://polling.3taps.com/anchor'
},
response: {
success: false,
error: 'example error',
request: {
body: '',
uri: '/anchor?auth_token=test-api-key×tamp=1417789575187'
}
},
statusCode: 409
}
Options
Options are optional for every method call… the underlying 3taps API may return an error in the event that an expected parameter is missing, however. All parameters can be specified globally when initializing the client library and each initialized parameter value can be overridden in each module method call.
Base Constructor Options
The following options are required when creating the client library:
apikey
: the API key for access to the 3taps API
The following options are optional when creating the client library:
maxRetryCount
: defaults to 0 - the number of retries in the event that any error is returned when calling the APIpollingUrl
: defaults to https://polling.3taps.comreferenceUrl
: defaults to https://reference.3taps.comsearchUrl
: defaults to https://search.3taps.comstrictSSL
: defaults to truetimeout
: defaults to 10000 (10 seconds)
Polling API
The polling endpoint supports two specific capabilities: anchor
and poll
Anchor
Use this to generate an anchor from a point in time… the timestamp value is supported as a Date value or the number of seconds from Unix epoch (January 1, 1970).
var
anchorDate = new Date(),
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
// retrieve all postings new in the last hour
anchorDate.setHours(anchorDate.getHours() - 1);
threeTapsClient.anchor({
timestamp : anchorDate
}, function (err, data) {
// work with data here
});
For which the response will look similar to the following:
{
success: true,
anchor: 1570197959
}
Poll
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.poll({
anchor : 1570197959
}, function (err, data) {
// work with data here
});
The library will respond with something similar to:
{
success: true,
anchor: 124981255,
postings: [
{ id: 1570150577,
source: 'CRAIG',
category: 'RHFS',
external_id: '4757959490',
external_url: 'http://greensboro.craigslist.org/reb/4757959490.html',
heading: '6312 Settlement Road',
timestamp: 1417712270,
annotations: [Object],
deleted: false,
location: [Object] },
{ id: 1570150578,
source: 'CRAIG',
category: 'JMFT',
external_id: '4759338172',
external_url: 'http://fredericksburg.craigslist.org/mnu/4759338172.html',
heading: 'QA Technician',
timestamp: 1417711983,
annotations: [Object],
deleted: false,
location: [Object] },
// and so on...
]
}
Polling Options
Polling supports a series of parameters that can be passed in the options
argument. For a full reference, please see the 3taps documentaiton at http://docs.3taps.com/polling_api.html. Additionally, many of the params support the ability to pass in the logical operators |
(or) and -
(not).
Here is an example list of options:
var options = {
anchor : 12345, // optional
category : '', // optional - 3taps category code, supports logical operators
'category_group' : '', // optional - 3taps category_group code, supports logical operators
'location' : {
'city' : '', // optional - desired City, supports logical operators
'country' : '', // optional - desired Country code, supports logical operators
'county' : '', // optional - desired County code, supports logical operators
'locality' : '', // optional - 3taps Locality code, supports logical operators
'metro' : '', // optional - 3taps Metro Area code, supports logical operators
'region' : '', // optional - 3taps Region code, supports logical operators
'state' : '', // optional - 3taps City code, supports logical operators
'zipcode' : '' // optional - desired Zip Code, supports logical operators
},
retvals : [''], // optional - list of fields to return (see below)
source : '', // optional - 3taps Data Source code, supports logical operators
state : '', // optional - state of the posting (see below), supports logical operators
status : '' // optional - status of the posting (see below), supports logical operators
};
threeTapsClient.poll(options, function (err, data) {
// filtered awesomeness in the data arg
});
retvals
The retvals parameter supports an array or a comma separated list of values from the following:
- id
- account_id
- source
- category
- category_group
- location
- external_id
- external_url
- heading
- body
- timestamp
- timestamp_deleted
- expires
- language
- price
- currency
- images
- annotations
- status
- state
- immortal
- deleted
- flagged_status
state
The state parameter supports the following values:
- available
- unavailable
- expired
status
The status parameter supports the following values:
- registered
- for_sale
- for_hire
- for_rent
- wanted
- lost
- stolen
- found
Reference API
The reference API endpoint in 3taps returns information about categories
, category_groups
, sources
and locations
in addition to providing the ability to lookup a specific location to retrieve detailed information.
Important Note:
Periodically, the values from reference API methods will change… they can be cached, but periodically, the lastModified date should be used to determine if a value has been updated. The responses from #getCategories
, #getCategoryGroups
, #getDataSources
and #getLocations
will contain a lastModified
field that can be used for this purpose.
getCategories
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getCategories(function (err, data) {
// work with categories here
});
The response will look similar to the following:
{
categories: [{
code: 'APET',
group_code: 'AAAA',
group_name: 'Animals',
name: 'Pets'
}, {
code: 'ASUP',
group_code: 'AAAA',
group_name: 'Animals',
name: 'Supplies'
}, {
// ... more categories, etc.
}],
success: true,
lastModified: 'Tue Sep 10 2013 00:34:25 GMT-0700 (PDT)'
}
getCategoryGroups
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getCategoryGroups(function (err, data) {
// work with category groups here
});
The response will look similar to:
{ category_groups:
[ { code: 'AAAA', name: 'Animals' },
{ code: 'CCCC', name: 'Community' },
{ code: 'DISP', name: 'Dispatch' },
{ code: 'SSSS', name: 'For Sale' },
{ code: 'JJJJ', name: 'Jobs' },
{ code: 'MMMM', name: 'Mature' },
{ code: 'PPPP', name: 'Personals' },
{ code: 'RRRR', name: 'Real Estate' },
{ code: 'SVCS', name: 'Services' },
{ code: 'ZZZZ', name: 'Uncategorized' },
{ code: 'VVVV', name: 'Vehicles' } ],
success: true,
lastModified: 'Mon Sep 02 2013 00:34:25 GMT-0700 (PDT)'
}
getDataSources
var threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getDataSources(function (err, data) {
// work with data sources here
});
The response will look similar to:
{ sources:
[ { code: 'APTSD', name: 'Apartments.com' },
{ code: 'AUTOC', name: 'autotraderclassic.com' },
{ code: 'AUTOD', name: 'autotrader.com' },
{ code: 'BKPGE', name: 'Backpage' },
{ code: 'CARSD', name: 'Cars.com' },
{ code: 'CCARS', name: 'classiccars.com' },
{ code: 'CRAIG', name: 'Craigslist' },
{ code: 'E_BAY', name: 'ebay.com' },
{ code: 'EBAYM', name: 'Ebay Motors' },
{ code: 'HMNGS', name: 'Hemmings Motor News' },
{ code: 'INDEE', name: 'Indeed' },
{ code: 'RENTD', name: 'Rent.com' } ],
success: true,
lastModified: 'Tue Sep 30 2014 00:34:25 GMT-0700 (PDT)'
}
getLocations
This method requires the parameter level
which should contain one of the following string values:
- city
- country
- county
- locality
- metro
- region
- state
- zipcode
Additionally, the results returned can be filtered at the server by passing any of the following parameters:
- city - only includes locations that exist within the specified 3taps city code
- country - only includes locations that exist within the specified 3taps country code
- county - only includes locations that exist within the specified 3taps county code
- locality - only includes locations that exist within the specified 3taps locality code
- metro - only includes locations that exist within the specified 3taps metro code
- region - only includes locations that exist within the specified 3taps region code
- state - only includes locations that exist within the specified 3taps state code
See the following example to pull zipcodes within San Francisco:
var
options = {
level : 'zipcode',
city : 'USA-SFO-SNF'
},
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.getLocations(
options,
function (err, data) {
// work with locations here
});
Which returns data similar to the following:
{
locations: [{
bounds_max_lat: 37.78933,
bounds_max_long: -122.40438,
bounds_min_lat: 37.76963,
bounds_min_long: -122.42968,
code: 'USA-94102',
full_name: '94102',
short_name: '94102'
}, {
bounds_max_lat: 37.78823,
bounds_max_long: -122.39768,
bounds_min_lat: 37.76453,
bounds_min_long: -122.42615,
code: 'USA-94103',
full_name: '94103',
short_name: '94103'
}, {
// more results here...
}],
success: true,
lastModified: 'Mon Sep 02 2013 00:34:25 GMT-0700 (PDT)'
}
lookupLocation
Provides the ability to find the details of a single location based on its code…
var
options = {
code : 'USA-94102'
},
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.lookupLocation(
options,
function (err, data) {
// work with location here
});
Which will return data similar to the following:
{ location:
{ bounds_max_lat: 37.78933,
bounds_max_long: -122.40438,
bounds_min_lat: 37.76963,
bounds_min_long: -122.42968,
code: 'USA-94102',
full_name: '94102',
level: 'zipcode',
short_name: '94102' },
success: true }
Search API
Search supports a series of parameters that can be passed in the options
argument. For a full reference, please see the 3taps documentaiton at http://docs.3taps.com/search_api.html. Additionally, many of the params support the ability to pass in the logical operators |
(or) and -
(not).
Here is a list of all optional options:
Reference Filters
- category
- category_group
- location.city
- location.country
- location.county
- location.locality
- location.metro
- location.region
- location.state
- location.zipcode
- source
Geographic Filters
- lat
- long
- radius
Posting Specific Filters
- annotations
- body
- currency
- external_id
- has_image
- has_price
- heading
- id
- include_deleted
- only_deleted
- price
- state
- status
- text
- timestamp
Response Shaping
- anchor - Helps in working with the constant changing of pages
- count - Puts search into count mode, the payload return is shifted considerably
- page - The page to return
- retvals - The specific fields in the response (similar to #poll, see 3taps docs for details)
- rpp - The number of posts per page
- sort - Sorts results, supports
timestamp
,-timestamp
,price
,-price
anddistance
- tier - The tier to return
The following example performs a search for all postings with fixie
in the body located within San Francisco, California:
var
options = {
body : 'fixie',
'location.city' : 'USA-SFO-SNF'
},
threeTapsClient = require('3taps')({ apikey : 'my-api-key' });
threeTapsClient.search(
options,
function (err, data) {
// work with location here
});
The response is similar to the following:
{
"next_page": 1,
"time_search": 4.912137985229492,
"success": true,
"time_taken": 163.88916969299316,
"anchor": 1574246415,
"time_fetch": 5.389928817749023,
"num_matches": 33,
"postings": [
{
"category": "SBIK",
"timestamp": 1417790322,
"id": 1573798080,
"source": "CRAIG",
"location": {
"city": "USA-SFO-SNF",
"geolocation_status": 3,
"metro": "USA-SFO",
"locality": "USA-SFO-BEN",
"country": "USA",
"region": "USA-SFO-SAF",
"zipcode": "USA-94110",
"long": "-122.4158",
"county": "USA-CA-SAF",
"state": "USA-CA",
"lat": "37.74299",
"formatted_address": "Bernal Heights Summit, San Francisco, CA 94110, USA",
"accuracy": 8
},
"external_id": "4787190734",
"heading": "2013 Ridley Excalibur Road Bike Frame PRICE DROP Or Best Offer",
"external_url": "http://sfbay.craigslist.org/sby/bik/4787190734.html"
},
{
"category": "VPAR",
"timestamp": 1417790193,
"id": 1573694799,
"source": "CRAIG",
"location": {
"city": "USA-SFO-SNF",
"geolocation_status": 3,
"metro": "USA-SFO",
"locality": "USA-SFO-BEN",
"country": "USA",
"region": "USA-SFO-SAF",
"zipcode": "USA-94110",
"long": "-122.4158",
"county": "USA-CA-SAF",
"state": "USA-CA",
"lat": "37.74299",
"formatted_address": "Bernal Heights Summit, San Francisco, CA 94110, USA",
"accuracy": 8
},
"external_id": "4788044842",
"heading": "3T IONIC 25 TEAM STEALTH CARBON SEATPOST",
"external_url": "http://sfbay.craigslist.org/sby/bop/4788044842.html"
},
// more results ...
],
"next_tier": 0
}
Development
Running Tests
The package.json
file is wired up to run jshint, unit tests and code coverage reporting, but not functional tests when running npm test
.
npm test
Unit Tests
gulp jshint
Unit Tests
gulp test-unit
Test Coverage
When running test coverage, an istanbul report will be created at ./reports/lcov-report/lib/index.js.html
gulp test-coverage
open reports/lcov-report/lib/index.js.html
Functional Tests
To run functional tests, you'll need to export an environment variable with your 3taps API key:
export THREETAPS_APIKEY=my-key-goes-here
To verify whether your key is properly set, simply echo from the command line:
echo $THREETAPS_APIKEY
note: You may want to consider adding this to your ~/.bashprofile so that it is always set when you open a terminal_
Now, you can run the functional tests using gulp with the following command:
gulp test-functional