Skip to content

API Get a Jurisdiction

Andrew Pollard edited this page Aug 11, 2014 · 5 revisions

The API call to retrieve information about a single jurisdiction. Provides details on approved answers to fields, votes, and comments. Filters can be used to efficiently "walk" the database, or to limit the question data to a specific subset. Filters must be passed as XML, and wrapped in the request tag. At least one filter must be specified. This is typically the "id" filter, but "first" or "last" may be used in place of a specific id number. Any combination of filters may be applied, but some may supersede others. i.e. you cannot user "next" and "previous" filters at the same time.

Service URL

https://solarpermit.org/api/read/jurisdiction/

Sample POST Request

<?xml version='1.0' encoding='utf-8'?>
<request>
	<filters>
		<first>TRUE</first>
		<limit_to_questions>1,2,3</limit_to_questions>
	</filters>
</request>

Valid Filters

id (int): The unique id number of a jurisdiction

first (str): Takes the place of a unique id. Will retrieve the jurisdiction with the lowest id number in the database. Actual value can technically be anything, but use of "TRUE" is recommended.

last (str): Takes the place of a unique id. Will retrieve the jurisdiction with the highest id number in the database. Actual value can technically be anything, but use of "TRUE" is recommended.

next (str): Shifts the returned jurisdiction by +1, automatically skipping any unused id numbers. Actual value can technically be anything, but use of "TRUE" is recommended.

previous (str): Shifts the returned jurisdiction by -1, automatically skipping any unused id numbers. Actual value can technically be anything, but use of "TRUE" is recommended.

limit_to_questions (comma separated integers): Only fields with a question id corresponding to integers in this list will be returned - all others will be ignored. Only standard questions can be accessed via the api - custom questions are unavailable.

Returns

<?xml version="1.0"?>
<result>
	<jurisdiction>
		<city type='varchar(64)'>sample city</city>
		<region_id type='int(11)'>None</region_id>
		<parent_id type='int(11)'>None</parent_id>
		<last_contributed_by_id type='int(11)'>3</last_contributed_by_id>
		<description type='longtext'>None</description>
		<create_datetime type='datetime'>2012-09-11 00:00:00</create_datetime>
		<modify_datetime type='datetime'>2013-04-10 05:05:04</modify_datetime>
		<county type='varchar(64)'>sample county</county>
		<organization_id type='int(11)'>None</organization_id>
		<last_contributed_by_org_id type='int(11)'>1</last_contributed_by_org_id>
		<state type='varchar(8)'>FL</state>
		<longitude type='decimal(10,7)'>-80.0000000</longitude>
		<last_contributed type='datetime'>2013-09-10 10:09:15</last_contributed>
		<latitude type='decimal(10,7)'>25.0000000</latitude>
		<jurisdiction_type type='varchar(8)'>CI</jurisdiction_type>
		<id type='int(11)'>1</id>
		<name type='varchar(64)'>Sample jurisdiction</name>
		<question>
			<reviewed type='tinyint(1)'>0</reviewed>
			<id type='int(11)'>1</id>
			<default_value type='longtext'>{"value":""}</default_value>
			<display_template type='longtext'>None</display_template>
			<question type='longtext'>NEC Code version</question>
			<label type='longtext'>NEC Code version</label>
			<template type='longtext'>None</template>
			<applicability_id type='int(11)'>None</applicability_id>
			<answer_choice_group_id type='int(11)'>None</answer_choice_group_id>
			<qtemplate_id type='int(11)'>2</qtemplate_id>
			<description type='longtext'>None</description>
			<migration_type type='varchar(64)'>None</migration_type>
			<has_multivalues type='tinyint(1)'>0</has_multivalues>
			<create_datetime type='datetime'>None</create_datetime>
			<modify_datetime type='datetime'>None</modify_datetime>
			<js type='longtext'>None</js>
			<field_suffix type='varchar(32)'>None</field_suffix>
			<form_type type='varchar(8)'>T</form_type>
			<accepted type='tinyint(1)'>1</accepted>
			<validation_class type='longtext'>required</validation_class>
			<state_exclusive type='longtext'>None</state_exclusive>
			<display_order type='smallint(5) unsigned'>1</display_order>
			<instruction type='longtext'></instruction>
			<field_attributes type='longtext'>maxLength='64'</field_attributes>
			<creator_id type='int(11)'>None</creator_id>
			<category_id type='int(11)'>5</category_id>
			<terminology type='longtext'>version</terminology>
			<answer>
				<file_upload type='varchar(100)'></file_upload>
				<is_callout type='tinyint(1)'>0</is_callout>
				<approval_status type='varchar(8)'>A</approval_status>
				<rating type='int(11)'>None</rating>
				<migrated_answer_id type='int(11)'>879</migrated_answer_id>
				<create_datetime type='datetime'>None</create_datetime>
				<modify_datetime type='datetime'>None</modify_datetime>
				<value type='longtext'>{"value": "70"}</value>
				<rating_status type='varchar(8)'>U</rating_status>
				<organization_id type='int(11)'>1</organization_id>
				<status_datetime type='datetime'>None</status_datetime>
				<creator_id type='int(11)'>3</creator_id>
				<is_current type='tinyint(1)'>1</is_current>
				<jurisdiction_id type='int(11)'>1</jurisdiction_id>
				<id type='int(11)'>385</id>
				<question_id type='int(11)'>1</question_id>
			</answer>
		</question>
	</jurisdiction>
</result>

Note that the type attribute on most xml tags corresponds to a MySQL data type. This was done for convenience for API users that are storing copies of information pulled via API.