WhereToBuy – API


The purpose of WhereToBuy API is to give our partners the possibility to integrate in their website, informations about the distributors over the world, including geolocation coordinates, which allows the display of a world map (e.g: using Google Maps API) for a better user experience.


Authentication:

To use this API, is mandatory the usage of a username and password to include in the JSON call. The credencials must be required to us by email ("email") or "???", with the following information:





API Basics:

ID Lang Name
1 -> PTG (Portuguese)
2 -> GER (German)
3 -> ITA (Italian)
4 -> ESP (Spanish)
5 -> ENG (English)
6 -> FRA (French)
7 -> POL (Polish)
http://api.gps-webservices.com/api/v2/countries

This route will retrieve all the countries existent in the database. Usefull for a dropdown that allows extra filtering, when used with other routes provided by this API.

http://api.gps-webservices.com/api/v2/countries/lang/{idLang}

This route will retrieve all the countries existent in the database, with their name translated to the given Language ID (Default: English, if not needed, use above route).

http://api.gps-webservices.com/api/v2/brands

This route will retrieve all the brands, with the respective informations (id, name and logo).

http://api.gps-webservices.com/api/v2/country/{idCountry}/regions

This route will retrieve all the regions of the given country ID, with the respective informations (ID and name).

http://api.gps-webservices.com/api/v2/country/{idCountry}/regions/lang/{idLang}

This route will retrieve all the regions of the given country ID, with the respective informations (ID and name) translated in the desired language ID (if translation available. Default is English).





Routes:

http://api.gps-webservices.com/api/v2/b2b/{idCountry}

This route will retrieve all the Business to Business distributors that exists in the country ID inserted in the request.

http://api.gps-webservices.com/api/v2/b2b/{idCountry}/brand/{idBrand}

This route will retrieve all the Business to Business distributors that exists in the country ID, filtered by the given Brand ID.

http://api.gps-webservices.com/api/v2/b2b/{idCountry}/cities

This route will retrieve all the cities of the country ID inserted in the request. Usefull for extra filtering, with the route " .../api/v2/b2b/{idCountry}/city/{name} ", which is expecting the city name or " .../api/v2/b2b/{idCountry}/city/{name}/brand/{idBrand} ", which is expecting the city name and the Brand Id, to return all the distributors that are located in that specific city and brand (if applied).

http://api.gps-webservices.com/api/v2/b2b/{idCountry}/cities/brand/{idBrand}

Same usage of the above route. Returns the cities that have distributors of that specific brand.

http://api.gps-webservices.com/api/v2/b2b/region/{idRegion}

This route will retrieve all the Business to Business distributors within the Region Id given, with the respective informations (contacts, name, location, etc...).

http://api.gps-webservices.com/api/v2/b2b/region/{idRegion}/brand/{idBrand}

This route will retrieve all the Business to Business distributors within the Region Id and Brand Id given, with the respective informations (contacts, name, location, etc...).

http://api.gps-webservices.com/api/v2/b2c/{idCountry}

This route will retrieve all the Business to Consumer distributors that exists in the country ID inserted in the request.

http://api.gps-webservices.com/api/v2/b2c/{idCountry}/brand/{idBrand}

This route will retrieve all the Business to Consumer distributors that exists in the country ID, filtered by the given Brand ID.

http://api.gps-webservices.com/api/v2/b2c/{idCountry}/cities

This route will retrieve all the cities of the country ID inserted in the request. Usefull for extra filtering, with the route " .../api/v2/b2c/{idCountry}/city/{name} ", which is expecting the city name or " .../api/v2/b2c/{idCountry}/city/{name}/brand/{idBrand} ", which is expecting the city name and the Brand Id, to return all the distributors that are located in that specific city and brand (if applied).

http://api.gps-webservices.com/api/v2/b2c/{idCountry}/cities/brand/{idBrand}

Same usage of the above route. Returns the cities that have distributors of that specific brand.

http://api.gps-webservices.com/api/v2/b2c/region/{idRegion}

This route will retrieve all the Business to Consumer distributors within the Region Id given, with the respective informations (contacts, name, location, etc...).

http://api.gps-webservices.com/api/v2/b2c/region/{idRegion}/brand/{idBrand}

This route will retrieve all the Business to Consumer distributors within the Region Id and Brand Id given, with the respective informations (contacts, name, location, etc...).

http://api.gps-webservices.com/api/v2/distributor/{distributorID}

This route will retrieve the distributor with the distributorID inserted in the request. (B2C and B2B)

http://api.gps-webservices.com/api/v2/sales-office

This route will retrieve all the sales offices, with the respective informations (contacts, name, location, etc...).

http://api.gps-webservices.com/api/v2/sales-office/count

This route will retrieve the number of sales offices existent (number only).

http://api.gps-webservices.com/api/v2/sales-office/{officeID}

This route will retrieve the sales office informations by the id number given.



Json Example:

 function getCities(countryID) {
     $.ajax({
         url: "http://ws2.dev/api/v2/b2b/" + countryID + "/cities",
         method: "GET",
         crossDomain: true,
         headers: {
             Authorization: 'Basic ' + btoa('username:password'),
         },
         dataType: "json",
         contentType: 'application/json',
         success: function (result) {

             //Your Code

         }
     });
 }

The ajax request must have all the above options. The username and password in the example, must be replaced the username and password requested to us. (see Authentication Topic above).