Introduction
Welcome to the KB GeoRisk API documentation! You can use the tabs at the top right to change the examples’ programming language.
Authentication
To authenticate, use this code:
class DistanceToCoastResponse {
private Double distanceInMiles;
private Point targetPoint;
private Point coastalPoint;
... setters and getters ...
}
class Point {
private Double lat;
private Double lng;
... setters and getters ...
}
// With Spring
@Autowired RestTemplate restTemplate;
HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995", HttpMethod.GET, new HttpEntity(headers), DistanceToCoastResponse.class);
// With jQuery
$.ajax({
type: 'GET',
headers: {
"kb-auth-token": "myauthtoken"
},
url: "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
}).done(function(data) {
console.log(data.distanceInMiles);
});
# In the shell, you can pass the authentication header with each request
curl "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
-H "kb-auth-token: myauthtoken"
Make sure to replace
myauthtoken
with your API key.
KB GeoRisk uses authentication tokens to provide access to the API. Your authentication token is provided when your business starts using KB Geo.
We expect the authentication token to be sent in all API requests via the kb-auth-token
header like this:
kb-auth-token: myauthtoken
API Methods
Distance to Coast by Lat/Lng
class DistanceToCoastResponse {
private Double distanceInMiles;
private Point targetPoint;
private Point coastalPoint;
... setters and getters ...
}
class Point {
private Double lat;
private Double lng;
... setters and getters ...
}
// With Spring
@Autowired RestTemplate restTemplate;
HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995", HttpMethod.GET, new HttpEntity(headers), DistanceToCoastResponse.class);
// With jQuery
$.ajax({
type: 'GET',
headers: {
"kb-auth-token": "myauthtoken"
},
url: "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
}).done(function(data) {
console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
-H "kb-auth-token: myauthtoken"
The response body is JSON structured like this:
{
"distanceInMiles": 702.4893212372758,
"targetPoint": {
"lat": 43.045583,
"lng": -89.3799951
},
"coastlinePoint": {
"lat": 38.662389,
"lng": -77.236111
}
}
If you already have the latitude/longitude for the geographic point you’re interested in, you can pass them to the KB GeoRisk Distance to Coast service as querystring parameters.
HTTP Request
GET https://api.kbgeo.com/coastal-distance/v2/coord?lat=<latitude>&lng=<longitude>
Query Parameters
Parameter | Required | Example | Description |
---|---|---|---|
lat | yes | 43.045583 | The latitude of the target coordinate |
lng | yes | -89.3799951 | The longitude of the target coordinate |
HTTP Response
distanceInMiles
is the distance to the nearest coastline in milestargetPoint
is the interior point you sent with your requestcoastlinePoint
is the coastline point nearest to thetargetPoint
Distance to Coast by Address
class DistanceToCoastResponse {
private Double distanceInMiles;
private Point targetPoint;
private Point coastalPoint;
... setters and getters ...
}
class Point {
private Double lat;
private Double lng;
... setters and getters ...
}
// With Spring
@Autowired RestTemplate restTemplate;
HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/coastal-distance/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713", HttpMethod.GET, new HttpEntity(headers), DistanceToCoastResponse.class);
// With jQuery
$.ajax({
type: 'GET',
headers: {
"kb-auth-token": "myauthtoken"
},
url: "https://api.kbgeo.com/coastal-distance/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
}).done(function(data) {
console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/coastal-distance/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
-H "kb-auth-token: myauthtoken"
The response body is JSON structured like this:
{
"distanceInMiles": 702.4893212372758,
"targetPoint": {
"lat": 43.045583,
"lng": -89.3799951
},
"coastlinePoint": {
"lat": 38.662389,
"lng": -77.236111
}
}
If you don’t know the latitude/longitude for the geographic point you’re interested in, KB GeoRisk’s Distance to Coast API can geocode the address and find its distance to coast all in one step.
HTTP Request
GET https://api.kbgeo.com/coastal-distance/address?address=<full address>
URL Parameters
Parameter | Example | Description |
---|---|---|
address | 1919 Alliant Energy Center Way, Madison, WI 53713 | The address to look up |
HTTP Response
distanceInMiles
is the distance to the nearest coastline in milestargetPoint
is the interior point you sent with your requestcoastlinePoint
is the coastline point nearest to thetargetPoint
Nearest Fire Station by Lat/Lng
class NearestFireStationResponse {
private Double distanceInMiles;
private Long drivingDurationInSeconds;
private Point targetPoint;
private FireStation fireDepartment;
... setters and getters ...
}
class Point {
private Double lat;
private Double lng;
... setters and getters ...
}
class FireStation {
private String stateId;
private String name;
private String address;
private String city;
private String state;
private String zip;
private String county;
private String staffType;
private String organizationType;
private String website;
private Integer stationCount;
private Integer careerFirefighterCount;
private Integer volunteerFirefighterCount;
private Integer paidPerCallFirefighterCount;
private Integer paidCivilianCount;
private Integer volunteerCivilianCount;
private BigDecimal lat;
private BigDecimal lng;
... setters and getters ...
}
// With Spring
@Autowired RestTemplate restTemplate;
HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/fire-station/v2/coord?lat=43.045583&lng=-89.379995", HttpMethod.GET, new HttpEntity(headers), NearestFireStationResponse.class);
// With jQuery
$.ajax({
type: 'GET',
headers: {
"kb-auth-token": "myauthtoken"
},
url: "https://api.kbgeo.com/fire-station/v2/coord?lat=43.045583&lng=-89.379995"
}).done(function(data) {
console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/fire-station/v2/coord?lat=43.045583&lng=-89.379995"
-H "kb-auth-token: myauthtoken"
If you already have the latitude/longitude for the geographic point you’re interested in, you can pass them to the KB GeoRisk Nearest Fire Station service as querystring parameters.
HTTP Request
GET https://api.kbgeo.com/coastal-distance/v2/coord?lat=<latitude>&lng=<longitude>
Query Parameters
Parameter | Required | Example | Description |
---|---|---|---|
lat | yes | 43.045583 | The latitude of the target coordinate |
lng | yes | -89.3799951 | The longitude of the target coordinate |
HTTP Response
distanceInMiles
is the linear distance to the nearest fire station in milesdrivingDurationInSeconds
is the estimated time, in seconds, to drive a legal route between the nearest fire station and the geocoordinate sent in your requesttargetPoint
is the geocoordinate you sent with your requestfireDepartment
is the nearest fire station containing:lat
the station's latitudelng
the station's longitudestateId
the state-specific identifier of this stationname
the official name of this stationaddress
the street address of this stationcity
the city of this station's addressstate
the state of this station's addresszip
the postal code of this station's addresscounty
the county of this station's addressstaffType
the station's staff type, such as 'Mostly volunteer'organizationType
the station's organization type, such as 'Career' or 'Mixed'website
the station's website URL, if providedstationCount
the number of stations in this station's districtcareerFirefighterCount
the number of career firefighters at this stationvolunteerFirefighterCount
the number of volunteer firefighters at this stationpaidPerCallFirefighterCount
the number of contract firefighters at this stationpaidCivilianCount
the number of civilian employees at this stationvolunteerCivilianCount
the number of civilian volunteers at this station
Nearest Fire Station by Address
class NearestFireStationResponse {
private Double distanceInMiles;
private Long drivingDurationInSeconds;
private Point targetPoint;
private FireStation fireDepartment;
... setters and getters ...
}
class Point {
private Double lat;
private Double lng;
... setters and getters ...
}
class FireStation {
private String stateId;
private String name;
private String address;
private String city;
private String state;
private String zip;
private String county;
private String staffType;
private String organizationType;
private String website;
private Integer stationCount;
private Integer careerFirefighterCount;
private Integer volunteerFirefighterCount;
private Integer paidPerCallFirefighterCount;
private Integer paidCivilianCount;
private Integer volunteerCivilianCount;
private BigDecimal lat;
private BigDecimal lng;
... setters and getters ...
}
// With Spring
@Autowired RestTemplate restTemplate;
HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713", HttpMethod.GET, new HttpEntity(headers), NearestFireStationResponse.class);
// With jQuery
$.ajax({
type: 'GET',
headers: {
"kb-auth-token": "myauthtoken"
},
url: "https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
}).done(function(data) {
console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
-H "kb-auth-token: myauthtoken"
If you don’t know the latitude/longitude for the geographic point you’re interested in, KB GeoRisk’s Nearest Fire Station API can geocode the address and find the nearest fire station all in one step.
HTTP Request
GET https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713;
Query Parameters
Parameter | Example | Description |
---|---|---|
address | 1919 Alliant Energy Center Way, Madison, WI 53713 | The address to look up |
HTTP Response
distanceInMiles
is the linear distance to the nearest fire station in milesdrivingDurationInSeconds
is the estimated time, in seconds, to drive a legal route between the nearest fire station and the geocoordinate sent in your requesttargetPoint
is the geocoordinate of the address you sent with your requestfireDepartment
is the nearest fire station containing:lat
the station's latitudelng
the station's longitudestateId
the state-specific identifier of this stationname
the official name of this stationaddress
the street address of this stationcity
the city of this station's addressstate
the state of this station's addresszip
the postal code of this station's addresscounty
the county of this station's addressstaffType
the station's staff type, such as 'Mostly volunteer'organizationType
the station's organization type, such as 'Career' or 'Mixed'website
the station's website URL, if providedstationCount
the number of stations in this station's districtcareerFirefighterCount
the number of career firefighters at this stationvolunteerFirefighterCount
the number of volunteer firefighters at this stationpaidPerCallFirefighterCount
the number of contract firefighters at this stationpaidCivilianCount
the number of civilian employees at this stationvolunteerCivilianCount
the number of civilian volunteers at this station
Errors
The KB GeoRisk Distance to Coast API may return any of these HTTP status codes
Error Code Description Resolution 400 Bad Request – Invalid parameters in URL Verify parameters in URL match the API documentation 401 Unauthorized – Invalid authentication token or you don’t subscribe to this endpoint Verify the authentication token set in kb-auth-token
. If you need access to an endpoint not on your account, contact KB GeoRisk.404 Not Found – The URL you tried to reach does not exist Verify the URL you are requesting matches the API documentation 405 Method Not Allowed – Your request specified an inappropriate HTTP verb Verify your request uses the HTTP verb specified in the API documentation 429 Too Many Requests – Your account has exceeded its maximum requests-per-minute Wait ten minutes and try again. If you need a higher requests-per-minute, contact KB GeoRisk. 500 Internal Server Error – Something unexpected happened on our server Notify KB GeoRisk and try again later. We do monitor these errors and respond as quickly as possibly. 503 Service Unavailable – We’re temporarily offline for maintanance Please try again later