Overview

The Basic PostGIS Query APIs offers functions that combine basic PostGIS functions, modify them slightly, or perform basic, commonly-used operations such as "nearest".

nearest

Description: Querries Giraffe Geo tables and returns nearest entries ordered by distance

Endpoint: https://api.giraffegeo.com/nearest

Fields without a default are required.

parameter default description
schema - target schema
table - target table
lat - latitude of point to query
lng - longitude of point to query
dwithin 0.0001 for SRID = 4269 and SRID = 4326 greatest distance from lat/lng to queried entries
limit 10 number of entries returned

Example python implementation

import requests

headers = {'x-api-key':'your_key'}
payload = {
           'schema':'military',
           'table':'mirta_points',
           'lat':'34.14',
           'lng':'-118.27',
           'dwithin':'0.5'
           }

r = requests.get('https://api.giraffegeo.com/nearest', headers=headers, params=payload,)

within

Description: Querries Giraffe Geo tables and returns all database rows for which the lat/lng pair provided is within the row geometry.

Endpoint: https://api.giraffegeo.com/within

Required query parameters

parameter description
schema target schema
table target table
lat latitude of point to query
lng longitude of point to query
srid srid of target table

Example python implementation

import requests

headers = {'x-api-key':'your_key'}
payload = {
           'schema':'cartographicboundary',
           'table':'cb_2016_us_county_500k',
           'lat':'34.14',
           'lng':'-118.27'
           }

r = requests.get('https://api.giraffegeo.com/within', headers=headers, params=payload,)