You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
2.9 KiB

10 years ago
# valid suggest query
10 years ago
*Generated: Fri Sep 19 2014 14:38:01 GMT+0100 (BST)*
10 years ago
## Request
```javascript
{
"protocol": "http:",
"host": "localhost",
"method": "GET",
"port": 3100,
10 years ago
"path": "/suggest?input=a&lat=0&lon=0"
10 years ago
}
```
## Response
```javascript
Status: 200
{
10 years ago
"x-powered-by": "mapzen",
10 years ago
"charset": "utf8",
10 years ago
"cache-control": "public,max-age=60",
"server": "Pelias/0.0.0",
10 years ago
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET",
"access-control-allow-headers": "X-Requested-With,content-type",
"access-control-allow-credentials": "true",
"content-type": "application/json; charset=utf-8",
"content-length": "1248",
10 years ago
"etag": "W/\"l7SMjqn0lVxkVsxRTJizhA==\"",
"date": "Fri, 19 Sep 2014 13:38:01 GMT",
10 years ago
"connection": "close"
}
```
```javascript
{
10 years ago
"date": 1411133881441,
10 years ago
"body": [
{
"text": "ACRELÂNDIA, Brazil",
"score": 1,
"payload": {
"id": "admin2/708:adm2:br:bra:acrel__ndia",
"geo": "-66.908143,-9.954353"
}
},
{
"text": "ALTA FLORESTA, Brazil",
"score": 1,
"payload": {
"id": "admin2/2986:adm2:br:bra:alta_floresta",
"geo": "-56.404593,-10.042071"
}
},
{
"text": "ALTO ALEGRE, Brazil",
"score": 1,
"payload": {
"id": "admin2/4611:adm2:br:bra:alto_alegre",
"geo": "-62.627879,3.103540"
}
},
{
"text": "ALTO PARAÍSO, Brazil",
"score": 1,
"payload": {
"id": "admin2/4584:adm2:br:bra:alto_para__so",
"geo": "-63.418743,-9.697774"
}
},
{
"text": "ALVARÃES, Brazil",
"score": 1,
"payload": {
"id": "admin2/832:adm2:br:bra:alvar__es",
"geo": "-65.296384,-3.674615"
}
},
{
"text": "AMAJARI, Brazil",
"score": 1,
"payload": {
"id": "admin2/4610:adm2:br:bra:amajari",
"geo": "-62.710104,3.724864"
}
},
{
"text": "AMAZONAS, Brazil",
"score": 1,
"payload": {
"id": "admin1/3232:adm1:br:bra:amazonas",
"geo": "-64.949558,-3.785708"
}
},
{
"text": "ANAMÃ, Brazil",
"score": 1,
"payload": {
"id": "admin2/834:adm2:br:bra:anam__",
"geo": "-61.683670,-3.473836"
}
},
{
"text": "ANORI, Brazil",
"score": 1,
"payload": {
"id": "admin2/835:adm2:br:bra:anori",
"geo": "-62.182138,-4.154809"
}
},
{
"text": "APIACÁS, Brazil",
"score": 1,
"payload": {
"id": "admin2/2992:adm2:br:bra:apiac__s",
"geo": "-57.803447,-8.583036"
}
}
]
}
```
## Tests
### ✓ valid response
```javascript
now = new Date().getTime()
should.exist json
should.not.exist json.error
should.exist json.date
10 years ago
json.date.should.be.within now-2000, now+2000
10 years ago
should.exist json.body
json.body.should.be.instanceof Array
```
10 years ago
### ✓ 200 ok
```javascript
response.statusCode.should.equal 200
```