Location
List Addresses
GET
https://api.stretch.com/api/v1/nav/locations
List of all available user addresses
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/nav/locations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/nav/locations, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/locations" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/locations" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/locations'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/locations' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/locations" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/locations"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/locations' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Successful Response (200)
AddressOut
[{
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string" ,
"id" : "b83687c8-e2ee-4b13-9ae3-c470573d85b0"
},{
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string" ,
"id" : "c034d369-39b4-40bf-b663-5bd5d8afbba1"
}]
Create
POST
https://api.stretch.com/api/v1/nav/location
Create new user address
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
lng required
number
55.296249
lat required
number
25.276
zoom
number default: _17_
14
isDefault
boolean
name
string
name
Name of address
address
string
Address
548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE
country
string
Country
United Arab Emirates
state
string
state
Dubai
city
string
city
Dubai
line1
string
line1
Jumeirah Lake Towers
line2
string
line2
1068, Tower Meadows 2
zip
string
zip (po box)
details
string
notes for address
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/nav/location" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"lng": 55.296249,
"lat": 25.276,
"zoom": 14,
"isDefault": False,
"name": "Name of address",
"address": "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE",
"country": "United Arab Emirates",
"state": "Dubai",
"city": "Dubai",
"line1": "Jumeirah Lake Towers",
"line2": "1068, Tower Meadows 2",
"zip": "string",
"details": "string"
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
response = requests . post ( "https://api.stretch.com/api/v1/nav/location" , headers = headers , json = payload )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/location" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
);
$data_string = json_encode ( $payload );
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true ); curl_setopt ( $ch , CURLOPT_POST , true );
curl_setopt ( $ch , CURLOPT_POSTFIELDS , $data_string );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.io.OutputStream ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/location" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
};
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
connection . setDoOutput ( true );
OutputStream outputStream = connection . getOutputStream ();
outputStream . write ( payload . getBytes ( "UTF-8" ));
outputStream . flush ();
outputStream . close ();
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/location'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"lng" : 55 . 296249 ,
"lat" : 25 . 276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
} . to_json
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Post . new ( uri . request_uri , headers )
request . body = payload
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/location' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
};
axios
. post ( url , payload , { headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
using System.Text ;
using System.Threading.Tasks ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" );
var payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/location" ), content );
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/location"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
jsonPayload , err := json . Marshal ( payload )
req , err := http . NewRequest ( "POST" , url , bytes . NewBuffer ( jsonPayload ))
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/location' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
final payload = jsonEncode ( application / json );
try {
final response = await http . post ( Uri . parse ( url ), headers: headers , body: payload );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Successful Response (201) Validation Error (422)
AddressOut
{
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string" ,
"id" : "42312109-607a-4922-96f8-b760d99a6e36"
}
Update Location
PUT
https://api.stretch.com/api/v1/nav/location/{location_id}
Update user address by id
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
lng
number
55.296249
lat
number
25.276
zoom
number default: _17_
14
isDefault
boolean
name
string
name
Name of address
address
string
Address
548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE
country
string
Country
United Arab Emirates
state
string
state
Dubai
city
string
city
Dubai
line1
string
line1
Jumeirah Lake Towers
line2
string
line2
1068, Tower Meadows 2
zip
string
zip (po box)
details
string
notes for address
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X PUT \
--url "https://api.stretch.com/api/v1/nav/location/{location_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"lng": 55.296249,
"lat": 25.276,
"zoom": 14,
"isDefault": False,
"name": "Name of address",
"address": "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE",
"country": "United Arab Emirates",
"state": "Dubai",
"city": "Dubai",
"line1": "Jumeirah Lake Towers",
"line2": "1068, Tower Meadows 2",
"zip": "string",
"details": "string"
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
response = requests . put ( "https://api.stretch.com/api/v1/nav/location/ {location_id} " , headers = headers , json = payload )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/location/{location_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
);
$data_string = json_encode ( $payload );
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true ); curl_setopt ( $ch , CURLOPT_POST , true );
curl_setopt ( $ch , CURLOPT_POSTFIELDS , $data_string );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.io.OutputStream ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/location/{location_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
};
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "PUT" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
connection . setDoOutput ( true );
OutputStream outputStream = connection . getOutputStream ();
outputStream . write ( payload . getBytes ( "UTF-8" ));
outputStream . flush ();
outputStream . close ();
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/location/{location_id}'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"lng" : 55 . 296249 ,
"lat" : 25 . 276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
} . to_json
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Put . new ( uri . request_uri , headers )
request . body = payload
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/location/{location_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
};
axios
. put ( url , payload , { headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
using System.Text ;
using System.Threading.Tasks ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" );
var payload = {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PutAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/location/{location_id}" ), content );
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/location/{location_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string"
}
jsonPayload , err := json . Marshal ( payload )
req , err := http . NewRequest ( "PUT" , url , bytes . NewBuffer ( jsonPayload ))
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/location/{location_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
final payload = jsonEncode ( application / json );
try {
final response = await http . post ( Uri . parse ( url ), headers: headers , body: payload );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Successful Response (200) Bad Request (404) Validation Error (422)
AddressOut
{
"lng" : 55.296249 ,
"lat" : 25.276 ,
"zoom" : 14 ,
"isDefault" : False ,
"name" : "Name of address" ,
"address" : "548, floor 5, Cluster G, Tower Al mas, JLT, Dubai, UAE" ,
"country" : "United Arab Emirates" ,
"state" : "Dubai" ,
"city" : "Dubai" ,
"line1" : "Jumeirah Lake Towers" ,
"line2" : "1068, Tower Meadows 2" ,
"zip" : "string" ,
"details" : "string" ,
"id" : "b6ad270c-ea22-4ce7-93a7-efaf321db501"
}
ErrorResponse
{
"code" : 404
"error" : "nav_address_not_found"
"message" : "Location not found"
}
ErrorResponse:
error string
message string
code integer
Delete Location
DELETE
https://api.stretch.com/api/v1/nav/location/{location_id}
Delete user address by id
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X DELETE \
--url "https://api.stretch.com/api/v1/nav/location/{location_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . delete ( "https://api.stretch.com/api/v1/nav/location/ {location_id} , headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/location/{location_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/location/{location_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "DELETE" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/location/{location_id}'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Delete . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/location/{location_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. delete ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . DeleteAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/location/{location_id}" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/location/{location_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "DELETE" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/location/{location_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . delete ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Bad Request (404) Validation Error (422)
ErrorResponse
{
"code" : 404
"error" : "nav_address_not_found"
"message" : "Location not found"
}
ErrorResponse:
error string
message string
code integer
Get Zones
GET
https://api.stretch.com/api/v1/nav/zones
Get all available location zone (under dev)
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/nav/zones" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/nav/zones, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/zones" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/zones" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/zones'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/zones' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/zones" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/zones"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/zones' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Zone Create
POST
https://api.stretch.com/api/v1/nav/zone
Create new location zone for coach (under dev)
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
lng required
number
55.296249
lat required
number
25.276
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/nav/zone" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"lng": 55.296249,
"lat": 25.276
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"lng" : 55.296249 ,
"lat" : 25.276
}
response = requests . post ( "https://api.stretch.com/api/v1/nav/zone" , headers = headers , json = payload )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/zone" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"lng" : 55.296249 ,
"lat" : 25.276
}
);
$data_string = json_encode ( $payload );
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true ); curl_setopt ( $ch , CURLOPT_POST , true );
curl_setopt ( $ch , CURLOPT_POSTFIELDS , $data_string );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.io.OutputStream ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/zone" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"lng" : 55.296249 ,
"lat" : 25.276
};
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
connection . setDoOutput ( true );
OutputStream outputStream = connection . getOutputStream ();
outputStream . write ( payload . getBytes ( "UTF-8" ));
outputStream . flush ();
outputStream . close ();
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/zone'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"lng" : 55 . 296249 ,
"lat" : 25 . 276
} . to_json
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Post . new ( uri . request_uri , headers )
request . body = payload
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/zone' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"lng" : 55.296249 ,
"lat" : 25.276
};
axios
. post ( url , payload , { headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
using System.Text ;
using System.Threading.Tasks ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" );
var payload = {
"lng" : 55.296249 ,
"lat" : 25.276
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/zone" ), content );
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/zone"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"lng" : 55.296249 ,
"lat" : 25.276
}
jsonPayload , err := json . Marshal ( payload )
req , err := http . NewRequest ( "POST" , url , bytes . NewBuffer ( jsonPayload ))
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/zone' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
final payload = jsonEncode ( application / json );
try {
final response = await http . post ( Uri . parse ( url ), headers: headers , body: payload );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Zone Update
PUT
https://api.stretch.com/api/v1/nav/zone/{zone_id}
Update coach location zone (under dev)
Input Fields / Form-Data / JSON
Query Parameter
Type
Description
Example
lng required
number
55.296249
lat required
number
25.276
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X PUT \
--url "https://api.stretch.com/api/v1/nav/zone/{zone_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"lng": 55.296249,
"lat": 25.276
}'
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
payload = {
"lng" : 55.296249 ,
"lat" : 25.276
}
response = requests . put ( "https://api.stretch.com/api/v1/nav/zone/ {zone_id} " , headers = headers , json = payload )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/zone/{zone_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$payload = array (
{
"lng" : 55.296249 ,
"lat" : 25.276
}
);
$data_string = json_encode ( $payload );
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true ); curl_setopt ( $ch , CURLOPT_POST , true );
curl_setopt ( $ch , CURLOPT_POSTFIELDS , $data_string );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.io.OutputStream ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/zone/{zone_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
String payload = {
"lng" : 55.296249 ,
"lat" : 25.276
};
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "PUT" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
connection . setDoOutput ( true );
OutputStream outputStream = connection . getOutputStream ();
outputStream . write ( payload . getBytes ( "UTF-8" ));
outputStream . flush ();
outputStream . close ();
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/zone/{zone_id}'
access_token = 'YOUR_ACCESS_TOKEN'
payload = {
"lng" : 55 . 296249 ,
"lat" : 25 . 276
} . to_json
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Put . new ( uri . request_uri , headers )
request . body = payload
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/zone/{zone_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
const payload = {
"lng" : 55.296249 ,
"lat" : 25.276
};
axios
. put ( url , payload , { headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
using System.Text ;
using System.Threading.Tasks ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" );
var payload = {
"lng" : 55.296249 ,
"lat" : 25.276
}
var content = new StringContent ( payload , Encoding . UTF8 , "application/json" );
var response = await client . PutAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/zone/{zone_id}" ), content );
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"bytes"
"encoding/json"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/zone/{zone_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
payload := map [ string ] string {
"lng" : 55.296249 ,
"lat" : 25.276
}
jsonPayload , err := json . Marshal ( payload )
req , err := http . NewRequest ( "PUT" , url , bytes . NewBuffer ( jsonPayload ))
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/zone/{zone_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
final payload = jsonEncode ( application / json );
try {
final response = await http . post ( Uri . parse ( url ), headers: headers , body: payload );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Zone Delete
DELETE
https://api.stretch.com/api/v1/nav/zone/{zone_id}
Delete coach location zone (under dev)
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X DELETE \
--url "https://api.stretch.com/api/v1/nav/zone/{zone_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . delete ( "https://api.stretch.com/api/v1/nav/zone/ {zone_id} , headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/nav/zone/{zone_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/nav/zone/{zone_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "DELETE" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/nav/zone/{zone_id}'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Delete . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/nav/zone/{zone_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. delete ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . DeleteAsync ( new Uri ( "https://api.stretch.com/api/v1/nav/zone/{zone_id}" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/nav/zone/{zone_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "DELETE" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/nav/zone/{zone_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . delete ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response