# How to migrate from Tenor's V1 API

For existing integrations that use Tenor's V1 API, follow the steps on this page to
migrate to V2.

## Get a V2 API key

Follow the instructions in the [setup
step](https://developers.google.com/tenor/guides/quickstart#setup) of the quickstart guide to get a V2 API key to replace your V1 version.

## Update to V2 domains

Update your API domain to `https://tenor.googleapis.com/v2/`. Tenor's V2 API only
supports HTTPS connections. For content, be sure your application supports content downloads from
`https://media.tenor.com` and `https://c.tenor.com`.

For example, suppose you made an API call to one of the following V1 domains:

- `https://api.tenor.com/v1/search?<parameters>`
- `https://g.tenor.com/v1/search?<parameters>`

To update the calls to V2, change them to
`https://tenor.googleapis.com/v2/search?<parameters>`.

## Endpoint changes

The majority of API endpoint parameters are unchanged from what's documented in V1. There are a
few notable exceptions:

1. Tenor's [Search endpoint](https://developers.google.com/tenor/guides/endpoints#search) now supports sticker search through the [`searchfilter`](https://developers.google.com/tenor/guides/endpoints#searchfilter-search) parameter.
2. Include the `client_key` and `country` parameters on API calls.
3. The `media_filter` parameter now takes a comma-separated list of the desired formats rather than preset enums.
4. The [Categories endpoint](https://developers.google.com/tenor/guides/endpoints#categories) now supports `featured` and `trending` for the `type` parameter.
5. The API no longer supports the `anon_id` parameter.
6. When there are no more pages of results to request, the `next` field of API responses is now a blank string rather than `"0"`.

The following changes have been made to the endpoints available:

1. The Trending endpoint is no longer supported. Instead, we recommend you use the [Featured endpoint](https://developers.google.com/tenor/guides/endpoints#featured).
2. The GIF endpoint has been rebranded as the [Posts endpoint](https://developers.google.com/tenor/guides/endpoints#posts).
3. The Random GIF endpoint has been incorporated into the [Search endpoint](https://developers.google.com/tenor/guides/endpoints#search) through the [`random`](https://developers.google.com/tenor/guides/endpoints#random-search) parameter.

## Response object and error changes

- The GIF Object has been rebranded to the [Response
  Object](https://developers.google.com/tenor/guides/response-objects-and-errors#response-object).
- In the [Response
  Object](https://developers.google.com/tenor/guides/response-objects-and-errors#response-object), the `media` field has been rebranded as `media_formats`. The value for `media_formats` is now a map [`{ CONTENT_FORMAT : MEDIA_OBJECT }`](https://developers.google.com/tenor/guides/response-objects-and-errors#media-object) rather than an array of maps.
- The content thumbnail previews have been moved from the [Media Object](https://developers.google.com/tenor/guides/response-objects-and-errors#media-object) for each [content
  format](https://developers.google.com/tenor/guides/response-objects-and-errors#content-formats) to its own format. They're offered under the `media_formats` field in the [Response
  Object](https://developers.google.com/tenor/guides/response-objects-and-errors#response-object).
- When there are no more results in a response object, the `next` field is an empty string, `""`, rather than `"0"`.
- Tenor API error codes have been migrated to Google's standard API [error codes](https://cloud.google.com/apis/design/errors).