API Services

Locations API

Location By Address API

class bingmaps.apiservices.LocationByAddress(data, http_protocol='http')[source]

Location by address API class

This class is used to retrieve the output from the given data from the user.

  • First, the data is used to build a URL which is related to the Locations by Address API.

  • Second, this class helps in retrieving the response from the URL built

  • Third, based on the response, this class helps in retrieving all the corresponding output data from the response. Some of the output data which this class would be retrieving is:

    • Coordinates (latitude/longitude)
    • BoundingBox coordinates (south latitude, west longitude, north latitude, east longitude)
    • Address

The output from the URL can be either JSON/XML based on the output parameter mentioned in the data. Even the output response is ‘xml’, this class helps in converting the xml response to JSON data first and then retrieve all the necessary output from it.

Variables:
  • data – The data that the user will send in to the Location by address to retrieve all the respective output from the response
  • url – The url that gets built based on the user’s given data
  • http_protocol

    Http protocol for the URL. Can be either of the following:

    • http
    • https
  • schema – The schema that gets used to build the URL and the schema is LocationByAddressUrl for location by address API service.
  • file_name

    The filename that the class can write the JSON response to.

    • file_name - ‘locationByAddress’
  • locationApiData – Response from the URL

Some of the examples are illustrated in Examples page

build_url()[source]

Build the url and replaces /None/ with empty string

get_address

Retrieves addresses from the output JSON/XML response

Returns:
address (namedtuple): List of named tuples of addresses
get_bbox

Retrieves the bounding box coordinates from the output JSON/XML response

Returns:
boundingbox (namedtuple): List of named tuples of bounding box coordinates
get_coordinates

Retrieves coordinates (latitudes/longitudes) from the output JSON/XML response

Returns:
coordinates (namedtuple): List of named tuples of coordinates (latitudes and longitudes)
get_data()[source]

Gets data from the built url

response

Returns response form the URL

status_code

Returns status code from the URL response

to_json_file(path, file_name=None)

Method to write response to a JSON file with the given file name

Location By Point API

class bingmaps.apiservices.LocationByPoint(data, http_protocol='http')[source]

Location by point API class

This class is used to retrieve the output from the given data from the user.

  • First, the data is used to build a URL which is related to the Location by Point API.

  • Second, this class helps in retrieving the response from the URL built

  • Third, based on the response, this class helps in retrieving all the corresponding output data from the response. Some of the output data which this class would be retrieving is:

    • Coordinates (latitude/longitude)
    • BoundingBox coordinates (south latitude, west longitude, north latitude, east longitude)
    • Address

The output from the URL can be either JSON/XML based on the output parameter mentioned in the data. Even the output response is ‘xml’, this class helps in converting the xml response to JSON data first and then retrieve all the necessary output from it.

Variables:
  • data – The data that the user will send in to the Location by point to retrieve all the respective output from the response
  • url – The url that gets built based on the user’s given data
  • http_protocol

    Http protocol for the URL. Can be either of the following:

    • http
    • https
  • schema – The schema that gets used to build the URL and the schema is LocationByPointUrl for location by point API service.
  • file_name

    The filename that the class can write the JSON response to.

    • file_name - ‘locationByPoint’
  • locationApiData – Response from the URL

Some of the examples are illustrated in Examples page

build_url()[source]

Build the url and replaces /None/ with ‘/’

get_address

Retrieves addresses from the output JSON/XML response

Returns:
address (namedtuple): List of named tuples of addresses
get_bbox

Retrieves the bounding box coordinates from the output JSON/XML response

Returns:
boundingbox (namedtuple): List of named tuples of bounding box coordinates
get_coordinates

Retrieves coordinates (latitudes/longitudes) from the output JSON/XML response

Returns:
coordinates (namedtuple): List of named tuples of coordinates (latitudes and longitudes)
get_data()[source]

Gets data from the built url

response

Returns response form the URL

status_code

Returns status code from the URL response

to_json_file(path, file_name=None)

Method to write response to a JSON file with the given file name

Location By Query API

class bingmaps.apiservices.LocationByQuery(data, http_protocol='http')[source]

Location by query API class

This class is used to retrieve the output from the given data from the user.

  • First, the data is used to build a URL which is related to the Location by Query API.

  • Second, this class helps in retrieving the response from the URL built

  • Third, based on the response, this class helps in retrieving all the corresponding output data from the response. Some of the output data which this class would be retrieving is:

    • Coordinates (latitude/longitude)
    • BoundingBox coordinates (south latitude, west longitude, north latitude, east longitude)
    • Address

The output from the URL can be either JSON/XML based on the output parameter mentioned in the data. Even the output response is ‘xml’, this class helps in converting the xml response to JSON data first and then retrieve all the necessary output from it.

Variables:
  • data – The data that the user will send in to the Location by query to retrieve all the respective output from the response
  • url – The url that gets built based on the user’s given data
  • http_protocol

    Http protocol for the URL. Can be either of the following:

    • http
    • https
  • schema – The schema that gets used to build the URL and the schema is LocationByQueryUrl for location by query API service.
  • file_name

    The filename that the class can write the JSON response to.

    • file_name - ‘locationByQuery’
  • locationApiData – Response from the URL

Some of the examples are illustrated in Examples page

build_url()[source]

Build the url and replaces /None/ with empty string

get_address

Retrieves addresses from the output JSON/XML response

Returns:
address (namedtuple): List of named tuples of addresses
get_bbox

Retrieves the bounding box coordinates from the output JSON/XML response

Returns:
boundingbox (namedtuple): List of named tuples of bounding box coordinates
get_coordinates

Retrieves coordinates (latitudes/longitudes) from the output JSON/XML response

Returns:
coordinates (namedtuple): List of named tuples of coordinates (latitudes and longitudes)
get_data()[source]

Gets data from the built url

response

Returns response form the URL

status_code

Returns status code from the URL response

to_json_file(path, file_name=None)

Method to write response to a JSON file with the given file name

Elevations API

class bingmaps.apiservices.ElevationsApi(data, http_protocol='http')[source]

Elevations API class

This class is used to retrieve the output from the given data from the user.

  • First, the data is used to build a URL which is related to the Elevations API.

  • Second, this class helps in retrieving the response from the URL built

  • Third, based on the response, this class helps in retrieving all the corresponding output data from the response. Some of the output data which this class would be retrieving is:

    • Elevations
    • Offsets
    • Zoom Level

The output from the URL can be either JSON/XML based on the output parameter mentioned in the data. Even the output response is ‘xml’, this class helps in converting the xml response to JSON data first and then retrieve all the necessary output from it.

Variables:
  • data – The data that the user will send in to the ElevationsApi to retrieve all the respective output from the response
  • url – The url that gets built based on the user’s given data
  • http_protocol

    Http protocol for the URL. Can be either of the following:

    • http
    • https
  • schema – The schema that gets used to build the URL and the schema is based in the ‘method’ field in the data.
  • file_name

    The filename that the class can write the JSON response to.

    • file_name - ‘elevations’
  • elevationdata – Response from the URL

Some of the examples are illustrated in Examples page

build_url()[source]

Builds the URL for elevations API services based on the data given by the user.

Returns:
url (str): URL for the elevations API services
elevations

Retrieves elevations/offsets from the output response

Returns:
elevations/offsets (namedtuple): A named tuple of list of elevations/offsets
get_data()[source]

Gets data from the given url

response

Response from the built URL

response_to_dict()[source]

This method helps in returning the output JSON data from the URL and also it helps in converting the XML output/response (string) to a JSON object

Returns:
data (dict): JSON data from the output/response
status_code

Status code of the response from the URL

to_json_file(path, file_name=None)[source]

Writes output to a JSON file with the given file name

zoomlevel

Retrieves zoomlevel from the output response

Returns:
zoomlevel (namedtuple): A namedtuple of zoomlevel from the output response

Traffic Incidents API

class bingmaps.apiservices.TrafficIncidentsApi(data, http_protocol='http')[source]

Traffic Incidents API class

This class is used to retrieve the output from the given data from the user.

  • First, the data is used to build a URL which is related to the Traffic Incidents API.

  • Second, this class helps in retrieving the response from the URL built

  • Third, based on the response, this class helps in retrieving all the corresponding output data from the response. Some of the output data which this class would be retrieving is:

    • coordinates
    • description
    • congestion
    • detour info
    • road closed info
    • incident id
    • lane info
    • start time of the incident
    • end time of the incident
    • last modified time of the incident
    • severity of the incident
    • type of the incident
    • verification status

The output from the URL can be either JSON/XML based on the output parameter mentioned in the data. Even the output response is ‘xml’, this class helps in converting the xml response to JSON data first and then retrieve all the necessary output from it.

Variables:
  • data – The data that the user will send in to the TrafficIncidentsApi to retrieve all the respective output from the response
  • url – The url that gets built based on the user’s given data
  • http_protocol

    Http protocol for the URL. Can be either of the following:

    • http
    • https
  • schema – The schema that gets used to build the URL and the schema would be .
  • file_name

    The filename that the class can write the JSON response to TrafficIncidentsSchema.

    • file_name - ‘traffic_incidents’
  • incidents_data – Response from the URL

Some of the examples are illustrated in Examples page

build_url()[source]

Builds the URL for elevations API services based on the data given by the user.

Returns:
url (str): URL for the elevations API services
congestion

Retrieves the congestion information of the incident/incidents from the output response

Returns:
congestion(namedtuple): List of named tuples of congestion info of the incident/incidents
description

Retrieves the description of the incident/incidents from the output response

Returns:
description(namedtuple): List of named tuples of descriptions of the incident/incidents
detour_info

Retrieves the detour information of the incident/incidents from the output response

Returns:
detour_info(namedtuple): List of named tuples of detour info of the incident/incidents
end_time

Retrieves the end time of the incident/incidents from the output response

Returns:
end_time(namedtuple): List of named tuples of end time of the incident/incidents
get_coordinates

Retrieves coordinates (latitudes/longitudes) from the output JSON/XML response

Returns:
coordinates (namedtuple): List of named tuples of coordinates (latitudes and longitudes)
incident_id

Retrieves the incident id/ids of the incident/incidents from the output response

Returns:
incident_id(namedtuple): List of named tuples of incident id/ids of the incident/incidents
is_verified

Retrieves the verification status of the incident/incidents from the output response

Returns:
verified(namedtuple): List of named tuples of verification status of the incident/incidents
lane_info

Retrieves the lane info of the incident/incidents from the output response

Returns:
lane_info(namedtuple): List of named tuples of lane info of the incident/incidents
last_modified

Retrieves the last modified time stamp of the incident/incidents from the output response

Returns:
last_modified(namedtuple): List of named tuples of last modified time stamp of the incident/incidents
response

Response from the built URL

response_to_dict()[source]

This method helps in returning the output JSON data from the URL and also it helps in converting the XML output/response (string) to a JSON object

Returns:
data (dict): JSON data from the output/response
road_closed

Retrieves the road closed information for the incident/incidents from the output response

Returns:
road_closed(namedtuple): List of named tuples of road closed information for the incident/incidents
severity

Retrieves the severity for the incident/incidents from the output response

Returns:
severity(namedtuple): List of named tuples of severity for the incident/incidents
start_time

Retrieves the start time of the incident/incidents from the output response

Returns:
start_time(namedtuple): List of named tuples of start time of the incident/incidents
status_code

Status code of the response from the URL

type

Retrieves the type of the incident/incidents from the output response

Returns:
type(namedtuple): List of named tuples of type of the incident/incidents