xref: /aosp_15_r20/external/googleapis/google/maps/addressvalidation/v1/address_validation_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.maps.addressvalidation.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/maps/addressvalidation/v1/address.proto";
23import "google/maps/addressvalidation/v1/geocode.proto";
24import "google/maps/addressvalidation/v1/metadata.proto";
25import "google/maps/addressvalidation/v1/usps_data.proto";
26import "google/type/postal_address.proto";
27
28option cc_enable_arenas = true;
29option csharp_namespace = "Google.Maps.AddressValidation.V1";
30option go_package = "cloud.google.com/go/maps/addressvalidation/apiv1/addressvalidationpb;addressvalidationpb";
31option java_multiple_files = true;
32option java_outer_classname = "AddressValidationServiceProto";
33option java_package = "com.google.maps.addressvalidation.v1";
34option objc_class_prefix = "GMPAVV1";
35option php_namespace = "Google\\Maps\\AddressValidation\\V1";
36option ruby_package = "Google::Maps::AddressValidation::V1";
37
38// The service for validating addresses.
39service AddressValidation {
40  option (google.api.default_host) = "addressvalidation.googleapis.com";
41
42  // Validates an address.
43  rpc ValidateAddress(ValidateAddressRequest)
44      returns (ValidateAddressResponse) {
45    option (google.api.http) = {
46      post: "/v1:validateAddress"
47      body: "*"
48    };
49  }
50
51  // Feedback about the outcome of the sequence of validation attempts. This
52  // should be the last call made after a sequence of validation calls for the
53  // same address, and should be called once the transaction is concluded. This
54  // should only be sent once for the sequence of `ValidateAddress` requests
55  // needed to validate an address fully.
56  rpc ProvideValidationFeedback(ProvideValidationFeedbackRequest)
57      returns (ProvideValidationFeedbackResponse) {
58    option (google.api.http) = {
59      post: "/v1:provideValidationFeedback"
60      body: "*"
61    };
62  }
63}
64
65// The request for validating an address.
66message ValidateAddressRequest {
67  // Required. The address being validated. Unformatted addresses should be
68  // submitted via [`address_lines`][google.type.PostalAddress.address_lines].
69  //
70  // The total length of the fields in this input must not exceed 280
71  // characters.
72  //
73  // Supported regions can be found
74  // [here](https://developers.google.com/maps/documentation/address-validation/coverage).
75  //
76  // The [language_code][google.type.PostalAddress.language_code] value in the
77  // input address is reserved for future uses and is ignored today. The
78  // validated address result will be populated based on the preferred language
79  // for the given address, as identified by the system.
80  //
81  // The Address Validation API ignores the values in
82  // [recipients][google.type.PostalAddress.recipients] and
83  // [organization][google.type.PostalAddress.organization]. Any values in those
84  // fields will be discarded and not returned. Please do not set them.
85  google.type.PostalAddress address = 1
86      [(google.api.field_behavior) = REQUIRED];
87
88  // This field must be empty for the first address validation request. If
89  // more requests are necessary to fully validate a single address (for
90  // example if the changes the user makes after the initial validation need to
91  // be re-validated), then each followup request must populate this field with
92  // the
93  // [response_id][google.maps.addressvalidation.v1.ValidateAddressResponse.response_id]
94  // from the very first response in the validation sequence.
95  string previous_response_id = 2;
96
97  // Enables USPS CASS compatible mode. This affects _only_ the
98  // [google.maps.addressvalidation.v1.ValidationResult.usps_data] field of
99  // [google.maps.addressvalidation.v1.ValidationResult]. Note: for USPS CASS
100  // enabled requests for addresses in Puerto Rico, a
101  // [google.type.PostalAddress.region_code] of the `address` must be provided
102  // as "PR", or an [google.type.PostalAddress.administrative_area] of the
103  // `address` must be provided as "Puerto Rico" (case-insensitive) or "PR".
104  //
105  // It's recommended to use a componentized `address`, or alternatively specify
106  // at least two [google.type.PostalAddress.address_lines] where the first line
107  // contains the street number and name and the second line contains the city,
108  // state, and zip code.
109  bool enable_usps_cass = 3;
110
111  // Optional. A string which identifies an Autocomplete session for billing
112  // purposes. Must be a URL and filename safe base64 string with at most 36
113  // ASCII characters in length. Otherwise an INVALID_ARGUMENT error is
114  // returned.
115  //
116  // The session begins when the user starts typing a query, and concludes when
117  // they select a place and a call to Place Details or Address Validation is
118  // made. Each session can have multiple autocomplete queries, followed by one
119  // Place Details or Address Validation request. The credentials used for each
120  // request within a session must belong to the same Google Cloud Console
121  // project. Once a session has concluded, the token is no longer valid; your
122  // app must generate a fresh token for each session. If the `session_token`
123  // parameter is omitted, or if you reuse a session token, the session is
124  // charged as if no session token was provided (each request is billed
125  // separately).
126  //
127  // Note: Address Validation can only be used in sessions with the
128  // Autocomplete (New) API, not the old Autocomplete API. See
129  // https://developers.google.com/maps/documentation/places/web-service/session-pricing
130  // for more details.
131  string session_token = 5 [(google.api.field_behavior) = OPTIONAL];
132}
133
134// The response to an address validation request.
135message ValidateAddressResponse {
136  // The result of the address validation.
137  ValidationResult result = 1;
138
139  // The UUID that identifies this response. If the address needs to be
140  // re-validated, this UUID *must* accompany the new request.
141  string response_id = 2;
142}
143
144// The request for sending validation feedback.
145message ProvideValidationFeedbackRequest {
146  // The possible final outcomes of the sequence of address validation requests
147  // needed to validate an address.
148  enum ValidationConclusion {
149    // This value is unused.
150    // If the `ProvideValidationFeedbackRequest.conclusion` field is set to
151    // `VALIDATION_CONCLUSION_UNSPECIFIED`, an `INVALID_ARGUMENT` error will be
152    // returned.
153    VALIDATION_CONCLUSION_UNSPECIFIED = 0;
154
155    // The version of the address returned by the Address Validation API was
156    // used for the transaction.
157    VALIDATED_VERSION_USED = 1;
158
159    // The version of the address provided by the user was used for the
160    // transaction
161    USER_VERSION_USED = 2;
162
163    // A version of the address that was entered after the last validation
164    // attempt but that was not re-validated was used for the transaction.
165    UNVALIDATED_VERSION_USED = 3;
166
167    // The transaction was abandoned and the address was not used.
168    UNUSED = 4;
169  }
170
171  // Required. The outcome of the sequence of validation attempts.
172  //
173  // If this field is set to `VALIDATION_CONCLUSION_UNSPECIFIED`, an
174  // `INVALID_ARGUMENT` error will be returned.
175  ValidationConclusion conclusion = 1 [(google.api.field_behavior) = REQUIRED];
176
177  // Required. The ID of the response that this feedback is for. This should be
178  // the
179  // [response_id][google.maps.addressvalidation.v1.ValidateAddressRequest.response_id]
180  // from the first response in a series of address validation attempts.
181  string response_id = 2 [(google.api.field_behavior) = REQUIRED];
182}
183
184// The response for validation feedback.
185//
186// The response is empty if the feedback is sent successfully.
187message ProvideValidationFeedbackResponse {}
188
189// The result of validating an address.
190message ValidationResult {
191  // Overall verdict flags
192  Verdict verdict = 1;
193
194  // Information about the address itself as opposed to the geocode.
195  Address address = 2;
196
197  // Information about the location and place that the address geocoded to.
198  Geocode geocode = 3;
199
200  // Other information relevant to deliverability. `metadata` is not guaranteed
201  // to be fully populated for every address sent to the Address Validation API.
202  AddressMetadata metadata = 4;
203
204  // Extra deliverability flags provided by USPS. Only provided in region `US`
205  // and `PR`.
206  UspsData usps_data = 5;
207}
208
209// High level overview of the address validation result and geocode.
210message Verdict {
211  // The various granularities that an address or a geocode can have.
212  // When used to indicate granularity for an *address*, these values indicate
213  // with how fine a granularity the address identifies a mailing destination.
214  // For example, an address such as "123 Main Street, Redwood City, CA, 94061"
215  // identifies a `PREMISE` while something like "Redwood City, CA, 94061"
216  // identifies a `LOCALITY`. However, if we are unable to find a geocode for
217  // "123 Main Street" in Redwood City, the geocode returned might be of
218  // `LOCALITY` granularity even though the address is more granular.
219  enum Granularity {
220    // Default value. This value is unused.
221    GRANULARITY_UNSPECIFIED = 0;
222
223    // Below-building level result, such as an apartment.
224    SUB_PREMISE = 1;
225
226    // Building-level result.
227    PREMISE = 2;
228
229    // A geocode that approximates the building-level location of the address.
230    PREMISE_PROXIMITY = 3;
231
232    // The address or geocode indicates a block. Only used in regions which
233    // have block-level addressing, such as Japan.
234    BLOCK = 4;
235
236    // The geocode or address is granular to route, such as a street, road, or
237    // highway.
238    ROUTE = 5;
239
240    // All other granularities, which are bucketed together since they are not
241    // deliverable.
242    OTHER = 6;
243  }
244
245  // The granularity of the **input** address. This is the result of parsing the
246  // input address and does not give any validation signals. For validation
247  // signals, refer to `validation_granularity` below.
248  //
249  // For example, if the input address includes a specific apartment number,
250  // then the `input_granularity` here will be `SUB_PREMISE`. If we cannot match
251  // the apartment number in the databases or the apartment number is invalid,
252  // the `validation_granularity` will likely be `PREMISE` or below.
253  Granularity input_granularity = 1;
254
255  // The granularity level that the API can fully **validate** the address to.
256  // For example, an `validation_granularity` of `PREMISE` indicates all address
257  // components at the level of `PREMISE` or more coarse can be validated.
258  //
259  // Per address component validation result can be found in
260  // [google.maps.addressvalidation.v1.Address.address_components].
261  Granularity validation_granularity = 2;
262
263  // Information about the granularity of the
264  // [`geocode`][google.maps.addressvalidation.v1.ValidationResult.geocode].
265  // This can be understood as the semantic meaning of how coarse or fine the
266  // geocoded location is.
267  //
268  // This can differ from the `validation_granularity` above occasionally. For
269  // example, our database might record the existence of an apartment number but
270  // do not have a precise location for the apartment within a big apartment
271  // complex. In that case, the `validation_granularity` will be `SUB_PREMISE`
272  // but the `geocode_granularity` will be `PREMISE`.
273  Granularity geocode_granularity = 3;
274
275  // The address is considered complete if there are no unresolved tokens, no
276  // unexpected or missing address components. See
277  // [`missing_component_types`][google.maps.addressvalidation.v1.Address.missing_component_types],
278  // [`unresolved_tokens`][google.maps.addressvalidation.v1.Address.unresolved_tokens]
279  // or
280  // [`unexpected`][google.maps.addressvalidation.v1.AddressComponent.unexpected]
281  // fields for more details.
282  bool address_complete = 4;
283
284  // At least one address component cannot be categorized or validated, see
285  // [google.maps.addressvalidation.v1.Address.address_components] for
286  // details.
287  bool has_unconfirmed_components = 5;
288
289  // At least one address component was inferred (added) that wasn't in the
290  // input, see
291  // [google.maps.addressvalidation.v1.Address.address_components] for
292  // details.
293  bool has_inferred_components = 6;
294
295  // At least one address component was replaced, see
296  // [google.maps.addressvalidation.v1.Address.address_components] for
297  // details.
298  bool has_replaced_components = 7;
299}
300