---
updatedAt: 2025-05-29T21:41:18.000Z
agentTools:
  projectIndex: https://developers.apptweak.com/llms.txt
---

# Trending Keywords per Region

```python Python
import requests
import pandas as pd

# RECIPE trending keywords per region
# The goal of this recipe is to provide trending keywords per region
# The generated CSV can easily be used to create charts

API_KEY = {"x-apptweak-key": "API-KEY"}

def get_url(url, at_key):

    response = requests.get(url, headers=at_key)
    resp_dict = response.json()
    return resp_dict["result"]

# query parameters definition
START_DATE="2021-03-01"
END_DATE="2021-05-31"
LIMIT=100
DEVICE="iphone"
OFFSET=0

# regions - create the regions you're interested in
LATAM_LIST = ["pe","ar","uy","cl","co","ec","ve"]
ASIAN_LIST = ["th","mm","sg","vn","ph","id","my"]
EUROPE_LIST = ["be","it","fr","gb","de","nl","es"]
# select here the region you'd like to get trending keywords from 
region=ASIAN_LIST

# creating the dataframe that will contain the trending keywords for the selected region
df_all_country = pd.DataFrame(columns = ["keyword","country","occurrences"])

for country in region:
    url = f'https://public-api.apptweak.com/api/public/store/keywords/suggestions/trending.json?country={country}&device={DEVICE}&limit={LIMIT}&offset={OFFSET}&start_date={START_DATE}&end_date={END_DATE}'
    trending_kw_dict = get_url(url,API_KEY)
    df_per_country = pd.DataFrame(columns = ["keyword","country","occurrences"]) # need to do it because otherwise we're just populating an existing dataframe and it could cause errors 

    for _, kw_suggestion_array in trending_kw_dict.items():
        keywords = list(map(lambda x: x["keyword"], kw_suggestion_array))
        occurences = list(map(lambda x: x["occurrences"], kw_suggestion_array))
        df_per_country["keyword"] = keywords
        df_per_country["occurrences"] = occurences
    df_per_country["country"] = country
    df_all_country = df_all_country.append(df_per_country)   

df_all_country.reset_index(drop=True,inplace=True) # resetting the index 
df_all_country.index.name = 'index' # needs to be named to be imported in google data studio
df_all_country.to_csv(f'trending_keyword_suggestions_region.csv')
```

```json Response Example
{"success":true}
```

# Copy this recipe



Copy this code sample by clicking on the clipboard icon on the right and paste it in your code editor (Sublime Text, VS Code, etc.).

# Insert your API token

<!-- python@8 -->

Replace "API-KEY" with your personal API token.

# Set the daterange and limit

<!-- python@17-21 -->

Set the start_date and end_date to select the date range you're interested by. Set the limit of the number of trending keywords per country that you want to fetch. Bear in mind that they are sorted by highest occurence first. Leave the device and offset parameter as they are.

# Create your regions

<!-- python@24-28 -->

Create regions you'd like to consider by making a list containing the country-codes of the countries of that region. Choose the region by assigning it to the variable "region".

# Run the code



You can now file the file and run the code. A csv file will be created in the current repository of your code editor.