(Created page with " This spec has been frozen and finalized, but the documentation will continue to be updated for clarity. Join the [http://lists.open311.org/groups/discuss Mailing List] for updat...") |
|||
| Line 66: | Line 66: | ||
===GET Service List=== | ===GET Service List=== | ||
| − | + | {| class="method-table" | |
| − | + | !scope="row" | Purpose | |
| − | + | | provide a list of acceptable 311 service request types and their associated service codes. These request types can be unique to the city/jurisdiction. | |
| − | + | |- | |
| − | + | !scope="row" | URL | |
| − | + | | https://[API endpoint]/services.[format] | |
| + | |- | ||
| + | !scope="row" | Sample URL | ||
| + | | <nowiki>https://api.city.gov/dev/v2/services.xml?jurisdiction_id=city.gov</nowiki> | ||
| + | |- | ||
| + | !scope="row" | Formats | ||
| + | | XML (JSON available if denoted by [[Service Discovery]]) | ||
| + | |- | ||
| + | !scope="row" | HTTP Method | ||
| + | | GET | ||
| + | |- | ||
| + | !scope="row" | Requires API Key | ||
| + | | No | ||
| + | |} | ||
| + | |||
====Required Arguments==== | ====Required Arguments==== | ||
| − | + | {| | |
| + | ! Field Name | ||
| + | ! Description | ||
| + | ! Notes | ||
| + | |- | ||
| + | | jurisdiction_id | ||
| + | | | ||
| + | | <span style="color: red">only required if the endpoint serves multiple jurisdictions</span> | ||
| + | |} | ||
====Response==== | ====Response==== | ||
| − | + | {| | |
| − | + | ! Field Name | |
| − | + | ! Description | |
| − | + | ! Notes | |
| − | + | |- | |
| − | + | !colspan="3"|services ↴ | |
| − | + | |- | |
| − | + | !colspan="3"|service ↴ | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; service_code | |
| − | + | | The unique identifier for the service request type | |
| − | + | | | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; service_name | |
| − | * | + | | The human readable name of the service request type |
| − | + | | | |
| − | * | + | |- |
| − | + | | class="field" | | |
| − | + | ; description | |
| − | + | | A brief description of the service request type. | |
| − | * | + | | |
| − | * | + | |- |
| − | * | + | | class="field" | |
| − | + | ; metadata | |
| − | + | | Determines whether their are additional form fields for this service type. | |
| − | + | * <span class="strict-value">true</span>: This service request type requires additional metadata so the client will need to make a call to the [[#GET Service Definition|Service Definition]] method. | |
| − | + | * <span class="strict-value">false</span>: No additional information is required and a call to the [[#GET Service Definition|Service Definition]] method is not needed. | |
| − | + | | Must be one of: true, false. | |
| − | + | |- | |
| − | + | | class="field" | | |
| + | ; type | ||
| + | | * <span class="strict-value">realtime</span>: The service request ID will be returned immediately after the service request is submitted. | ||
| + | * <span class="strict-value">batch</span>: A token will be returned immediately after the service request is submitted. This token can then be later used to return the service request ID. | ||
| + | * <span class="strict-value">blackbox</span>: No service request ID will be returned after the service request is submitted | ||
| + | | Must be one of: realtime, batch, blackbox. | ||
| + | |- | ||
| + | | class="field" | | ||
| + | ; keywords | ||
| + | | A comma separated list of tags or keywords to help users identify the request type. This can provide synonyms of the service_name and group. | ||
| + | | | ||
| + | |- | ||
| + | | class="field" | | ||
| + | ; group | ||
| + | | A category to group this service type within. This provides a way to group several service request types under one category such as "sanitation" | ||
| + | | | ||
| + | |} | ||
====Possible Errors==== | ====Possible Errors==== | ||
| Line 191: | Line 229: | ||
===GET Service Definition=== | ===GET Service Definition=== | ||
| − | + | {| class="method-table" | |
| − | + | !scope="row" | Conditional | |
| − | + | | Yes - <span style="font-weight : bold; color: red">This call is only necessary if the Service selected has metadata set as ''true'' from the ''GET Services'' response</span> | |
| − | + | |- | |
| − | + | !scope="row" | Purpose | |
| − | + | | Define attributes associated with a service code. These attributes can be unique to the city/jurisdiction. | |
| − | + | |- | |
| + | !scope="row" | URL | ||
| + | | https://[API endpoint]/services/[service_code].[format] | ||
| + | |- | ||
| + | !scope="row" | Sample URL | ||
| + | | <nowiki>https://api.city.gov/dev/v2/services/033.xml?jurisdiction_id=city.gov</nowiki> | ||
| + | |- | ||
| + | !scope="row" | Formats | ||
| + | | XML (JSON available if denoted by [[Service Discovery]]) | ||
| + | |- | ||
| + | !scope="row" | HTTP Method | ||
| + | | GET | ||
| + | |- | ||
| + | !scope="row" | Requires API Key | ||
| + | | No | ||
| + | |} | ||
| + | |||
====Required Arguments==== | ====Required Arguments==== | ||
| − | + | {| | |
| − | + | ! Field Name | |
| + | ! Description | ||
| + | ! Notes | ||
| + | |- | ||
| + | | jurisdiction_id | ||
| + | | | ||
| + | | <span style="color: red">only required if the endpoint serves multiple jurisdictions</span> | ||
| + | |- | ||
| + | | service_code | ||
| + | | | ||
| + | | The service_code is specified in the main URL path rather than an added query string parameter. | ||
| + | |} | ||
| + | |||
| + | |||
====Response==== | ====Response==== | ||
| − | + | ||
| − | + | {| | |
| − | + | ! Field Name | |
| − | + | ! Description | |
| − | + | ! Notes | |
| − | + | |- | |
| − | + | !colspan="3"|service_definition ↴ | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; service_code | |
| − | + | | Returns the service_code associated with the definition, the same one submitted for this call. | |
| − | + | | | |
| − | * | + | |- |
| − | + | !colspan="3"|attributes ↴ | |
| − | + | |- | |
| − | + | !colspan="3"|attribute ↴ | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; variable | |
| − | + | | * <span class="strict-values">true</span> denotes that user input is needed | |
| − | * | + | * <span class="strict-values">false</span> means the attribute is only used to present information to the user within the description field |
| − | + | | Must be one of: true, false. | |
| − | * | + | |- |
| − | * | + | | class="field" | |
| − | * | + | ; code |
| − | * | + | | A unique identifier for the attribute |
| − | * | + | | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; datatype | |
| − | + | | Denotes the type of field used for user input. | |
| − | * | + | * <span class="strict-values">string</span>: A string of characters without line breaks. Represented in an HTML from using an <input> tag |
| − | * | + | * <span class="strict-values">number</span>: A numeric value. Represented in an HTML from using an <input> tag |
| − | + | * <span class="strict-values">datetime</span>: The input generated must be able to transform into a valid ISO 8601 date. Represented in an HTML from using <input> tags | |
| − | + | * <span class="strict-values">text</span>: A string of characters that may contain line breaks. Represented in an HTML from using an <textarea> tag | |
| − | + | * <span class="strict-values">singlevaluelist</span>: A set of predefined values (specified in this response) where only one value may be selected. Represented in an HTML from using the <select> and <option> tags | |
| − | + | * <span class="strict-values">multivaluelist</span>: A set of predefined values (specified in this response) where several values may be selected. Represented in an HTML from using the <select multiple="multiple"> and <option> tags | |
| − | + | | Must be one of: string, number, datetime, text, singlevaluelist, multivaluelist. | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; required | |
| − | + | | * <span class="strict-value">true</span> means that the value is required to submit service request | |
| − | + | * <span class="strict-value">false</span> means that the value not required. | |
| − | + | | Must be one of: true, false. | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; datatype_description | |
| − | + | | A description of the datatype which helps the user provide their input | |
| − | + | | | |
| − | + | |- | |
| − | + | | class="field" | | |
| − | + | ; order | |
| − | + | | The sort order that the attributes will be presented to the user. 1 is shown first in the list. | |
| − | + | | Any positive integer not used for other attributes in the same service_code | |
| + | |- | ||
| + | | class="field" | | ||
| + | ; description | ||
| + | | An description of the attribute field with instructions for the user to find and identify the requested information | ||
| + | | | ||
| + | |- | ||
| + | !colspan="3"| values ↴ | ||
| + | |- | ||
| + | !colspan="3"| value ↴ | ||
| + | |- | ||
| + | | class="field" | | ||
| + | ; key | ||
| + | | The unique identifier associated with an option for singlevaluelist or multivaluelist. This is analogous to the value attribute in an html option tag. | ||
| + | | | ||
| + | |- | ||
| + | | class="field" | | ||
| + | ; name | ||
| + | | The human readable title of an option for singlevaluelist or multivaluelist. This is analogous to the innerhtml text node of an html option tag. | ||
| + | | | ||
| + | |} | ||
This spec has been frozen and finalized, but the documentation will continue to be updated for clarity. Join the Mailing List for updates.
The GeoReport API allows developers to build applications to report non-emergency issues such as graffiti, potholes, and street cleaning directly to government organizations like cities.
Stable: The GeoReport v2 Spec has been finalized, but we are still updating documentation for clarity and verifying compliance of implementations
Servers receive and manage service requests on behalf of a jurisdiction. A comprehensive list is being maintained on the GeoReport v2 Servers page
GeoReport v2 and subsequent Open311 APIs are also required to have a standard service discovery file associated with them to provide routing between versions and types of APIs. See the Service Discovery page for details of the specification.
All date/time fields must be formatted in a common subset of ISO 8601 as per the w3 note. Timezone information (either Z meaning UTC, or an HH:MM offset from UTC) must be included.
Examples:
UTF-8 is required everywhere.
All text returned by the service, whether in XML, JSON, or any other text-based content-type, MUST be encoded as UTF-8. Appropriate HTTP headers must be set, and the root element must be preceded with the XML declaration including the encoding="UTF-8" attribute. All text received by the service from the client will be assumed to be UTF-8 and must be decoded accordingly. Examples of the HTTP content-type headers for each format are shown below under Format Support.
XML is a required format, but JSON can be provided at the discretion of the API provider. The output formats supported by the provider are indicated through the Service Discovery formats field for the API endpoint being used. The client can specify the desired format by appending the format name to the resource. For example a GET request to /services.xml for text/xml output from the services resource and /services/01.json for application/json (RFC 4627) output for a specific service definition.
The HTTP content-type headers should look like this for each format:
POST Service Request: Content-Type: application/x-www-form-urlencoded; charset=utf-8
XML: Content-Type: text/xml; charset=utf-8
JSON: Content-Type: application/json; charset=utf-8
XML for the API should be Content-Type: text/xml. The XML output currently defined is schemaless and without a namespace declaration. For now, extending the output with additional namespaces should be done at your own risk. To guarantee that all clients can support the XML output, it is recommended that you adhere to the specification strictly and do not include foreign tags or namespaces. It is also assumed that the default namespace is not specified, but if it must be specified, the XMLNS URI is the URL of the specification: http://wiki.open311.org/GeoReport_v2
JSON for the API should be Content-Type: application/json. JSON support is based on a programmatic mapping of the XML format using the Spark Convention. This means that if you have an XML file, you can easily generate the JSON version with XSL. This can be done using a server side XSLT (php example).
As a means to allow this API to distinguish multiple jurisdictions within one API endpoint we've included a "jurisdiction_id" which will be the unique identifier for cities. It has been suggested that we use the jurisdiction's main website root url (without the www) as the "jurisdiction_id". For San Francisco, the jurisdiction_id is sfgov.org. Implementations can ignore this parameter and treat it as an "Optional Argument" if the implementation only serves one jurisdiction.
"Optional" means that the response should be the same whether a parameter is passed and is empty or is not passed at all. A null parameter should be treated as equivalent to a non-declared parameter in processing the request.
| Purpose | provide a list of acceptable 311 service request types and their associated service codes. These request types can be unique to the city/jurisdiction. |
|---|---|
| URL | https://[API endpoint]/services.[format] |
| Sample URL | https://api.city.gov/dev/v2/services.xml?jurisdiction_id=city.gov |
| Formats | XML (JSON available if denoted by Service Discovery) |
| HTTP Method | GET |
| Requires API Key | No |
| Field Name | Description | Notes |
|---|---|---|
| jurisdiction_id | only required if the endpoint serves multiple jurisdictions |
| Field Name | Description | Notes |
|---|---|---|
| services ↴ | ||
| service ↴ | ||
|
The unique identifier for the service request type | |
|
The human readable name of the service request type | |
|
A brief description of the service request type. | |
|
Determines whether their are additional form fields for this service type.
|
Must be one of: true, false. |
|
* realtime: The service request ID will be returned immediately after the service request is submitted.
|
Must be one of: realtime, batch, blackbox. |
|
A comma separated list of tags or keywords to help users identify the request type. This can provide synonyms of the service_name and group. | |
|
A category to group this service type within. This provides a way to group several service request types under one category such as "sanitation" | |
The numbers represent the HTTP status code returned for each error type:
| Conditional | Yes - This call is only necessary if the Service selected has metadata set as true from the GET Services response |
|---|---|
| Purpose | Define attributes associated with a service code. These attributes can be unique to the city/jurisdiction. |
| URL | https://[API endpoint]/services/[service_code].[format] |
| Sample URL | https://api.city.gov/dev/v2/services/033.xml?jurisdiction_id=city.gov |
| Formats | XML (JSON available if denoted by Service Discovery) |
| HTTP Method | GET |
| Requires API Key | No |
| Field Name | Description | Notes |
|---|---|---|
| jurisdiction_id | only required if the endpoint serves multiple jurisdictions | |
| service_code | The service_code is specified in the main URL path rather than an added query string parameter. |
| Field Name | Description | Notes |
|---|---|---|
| service_definition ↴ | ||
|
Returns the service_code associated with the definition, the same one submitted for this call. | |
| attributes ↴ | ||
| attribute ↴ | ||
|
* true denotes that user input is needed
|
Must be one of: true, false. |
|
A unique identifier for the attribute | |
|
Denotes the type of field used for user input.
|
Must be one of: string, number, datetime, text, singlevaluelist, multivaluelist. |
|
* true means that the value is required to submit service request
|
Must be one of: true, false. |
|
A description of the datatype which helps the user provide their input | |
|
The sort order that the attributes will be presented to the user. 1 is shown first in the list. | Any positive integer not used for other attributes in the same service_code |
|
An description of the attribute field with instructions for the user to find and identify the requested information | |
| values ↴ | ||
| value ↴ | ||
|
The unique identifier associated with an option for singlevaluelist or multivaluelist. This is analogous to the value attribute in an html option tag. | |
|
The human readable title of an option for singlevaluelist or multivaluelist. This is analogous to the innerhtml text node of an html option tag. | |
The numbers represent the HTTP status code returned for each error type:
The numbers represent the HTTP status code returned for each error type:
POST /dev/v2/requests.xml Host: api.city.gov Content-Type: application/x-www-form-urlencoded; charset=utf-8 api_key=xyz&jurisdiction_id=city.gov&service_code=001&lat=37.76524078&long=-122.4212043&address_string=1234+5th+street&email=smit333%40sfgov.edu&device_id=tt222111&account_id=123456&first_name=john&last_name=smith&phone=111111111&description=A+large+sinkhole+is+destroying+the+street&media_url=http%3A%2F%2Ffarm3.static.flickr.com%2F2002%2F2212426634_5ed477a060.jpg&attribute[WHISPAWN]=123456&attribute[WHISDORN]=COISL001
Example response:
The numbers represent the HTTP status code returned for each error type:
The numbers represent the HTTP status code returned for each error type:
The numbers represent the HTTP status code returned for each error type:
HTTP error codes are required, but the code in the response body shouldn't necessarily match the HTTP error code, so that more specific and unique error code identifiers can be used. The HTTP error codes should always be 404 for resources that don't exist, 403 for errors because of wrong or missing api_key and basically 400 for any other error where the request can not be fulfilled as expected. Multiple errors codes and descriptions can be returned in the body (the response is an array).
Example: