# Resource Metadata

You can use [`SearchAds360FieldService`](https://developers.google.com/search-ads/reporting/api/reference/rpc/google.ads.searchads360.v0.services#google.ads.searchads360.v0.services.SearchAds360FieldService)
to dynamically request the catalog for resources, resource's fields,
segmentation keys and metrics available in the [`SearchAds360Service`](https://developers.google.com/search-ads/reporting/api/reference/rpc/google.ads.searchads360.v0.services#searchads360service)
`Search` and `SearchStream` methods. The catalog provides metadata that can be
used by Search Ads 360 Reporting API clients for validation and construction of Search Ads 360
Query Language statements.

## Sample HTTP request and response

> [!NOTE]
> **Note:** The example shows the underlying HTTP/JSON request as a guide, but you are strongly encouraged to use one of the [client libraries](https://developers.google.com/search-ads/reporting/client-libraries/client-libraries) based on [gRPC](https://grpc.io) to submit your requests.

The request consists of an `HTTP GET` to the Search Ads 360 Reporting API server at the
following URL:

    https://searchads360.googleapis.com/v0/searchAds360Fields/{resource_or_field}

The following is an example of a request followed by the response returned from
`SearchAds360FieldService` for **ad_group** resource:

### Request

    https://searchads360.googleapis.com/v0/searchAds360Fields/ad_group

### Response

    {
      "resourceName": "searchAds360Fields/ad_group",
      "name": "ad_group",
      "category": "RESOURCE",
      "selectable": false,
      "filterable": false,
      "sortable": false,
      "selectableWith": [
        "campaign",
        "customer",
        "metrics.average_cpc",
        "segments.device",
        ...
      ],
      "attributeResources": [
        "customer",
        "campaign"
      ],

      "metrics": [
        "metrics.conversions",
        "metrics.search_budget_lost_impression_share",
        "metrics.average_cost",
        "metrics.clicks",
        ...
      ],
      "segments": [
        "segments.date",
        "segments.ad_network_type",
        "segments.device",
        ...
      ]
    }

For this example, the important arrays are:

`attributeResources`
:   Resources that can be implicitly joined to the resource in the `FROM`
    clause.

`metrics`
:   Metrics that are available to be selected with the resource in the `FROM`
    clause. Only populated for fields where the `category` is `RESOURCE`.

`segments`
:   Segment keys that can be selected with the resource in the `FROM` clause.
    These segment the metrics specified in the query. Only populated for fields
    where the `category` is `RESOURCE`.

`selectableWith`
:   Fields that can be selected alongside a given field, when not in the `FROM`
    clause. This attribute is only relevant when identifying resources or segments
    that are able to be selected in a query where they are not included by the
    resource in the `FROM` clause. As an example, if you are selecting `ad_group.id`
    and `segments.date` from `ad_group`, and you want to include attributes from
    `campaign`, you would need to check that `segments.date` is in the
    `selectableWith` attribute for campaign, since it's being selected alongside the
    existing `segments.date` field.

## Metadata details

You can request the catalog using the `SearchAds360FieldService` at these
levels:

Resource
:   For example, `searchAds360Fields/campaign`.

Resource's field
:   For example, `searchAds360Fields/campaign.name`.

Segmentation field
:   For example, `searchAds360Fields/segments.ad_network_type`.

Metric
:   For example, `searchAds360Fields/metrics.clicks`.

## Use a query to get field details

It is possible to get field details by sending a query to

    https://searchads360.googleapis.com/v0/searchAds360Fields:search

Example 1: Using a regular expression.

    SELECT
      name,
      category,
      selectable,
      filterable,
      sortable,
      selectable_with,
      data_type,
      is_repeated
    WHERE name LIKE 'ad_group.%'"

Example 2: Querying specific fields, metrics or segments.

    SELECT
      name,
      category,
      selectable,
      filterable,
      sortable,
      selectable_with,
      data_type,
      is_repeated
    WHERE
      name IN (
        "ad_group.id",
        "ad_group.name",
        "segments.date",
        "customer.id",
        "customer.manager",
        "metrics.clicks"
      )