Woosmap for React Native - API Services

Get access to Woosmap services for your native mobile developments on hybrid React Native development.

  1. Localities API
  2. Store Search API
  3. Distance API
  4. Transit API

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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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

src/plugin_snippet.tsx
          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)}`
            );
          });

    
Was this article helpful?
Have more questions? Submit a request