Woosmap for React Native - API Services
Get access to Woosmap services for your native mobile developments on hybrid React Native development.
The Woosmap API is a RESTful API built on HTTP. It has predictable resource URLs. It returns HTTP response codes to indicate errors. It also accepts and returns JSON in the HTTP body.
Localities API
Woosmap Localities API is a web service that returns a great amount of geographical places in response to an HTTP request. Among others are city names, postal codes, suburbs, addresses or airports. Request is done over HTTPS using GET. Response is formatted as JSON. You must specify a key in your request, included as the value of a key parameter for your public key or private_key for your private key. This key identifies your application for purposes of quota management.
Autocomplete for Localities
Autocomplete on worldwide suggestions for a for text-based geographic searches. It can match on full words as well as substrings. You can therefore send queries as the user types, to provide on-the-fly city names, postal codes or suburb name suggestions.
Request parameters
input
: The text string on which to search, for example: “london”types
: “locality” “postal_code” “address” “admin_level” “country” “airport” “train_station” “metro_station” “shopping” “museum” “tourist_attraction” “amusement_park” “art_gallery” “zoo”components
: A grouping of places to which you would like to restrict your results. Components can be used to filter over countries.language
: The language code, using ISO 3166-1 Alpha-2 country codes, indicating in which language the results should be returnedlocation
: This parameter is used to add a bias to the autocomplete feature. The location defines the point around which to retrieve results in priority.radius
: This parameter may be used in addition to the location parameter to define the distance in meters within which the API will return results in priority.data
: Two values for this parameter: standard or advanced. By default, if the parameter is not defined, value is set as standard. The advanced value opens suggestions to worldwide postal codes in addition to postal codes for Western Europe. A dedicated option subject to specific billing on your license is needed to use this parameter.extended
:If set, this parameter allows a refined search over locality names that bears the same postal code.customDescription
: This parameter allows to choose the description format for all or some of the suggestion types selected. The custom formats are described as follows (available fields depend on the returned type):custom_description=type_A:"{field_1}, {field_2}, [...]"|type_B:"{field_1}, {field_2}, [...]"
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: LocalitiesAutocompleteRequest = { input: 'landon' };
api.Localities.autocomplete(apiInput)
.then((apiResult) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Details of a Locality
Provides details of an autocomplete suggestion (using the suggestion’s publicId
).
Request parameters
publicId
: A textual identifier that uniquely identifies a locality, returned from a Localities Autocomplete.language
: The language code, using ISO 3166-1 Alpha-2 country codes, indicating in which language the results should be returnedfields
: Used to limit the returning fields, default it is geometrycountryCodeFormat
: To specify the format for the short country code expected to be returned in the address_components field (default is alpha3).
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: LocalitiesDetailsRequest = { publicId: '123456' };
api.Localities.autocomplete(apiInput)
.then((apiResult) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Geocode a locality or Reverse Geocode a latlng
Provides details for an address or a geographic position. Either parameter address
or latlng
is required.
Request parameters
address
: The input string to geocode. Can represent an address, a street, a locality or a postal code.latLng
: The latlng parameter is used for reverse geocoding, it’s required if the address parameter is missing.components
: A grouping of places to which you would like to restrict your results. Components can be used to filter over countries. Countries must be passed as an ISO 3166-1 Alpha-2 or Alpha-3 compatible country code.language
: The language code, using ISO 3166-1 Alpha-2 country codes, indicating in which language the results should be returnedfields
: Used to limit the returning fieldsdata
: Two values for this parameter: standard or advanced. By default, if the parameter is not defined, value is set as standard. The advanced value opens suggestions to worldwide postal codes in addition to postal codes for Western Europe. A dedicated option subject to specific billing on your license is needed to use this parameter.countryCodeFormat
: To specify the format for the short country code expected to be returned in the address_components field.
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: LocalitiesGeocodeRequest = {address: '123 gold gym'};
api.Localities.geocode(apiInput)
.then((apiResult) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Nearby points of interest
Retrieve worldwide points of interest surrounding a given location. They can be filtered by categories.
Request parameters
- types?: types of targeted items.
point_of_interest
- location: Center of the search circle.
- radius?: radius of the search circle, in meter.
- categories?: The categories of points of interest to return. Not specifying any category will not filter returned results. Multiple categories can be passed for filter
- language?: The preferred language to match against name
- page?: use page to navigate through paginated results. default: 1
- limit?: Defines how many results should be included in a page. Default 10
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: LocalitiesNearbyRequest = {
location: { lat: 40.71399, lng: -74.00499 },
categories: [`business`],
};
api.Localities.nearby(apiInput)
.then((apiResult:LocalitiesNearbyResponse) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Search for Localities
Search for suggestions given a text-based geographic query.
Request parameters
input: he text string on which to search, for example: “london” or “123 Cross Road”. The Woosmap Localities API will return predictions matches based on this string and order the results based on their perceived relevance. types: The types of suggestion to return. excludedTypes?: The types of suggestion to exclude. components: A grouping of places to which you would like to restrict your results. Countries must be passed as an ISO 3166-1 Alpha-2 compatible country code. location: This parameter is used to add a geographical bias to the query. The location defines the point around which to retrieve results in priority. radius?: This parameter may be used in addition to the location parameter to define the distance in meters within which the API will return results in priority. language?: The language code, using ISO 639-2 Alpha-2 country codes, indicating in which language the results should be returned
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: LocalitiesSearchRequest = {
input: `royal al`,
types: [`point_of_interest`,
`locality`,
`address`,
`postal_code`],
components: {
country: ['gb','fr'],
},
location: { lat: 40.71399, lng: -74.00499 },
radius: 2000,
};
api.Localities.search(apiInput)
.then((apiResult: LocalitiesSearchResponse) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Store Search API
Stores Search API lets you search among your own Points of Interest. Find stores by geography, by attributes or by autocomplete on store names.
Autocomplete for assets
Autocomplete on localizedNames with highlighted results on asset name. Use the field localized in your query parameter to search for localized names.
Request parameters
query
: Search query combining one or more search clauses. Example:query=name:'My cool store'|type:'click_and_collect'
language
: The preferred language to match against name (defaults on Accept-Language header)limit
: You can then request stores by page usinglimit
parameters
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: StoresAutocompleteRequest = {query:'name:\'My cool store\'|type:\'click_and_collect\''};
api.Stores.autocomplete(apiInput)
.then((apiResult) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Search for assets
Used to retrieve assets from query.
Request parameters
query
: Search query combining one or more search clauses. Example:query=name:'My cool store'|type:'click_and_collect'
latLng
: To bias the results around a specific latlngradius
: To bias the results within a given circular area.polyline
: Find stores nearby an encoded polyline and inside a defined radius.storesByPage
: You can then request stores by page usingpage
andstoresByPage
parameters (Default is 100, max is 300).page
: Page number when accessing paginated storeszone
: whether to search for stores intersecting a zone
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: StoresSearchRequest = {query:'idStore:31625406'};
api.Stores.search(apiInput)
.then((apiResult) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Distance API
The Woosmap Distance API is a service providing road travel distance and duration calculations, on a Worldwide scale. Fully integrated to the Woosmap platform, it can be combined with other APIs to build advanced location based scenarios (e.g. search for closest stores or services, ressources / tasks affectation, …).
Distance Matrix
Get distances and durations for a matrix of origins and destinations, based on the recommended route between start and end points for a specified travel mode.
Request parameters
origins
: The starting points for calculating travel distance.destinations
: One or more locations to use as the finishing point for calculating travel distance. The options for the destinations parameter are the same as for the origins parametertravelMode
?: Specifies the mode of transport to use when calculating distance. Valid values aredriving
,cycling
,walking
. (if not specified default isdriving
)language
?: The language code, indicating in which language the results should be returnedunitSystem
?: Specifies the unit system to use when expressing distance as text. Two different units supported:metric
orimperial
elements
?: Specifies element values that will be part of the API response (distance and/or duration). Valid values aredistance
,duration
,duration_distance
method
?:Specifies the method to compute the route between elements:time
: fastest route (default)distance
: shortest routeavoidTolls
?: Find a route that does not pass through toll segments.avoidHighways
?: Find a route that does not pass through highway segments.avoidFerries
?: Find a route that does not pass through ferry segments.avoidZone
?: A zone to avoid is given as a polygon, formed by a list of coordinatesdepartureTime
?: Specifies the date/time at which to base the calculations on for traffic purposes.
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: DistanceMatrixRequest = {
origins: [{ lat: 48.836, lng: 2.237 }],
destinations: [
{ lat: 48.709, lng: 2.403 },
{ lat: 48.768, lng: 2.338 },
],
};
api.Distance.distancematrix(apiInput)
.then((apiResult: DistanceMatrixResponse) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Distance Route
Get distance, duration and path (as a polyline) between an origin and a destination, based on the recommended route between those two points for a specified travel mode.
Request parameters
origin
: The starting point for the route. It should be supplied in the form of latitude/longitudedestination
: The ending point for the route. It should be supplied in the form of latitude/longitudearrivalTime
?: Specifies the date/time at which to base the calculations on for traffic purposes.avoidFerries
?: Find a route that does not pass through ferry segments.avoidHighways
?: Find a route that does not pass through highway segments.avoidTolls
?: Find a route that does not pass through toll segments.avoidZones
?: A zone to avoid is given as a polygon, formed by a list of coordinatesdepartureTime
?: Specifies the date/time at which to base the calculations on for traffic purposes.details
?: Specifies if maneuver instructions should be returned (roadbook).none
|full
;language
?: The language code, indicating in which language the results should be returnedmethod
?: Specifies the method to compute the route between elements:time
: fastest route (default)distance
: shortest routetravelMode
?: Specifies the mode of transport to use when calculating distance. Valid values aredriving
,cycling
,walking
. (if not specified default isdriving
)unitSystem
?:Specifies the unit system to use when expressing distance as text. Two different units supported:metric
orimperial
provideRouteAlternatives
?: Specifies if alternative routes should be returned.waypoints
?: A list of points by which the route should pass.optimizeWaypoints
?: provided route is optimized by rearranging the waypoints in a more efficient order based on distance or time according to the method parameter.
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: DistanceRouteRequest = {
origins: { lat: 48.836, lng: 2.237 },
destinations: { lat: 48.709, lng: 2.403 },
};
api.Distance.route(apiInput)
.then((apiResult: DistanceRouteResponse) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Tolls
Get Toll costs, Toll details, distance, duration and path (as a polyline) between an origin and a destination, based on the recommended route between those two points by car.
Request parameters
origin
: The starting point for the route. It should be supplied in the form of latitude/longitude.destination
: The ending point for the route. It should be supplied in the form of latitude/longitude.arrivalTime
?: Specifies the date/time at which to base the calculations on for traffic purposes.departureTime
?: Specifies the date/time at which to base the calculations on for traffic purposes.language
?: The language code, indicating in which language the results should be returnedmethod
?: Specifies the method to compute the route between elements:time
: fastest route (default)distance
: shortest route.unitSystem
?:Specifies the unit system to use when expressing distance as text. Two different units supported:metric
orimperial
.provideRouteAlternatives
?: Specifies if alternative routes should be returned.waypoints
?: A list of points by which the route should pass.optimizeWaypoints
?: provided route is optimized by rearranging the waypoints in a more efficient order based on distance or time according to the method parameter.
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: DistanceTollsRequest = {
origins: { lat: 48.836, lng: 2.237 },
destinations: { lat: 48.709, lng: 2.403 },
};
api.Distance.route(apiInput)
.then((apiResult: DistanceTollsResponse) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Isochrone
An isochrone is a line that connects points of equal travel time around a given location. The isochrone endpoint computes areas that are reachable within a specified amount of time from a location, and returns the reachable regions as contours of lines that you can display on a map.
Request parameters
origin
: The point around which to center the isochrone. It should be supplied in the form of latitude/longitude coordinatesvalue
: The value to use for isochrone contour. You can specify time in minutes or distance in kilometers (cf. method parameter). The maximum value that can be specified is 120 (120 minutes : 2 hours or 120 km).avoidFerries
?: Find a route that does not pass through ferry segments.avoidHighways
?: Find a route that does not pass through highway segments.avoidTolls
?: Find a route that does not pass through toll segments.avoidZones
?: A zone to avoid is given as a polygon, formed by a list of coordinateslanguage
?: The language code, indicating in which language the results should be returnedmethod
?: Specifies the method to compute the route between elements:time
: fastest route (default)distance
: shortest route.unitSystem
?:Specifies the unit system to use when expressing distance as text. Two different units supported:metric
orimperial
.travelMode
?: Specifies the mode of transport to use when calculating distance. Valid values aredriving
,cycling
,walking
. (if not specified default isdriving
)
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: DistanceIsochroneRequest = {
origins: { lat: 48.836, lng: 2.237 },
value: 10,
method: "time"
};
api.Distance.isochrone(apiInput)
.then((apiResult: DistanceIsochroneResponse) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});
Transit API
Transit API uses data provided by transit agencies (real time, timetables, average travel times) to build itineraries. In addition pedestrian mode can be proposed in itineraries to reach starting and ending points and commute between transportation modes
Route
Get distance, duration, path and public transport details between an origin and a destination, based on public transportation between those two points. This endpoint provides all the information needed to evaluate an itinerary.
Request parameters
origin
: The starting point for the route. It should be supplied in the form of latitude/longitude.destination
: The ending point for the route. It should be supplied in the form of latitude/longitude.arrivalTime
?: Specifies the date/time at which to base the calculations on for transit route.departureTime
?: Specifies the date/time at which to base the calculations on for transit route.modes
?: Transit mode filter used to determine which modes of transit to include in the response. By default, all supported transit modes are permitted. Supported modes:highSpeedTrain
intercityTrain
interRegionalTrain
regionalTrain
cityTrain
bus
ferry
subway
lightRail
privateBus
inclined
aerial
busRapid
monorail
flight
spaceship
This parameter also support an exclusion list: It’s sufficient to specify each mode to exclude by prefixing it with-
. Mixing of inclusive and exclusive transit modes is not allowed.
let api = new WoosmapApi({ publicKey: <<public key from woosmap console>> }); //or new WoosmapApi({ privateKey: <<private key from woosmap console>> });
let apiInput: TransitRouteRequest = {
origins: { lat: 48.73534, lng: 2.368308 },
destination: { lat: 48.83534, lng: 2.368308 },
modes: [ "highSpeedTrain",
"intercityTrain",
"interRegionalTrain",
"regionalTrain",
"cityTrain",
"subway",
"lightRail",
"monorail",
"inclined",
"bus",
"privateBus",
"busRapid",
"ferry"],
};
api.Transit.route(apiInput)
.then((apiResult: TransitRouteResponse) => {
console.log(JSON.stringify(apiResult, undefined, 4));
})
.catch((error) => {
console.log(
`${error.message} \n\n ${JSON.stringify(error.cause, undefined, 4)}`
);
});