The API supports options that can be used to control the behavior of the API and the response that is returned.
Format Option
The API can return data in either raw form or in formatted form. At present, it is not possible to override the default character format. If the default character format does not meet the application’s requirements, retrieve the raw format and then reformat it in the application as needed.
The outputFormat option in the options section can be set to any of the following:
- raw - Return the data in raw form
- formatted - Return the data in formatted form
The following example requests that the data be returned in formatted form.
var request = { "data": { "datapoints": [ "dem.acs.pop.total.val", "dem.acs.pop.total.ayc", "dem.acs.pop.total.aycp" ] }, "criteria": { "geography": "city:burlington-vt" }, "options": { "outputFormat": "formatted" } }; var response = { "resultset": { "geography": "city:burlington-vt", "data": [ { "datapoint": "dem.acs.pop.total.val", "periods": ["2017"], "source": "acs5", "value": ["42,453"] }, { "datapoint": "dem.acs.pop.total.ayc", "periods": ["2017"], "source": "acs5", "values": ["31"] }, { "datapoint": "dem.acs.pop.total.aycp", "periods": ["2017"], "source": "acs5", "values": ["0.07%"] } ] } };
Metadata Option
The API can return metadata about the geographies, collections, and datapoints that are returned. This can be useful to obtain information about data types, titles, attribution, etc. The includeMetadata option can be set to true or false.
var request = { "data": { "datapoints": [ "dem.acs.pop.total.val" ], "collections": [ { "collection": "trn.airport", "datapoints": [ "trn.airport.name", "trn.airport.runway" ] } ] }, "criteria": { "geography": "city:burlington-vt" }, "options": { "includeMetadata": true } } var response = { { "resultset": { "geography": "city:burlington-vt", "data": [ { "datapoint": "dem.acs.pop.total.val", "period": "2017", "source": "acs5", "value": 42453 }, { "collection": "trn.airport", "items": [] } ] }, "metadata": { "geographies": { "city:burlington-vt": { "type": "city", "description": "Burlington, VT", "fipscode": "5010675" } }, "datapoints": { "dem.acs.pop.total.val": { "description": "Total Population", "attribution": "US Census, ACS" }, "trn.airport.name": { "description": "Airport Name", "attribution": "Federal Aviation Administration", "collection": "trn.airport" }, "trn.airport.runway": { "description": "Airport Maximum Runway Length", "attribution": "Federal Aviation Administration", "collection": "trn.airport" } }, "collections": { "trn.airport": { "description": "Airports", "attribution": "Federal Aviation Administration", "item": "trn.airport.item", "itemDescription": "Airport ID" } } } }
GeoJSON Option
The API can return a GeoJSON object for each geography within the metadata. This can be useful to display outlines of geographies within a GIS system. The includeGeojson option can be set to true or false. This option requires that the includeMetadata option be set to true.
Comments
0 comments
Article is closed for comments.