API for apps dedicated to sailors.
- Host
- Running API locally
- Authentication
- Geolocation
- API endpoints
- Custom API status codes
sail-hero.dev/api/v1/en
- Scoping - API by default is accessible from api scope -
BASE_URL.com/api/REST_OF_THE_URL
- Versioning follows base url in HOST name (current version is
v1
). - I18n - currently only english version is available (
en
).
cp config/application.yml.sample config/application.yml
- Add
SECRET_KEY_BASE
-rake secret
.
- Install Postgresql and create proper role
- Run
rake db:create
&rake db:migrate
rails s
Visit http://sail-hero.dev/oauth/applications/
and create new application.
After application and registering user you can send request for access token:
POST /oauth/token HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
{
"client_id":YOUR-CLIENT-ID,
"client_secret":YOUR-CLIENT-SECRET,
"username":"[email protected]",
"grant_type":"password",
"password":"password_example"
}
# STATUS 200 OK
{
access_token: YOUR-ACCESS-TOKEN
token_type: "bearer"
expires_in: 604800
refresh_token: YOUR-REFRESH-TOKEN
}
POST /ouath/revoke HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"token":YOUR_ACCESS_TOKEN
}
# STATUS 200 OK
{}
This app is designed to work with geolocation services. It's highly recommended to send current position in header of every HTTP request.
GET /api/v1/en/users/me HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
...
# request body
You can always check your last saved position at your profile endpoint.
Field | Type | Comments | Validations |
---|---|---|---|
id |
Integer | ||
email |
String | ||
activation_token |
String | ||
password |
String | Beetween 4 and 128 characters | |
created_at |
DateTime | ||
created_at |
DateTime | ||
position_updated_at |
DateTime | ||
name |
String | Beetween 2 and 128 characters | |
surname |
String | Beetween 2 and 128 characters | |
regio_id |
Integer | ||
active |
Boolean | Default: false |
|
avatar_url |
Boolean | Default: true |
|
share_position |
Boolean | Default: true |
GET /api/v1/en/users?q=scarlett HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
# STATUS: 200 OK
{
"users":[
{
"id":999,
"name":"Scarlett",
"surname":"Johansson",
"created_at":"2014-09-13T09:57:21.402Z",
"updated_at":"2014-09-13T09:57:21.402Z",
"email":"[email protected]",
"last_position":{
"latitude":null,
"longitude":null,
"updated_at":null
},
"region":null,
"yacht":null
}
]
}
Status | Description |
---|---|
200 | Everything went fine. Server responds with matched users |
401 | Access token is invalid or revoked. |
POST /api/v1/en/users HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
{
"user":{
"email":"[email protected]",
"password":"password_example",
"password_confirmation":"password_example",
"name":"Your Name",
"surname":"Your Surname",
"avatar_data":"data:image/jpg;base64,YOUR-AVATAR-BASE64-ENCODED"
}
}
# STATUS: 201 Created
{
"user":{
"id":999,
"created_at":"2014-09-13T09:57:21.402Z",
"updated_at":"2014-09-13T09:57:21.402Z",
"email":"[email protected]",
"last_position":{
"latitude":null,
"longitude":null,
"updated_at":null
},
"region":null,
"yacht":null,
"avatar_url":"AVATAR-URL"
}
}
PUT /api/v1/en/users/:id HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
{
"user":{
"email":"[email protected]",
}
}
Same as for creating user.
GET /api/v1/en/users HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
# STATUS: 200 OK
{
"user":{
"id":999,
"created_at":"2014-09-13T09:57:21.402Z",
"email":"[email protected]",
"last_position":{
"latitude:16.9765102,
"longitude":16.9765102,
"updated_at":"2014-10-05T15:25:21.919Z"
}
"region":{
"id":1,
"full_name":"Wielkie Jeziora Mazurskie",
"code_name":"MAZURY"
}
"yacht":{
"id":8,
"name":"Your Yacht Name",
"length": 780,
"width": 230,
"crew":7
}
}
}
DELETE /api/v1/en/users HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
# STATUS: 200 OK
{}
GET /api/v1/en/users/me/devices HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"device_type":"ANDROID",
"name":"YOUR DEVICE NAME"
"key":"YOUR_GCM_OR_IOS_KEY"
}
# STATUS: 201 OK
{
device: {
id: 3,
name:"YOUR_DEVICE_NAME",
device_type:"ANDROID",
key: "YOUR_GCM_KEY",
created_at: "2014-11-02T14:25:29.722Z"
}
}
Status | Description |
---|---|
201 | Everything went fine. GCM key created |
401 | Access token is invalid or revoked. |
422 | Provided data is invalid |
Currently only ANDROID
with GCM as key
is supported.
POST /api/v1/en/messages HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Latitude: YOUR-LATITUDE
Longitude: YOUR-LONGITUDE
Authorization: Bearer YOUR-TOKEN
{
"message":{
"body":"YOUR-MESSAGE"
}
}
# STATUS: 201 Created
{
"message":{
"id":999,
"body":"YOUR-MESSAGE",
"created_at":"2014-09-13T09:57:21.402Z",
"user_id":"YOUR-ID",
"latitude":"YOUR-LATITUDE",
"longitude":"YOUR-LONGITUDE"
}
}
Status | Description |
---|---|
201 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
460 | Your current region_id is invalid. |
Fetching messages is cursor style - we have three parameters:
order
-ASC
(default) andDESC
allowed.DESC
fetches previous messages.since
- id of first message that will be included in responselimit
- how many messages will be included,25
by default,100
is maximum, can't be less then1
If you don't provide any of the paramters API will respond with 25 last messages.
GET /api/v1/en/messages/limit=5&since=15&order=ASC HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Latitude: YOUR-LATITUDE
Longitude: YOUR-LONGITUDE
Authorization: Bearer YOUR-TOKEN
# STATUS: 200 OK
{
"messages":[
{
"id":5,
"body","MESSAGE-BODY",
"created_at":"2014-09-13T09:57:21.402Z",
"user_id":"AUTHOR-ID",
"latitude":"MESSAGE-LATITUDE",
"longitude":"MESSAGE-LONGITUDE"
}
# ...
],
next: NEXT-MESSAGE-ID
}
Let't assume we have 6 messages with ID's 1
, 2
, 3
, 4
, 5
and 6
.
Since | Limit | Order | IDs included | Next message id |
---|---|---|---|---|
4 | 2 | DESC | 4, 3 | 2 |
4 | 2 | - | 4, 5 | 6 |
4 | 10 | - | 4, 5, 6 | nil |
- | - | - | 6, 5, 4, 3, 2, 1 | nil |
Status | Description |
---|---|
200 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
460 | Your current region_id is invalid. |
GET /api/v1/en/messages/:id HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Latitude: YOUR-LATITUDE
Longitude: YOUR-LONGITUDE
Authorization: Bearer YOUR-TOKEN
# STATUS: 200 OK
{
"message":{
"id":999,
"body","YOUR-MESSAGE",
"created_at":"2014-09-13T09:57:21.402Z",
"user_id":"AUTHOR-ID",
"latitude":"MESSAGE-LATITUDE",
"longitude":"MESSAGE-LONGITUDE"
}
}
Messages are paginated - you can switch page
(by default 0
) and per
(by default 25
).
Status | Description |
---|---|
200 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
404 | Message with given id was not found. |
460 | Your current region_id is invalid or doesn't match message region |
If user allows position tracking and sends his position in headers message sent position is saved as well. Otherwise it's casted to nil
.
This app is meant to be social. It wouldn't be possible without friends. Making friends at Sailhero is very easy!
GET /api/v1/en/friendships/accepted HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
# STATUS: 200 OK
{
"friendships":[
{
"id":3,
"status":1,
"invited":true,
"friend":{
"id":"YOUR_FRIEND_ID",
"email":"YOUR_FRIEND_EMAIL",
"name":"YOUR_FRIEND_NAME",
"surname":"YOUR_FRIEND_SURNAME"
}
"created_at": "2014-11-23T11:26:13.725Z",
"updated_at": "2014-11-23T11:26:13.731Z"
},
{
"id":13,
"status":1,
"invited":false,
"friend":{
"id":"YOUR_ID",
"email":"YOUR_EMAIL",
"name":"YOUR_NAME",
"surname":"YOUR_SURNAME"
}
"created_at": "2014-11-23T11:26:13.725Z",
"updated_at": "2014-11-23T11:26:13.731Z"
}
]
}
Status | Description |
---|---|
200 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
GET /api/v1/en/friendships/pending HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Response and possible status codes look very similar to getting all friendships - only difference: each friendship has 0
(PENDING
status).
GET /api/v1/en/friendships/sent HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Response and possible status codes look very similar to getting all friendships - only difference: each friendship has 0
(PENDING
status).
GET /api/v1/en/friendships HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
"accepted":[
# ... list of accepted friendships
],
"pending":[
# ... list of pending friendships requests
],
"sent":[
# ... list of sent friendships requests
]
POST /api/v1/en/friendships HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"friend_id":YOUR_FUTURE_FRIEND_ID
}
# STATUS 201 Created
"friendship":{
"id":3,
"status":0,
"invited":false,
"friend":{
"id":"YOUR_FRIEND_ID",
"email":"YOUR_FRIEND_EMAIL",
"name":"YOUR_FRIEND_NAME",
"surname":"YOUR_FRIEND_SURNAME"
},
"created_at": "2014-11-23T11:26:13.725Z",
"updated_at": "2014-11-23T11:26:13.731Z"
}
Status | Description |
---|---|
201 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
403 | Friendship already exists (any state allowed). |
462 | Forever alone - you're trying to make friends with yourself. |
463 | You're trying to become friends with nil . |
DELETE /api/v1/en/friendships/:id HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
# STATUS 200 OK
{}
Status | Description |
---|---|
200 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
403 | Your not either friend neither user in this friendship. |
404 | Friendship with given ID doesn't exist. |
POST /api/v1/en/friendships/:id/accept HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
POST /api/v1/en/friendships/:id/deny HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
POST /api/v1/en/friendships/:id/cancel HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
For accepting - standard friendship response (see creating new friendship). For denying and canceling:
# STATUS 200 OK
{}
Status | Description |
---|---|
200 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
403 | This friendship is not in pending state or you're not allowed to accept it. |
404 | Friendship with given id doesn't exist. |
There can be 2 status codes:
0
-PENDING
(default)1
-ACCEPTED
Most of the actions (except editing user profile) require selected region. If you try to access protected resource you'll run into 460
error code.
GET /api/v1/en/regions HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
# Status: 200 OK
{
"regions":[
{
"id":1,
"full_name":"Wielkie Jeziora Mazurskie",
"code_name":"MAZURY"
},
{
"id":2,
"full_name":"Jezioro Powidz",
"code_name":"POWIDZ"
}
]
}
Status | Description |
---|---|
200 | Everything went fine. Described above |
401 | Access token is invalid or revoked. |
POST /api/v1/en/regions/1/select HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
# Status: 200 OK
{
"region":{
"id":1,
"full_name":"Wielkie Jeziora Mazurskie",
"code_name":"MAZURY"
}
}
Status | Description |
---|---|
200 | Everything went fine. User region is updated. |
401 | Access token is invalid or revoked. |
404 | No region with given id was found |
Each user has one yacht which is used for port cost calculations.
Field | Type | Comments | Validations |
---|---|---|---|
id |
Integer | ||
name |
String | Beetween 4 and 128 characters | |
length |
Integer | In centimeters | Integer between 300 and 4000 |
width |
Integer | In centimeters | Integer between 100 and 1500 |
crew |
Integer | Crew members on board | Integer between 1 and 30 |
user_id |
Integer |
POST /api/v1/en/yachts HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"yacht":{
"length":780,
"width":230,
"name":"Your Yacht Name",
"crew":7
}
}
# STATUS: 201 Created
{
"yacht":{
id:8,
name:"Your Yacht Name",
length: 780,
width: 230,
crew:10
}
}
Status | Description |
---|---|
201 | Everything went fine. Yacht is created. |
401 | Access token is invalid or revoked. |
422 | Provided data is invalid |
461 | Current user has already created yacht. |
PUT /api/v1/en/yachts/YACHT_ID HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"yacht":{
"name":"New yacht name"
}
}
If you're access token owner is not an owner of the yacht response status will be 403
. If data is not valid you will get response with 422
status and errors in response body. Otherwise response will look more less like:
# STATUS: 200 OK
{
"yacht":{
"id":8,
"name":"New yacht name",
"length":780,
"width":230,
"crew":10
}
}
POST /api/v1/en/alerts HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
{
"alert":{
"latitude":"54.025369",
"longitude":"21.765876",
"alert_type":"BAD_WEATHER_CONDITIONS",
"additional_info":"Zawody GiĹĽycko 2014"
}
}
# STATUS: 201 Created
{
"alert":{
"id":15,
"latitude":"54.025369",
"longitude:"21.765876",
"alert_type":"BAD_WEATHER_CONDITIONS",
"additional_info":"Zawody GiĹĽycko 2014",
"created_at":"2014-10-19T16:06:25.422Z",
"user_id":22,
"credibility":0,
"active":true,
"user_vote":0,
}
}
Status | Description |
---|---|
201 | Everything went fine. New alert is created |
401 | Access token is invalid or revoked. |
460 | Region id is invalid |
GET /api/v1/en/alerts/:ID/ HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
# STATUS: 200 OK
{
"alert":{
"id":15,
"latitude":"54.025369",
"longitude:"21.765876",
"alert_type":"BAD_WEATHER_CONDITIONS",
"additional_info":"Zawody GiĹĽycko 2014",
"created_at":"2014-10-19T16:06:25.422Z",
"user_id":22,
"credibility":0,
"active":true,
"user_vote:0
}
}
Status | Description |
---|---|
200 | Everything went fine. |
401 | Access token is invalid or revoked. |
404 | Alert with given ID is not present |
422 | Provided data is invalid |
460 | Region ID is invalid |
POST /api/v1/en/alerts/:ID/confirmations HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
DELETE /api/v1/en/alerts/15/confirmations HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
# STATUS: 200 OK
{
"alert":{
"id":15,
"latitude":"54.025369",
"longitude:"21.765876",
"alert_type":"BAD_WEATHER_CONDITIONS",
"additional_info":"Zawody GiĹĽycko 2014",
"created_at":"2014-10-19T16:06:25.422Z",
"user_id":22,
"credibility":-5,
"active":false,
"user_vote":1
}
}
Status | Description |
---|---|
200 | Everything went fine. |
401 | Access token is invalid or revoked. |
403 | You're alert owner - you can't confirm/deny your own alert |
404 | Alert with given ID is not present |
460 | Region ID is invalid |
You can make only one action per alert - confirming it means +1 to alert creadibilty. If you change your mind and decline alert your +1 is changed for -1.
0
- user has not confirmed/denied this alert yet1
- user has confirmed this alert-1
- user has denied this alert
Each alert is archived due to check_tasks
rake task after 4 hours with no activity. Task is launched every hour.
BAD_WEATHER_CONDITIONS
CLOSED_AREA
YACHT_FAILURE
Field | Type | Comments |
---|---|---|
id |
Integer | |
region_id |
Integer | |
name |
String | |
longitude |
Decimal | Default: 0.0 |
latitude |
Decimal | Default: 0.0 |
created_at |
DateTime | |
updated_at |
DateTime | |
photo_url |
String | |
website |
String | |
city |
String | |
street |
String | |
telephone |
String | Default: true |
additional_info |
String | Default: true |
currency |
String | Default: EUR |
spots |
Integer | Default: true |
depth |
Integer | In centemeters, Default: 100 |
price_per_person |
String | Default: 0.0 |
price_power_connection |
String | Default: 0.0 |
price_wc |
String | Default: 0.0 |
price_shower |
String | Default: 0.0 |
price_washbasin |
String | Default: 0.0 |
price_dishes |
String | Default: 0.0 |
price_parking |
String | Default: 0.0 |
price_wifi |
String | Default: 0.0 |
price_washing_machine |
String | Default: 0.0 |
price_emptying_chemical_toilet |
String | Default: 0.0 |
has_power_connection |
Boolean | Default: true |
has_wc |
Boolean | Default: true |
has_shower |
Boolean | Default: true |
has_parking |
Boolean | Default: true |
has_washbasin |
Boolean | Default: true |
has_dishes |
Boolean | Default: true |
has_wifi |
Boolean | Default: true |
has_slip |
Boolean | Default: false |
has_washing_machine |
Boolean | Default: true |
has_fuel_station |
Boolean | Default: false |
has_parking |
Boolean | Default: true |
Each port can have different prices depending on boat size. Sailhero handles it by Yacht Size Range Price model:
Field | Type | Comments |
---|---|---|
id |
Integer | |
port_id |
Integer | |
min_length |
Integer | In centemetrs |
max_length |
Integer | In centemetrs |
max_width |
Integer | In centemetrs |
created_at |
DateTime | |
updated_at |
DateTime | |
price |
Float |
GET /api/v1/en/map/ports HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
# STATUS: 200 OK
{
"ports":[
{
"id": 17,
"name": "Sztynort",
"latitude": "54.130976",
"longitude": "21.682389",
"website": "http://www.tiga-yacht.com.pl/",
"city": "Wegorzewo",
"street": "Sztynort 11",
"photo_url": null,
"telephone": "+48 87 427 51 80",
"additional_info": "Showers for 10 minutes, restaurant available",
"spots": 120,
"depth": 100,
"has_power_connection": true,
"has_wc": true,
"has_shower": true,
"has_washbasin": true,
"has_dishes": true,
"has_wifi": true,
"has_parking": true,
"has_slip": false,
"has_washing_machine": true,
"has_fuel_station": true,
"has_emptying_chemical_toilet": true,
"price_per_person": 15,
"price_power_connection": 0,
"price_wc": 0,
"price_shower": 15,
"price_washbasin": 0,
"price_dishes": 0,
"price_wifi": 0,
"price_washing_machine": 15,
"price_emptying_chemical_toilet": 0,
"price_parking": 0,
"currency": "EUR"
},
...
]
}
Status | Description |
---|---|
200 | Everything went fine |
401 | Access token is invalid or revoked. |
460 | Region id is invalid |
GET /api/v1/en/map/ports/:id HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
# STATUS: 200 OK
{
"port": {
"id": 17,
"name": "Sztynort",
"latitude": "54.130976",
"longitude": "21.682389",
"website": "http://www.tiga-yacht.com.pl/",
"city": "Wegorzewo",
"street": "Sztynort 11",
"photo_url": null,
"telephone": "+48 87 427 51 80",
"additional_info": "Showers for 10 minutes, restaurant available",
"spots": 120,
"depth": 100,
"has_power_connection": true,
"has_wc": true,
"has_shower": true,
"has_washbasin": true,
"has_dishes": true,
"has_wifi": true,
"has_parking": true,
"has_slip": false,
"has_washing_machine": true,
"has_fuel_station": true,
"has_emptying_chemical_toilet": true,
"price_per_person": 15,
"price_power_connection": 0,
"price_wc": 0,
"price_shower": 15,
"price_washbasin": 0,
"price_dishes": 0,
"price_wifi": 0,
"price_washing_machine": 15,
"price_emptying_chemical_toilet": 0,
"price_parking": 0,
"currency": "EUR"
}
}
Status | Description |
---|---|
200 | Everything went fine |
401 | Access token is invalid or revoked. |
404 | Port with given id was not found or is in different region. |
460 | Region id is invalid |
GET /api/v1/en/map/ports/:id/calculate HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
# STATUS: 200 OK
{
"port": {
"cost": 135,
"currency": "EUR",
"included": [
{
name: "wc",
price: 0
},
...
],
"optional": [
{
name: "power_connection",
price: 10
},
...
]
"additional_info": "Lorem ipsum dolores..."
}
}
Status | Description |
---|---|
200 | Everything went fine |
401 | Access token is invalid or revoked. |
404 | Port with given id was not found or is in different region. |
460 | Region id is invalid |
464 | There is no spot for your yacht (is too big or too small). |
465 | You're trying to calculate port cost with no yacht. |
Field | Type |
---|---|
id |
Integer |
name |
String |
created_at |
DateTime |
updated_at |
DateTime |
Each route can have mutiple pins:
Field | Type |
---|---|
id |
Integer |
route_id |
Integer |
longitude |
Decimal |
latitude |
Decimal |
created_at |
DateTime |
updated_at |
DateTime |
GET /api/v1/en/map/routes HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
# STATUS: 200 OK
{
"routes":[
{
"id": 17,
"name": "Wielki Szlak Mazurski",
"pins":[
{
"latitude": "54.130976",
"longitude": "21.682389"
},
]
},
...
]
}
Status | Description |
---|---|
200 | Everything went fine |
401 | Access token is invalid or revoked. |
460 | Region id is invalid |
GET /api/v1/en/map/routes/:id HTTP/1.1
Host: sail-hero.dev
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Longitude: YOUR_LONGITUDE
Latitude: YOUR_LATITUDE
# STATUS: 200 OK
{
"route":{
"id": 17,
"name": "Wielki Szlak Mazurski",
"pins":[
{
"latitude": "54.130976",
"longitude": "21.682389"
},
...
]
}
}
Status | Description |
---|---|
200 | Everything went fine |
401 | Access token is invalid or revoked. |
404 | Route not found. |
460 | Region id is invalid |
Status | Description |
---|---|
460 | Region ID is invalid. |
461 | User has already created yacht. |
462 | Forever alone. You're trying to become a friend with yourself. |
463 | You're trying to become a friend with nil. |
464 | There is no spot for your yacht (is too big or too small) |
465 | You're trying to calculate port cost with no yacht. |