Skip to main content
Open In ColabOpen on GitHub

Naver Search

Overview

Integration details

ClassPackageSerializableJS supportPackage latest
NaverSearchResultslangchain-naver-communityPyPI - Version

Tool features

Search : The Naver Search Tool provides a simple interface to search Naver and get results.

Setup

Setting Up API Credentials

To use Naver Search, you need to obtain API credentials. Follow these steps:

Sign in to the Naver Developers portal. Create a new application and enable the Search API. Obtain your NAVER_CLIENT_ID and NAVER_CLIENT_SECRET from the "Application List" section.

Setting Up Environment Variables

After obtaining the credentials, set them as environment variables in your script:

%pip install --upgrade --quiet  langchain-naver-community
import getpass
import os

if not os.environ.get("NAVER_CLIENT_ID"):
os.environ["NAVER_CLIENT_ID"] = getpass.getpass("Enter your Naver Client ID:\n")

if not os.environ.get("NAVER_CLIENT_SECRET"):
os.environ["NAVER_CLIENT_SECRET"] = getpass.getpass(
"Enter your Naver Client Secret:\n"
)

Instantiation

from langchain_naver_community.utils import NaverSearchAPIWrapper

search = NaverSearchAPIWrapper()

Invocation

search.results("Seoul")[:3]
[{'title': 'Seoul shares rise for 4th day on tech gains; won at 2-week low',
'link': 'https://n.news.naver.com/mnews/article/001/0015277717?sid=104',
'description': 'stocks-summary Seoul shares rise for 4th day on tech gains; won at 2-week low SEOUL, March 20 (Yonhap) -- Seoul shares extended their winning streak to a fourth day Thursday on the back of gains... ',
'pubDate': 'Thu, 20 Mar 2025 16:09:00 +0900'},
{'title': "Seoul Mayor Oh's residence, office raided over alleged ties to shadowy po...",
'link': 'https://n.news.naver.com/mnews/article/640/0000067073?sid=100',
'description': 'Prosecutors on Thursday raided Seoul Mayor Oh Se-hoon’s official residence and the City Hall... The raid came as part of the Seoul Central District Prosecutors’ Office’s probe into... ',
'pubDate': 'Thu, 20 Mar 2025 19:12:00 +0900'},
{'title': 'Education can heal divides: Seoul schools chief',
'link': 'https://n.news.naver.com/mnews/article/044/0000267866?sid=104',
'description': 'Jung Keun-sik, Superintendent of Seoul Metropolitan Office of Education speaks during an interview with The Korea Herald at his office on March 13. (Lim Se-jun/ The Korea Herald) Seoul education... ',
'pubDate': 'Thu, 20 Mar 2025 14:35:00 +0900'}]

Tool Usage

from langchain_naver_community.tool import NaverSearchResults
from langchain_naver_community.utils import NaverSearchAPIWrapper

search = NaverSearchAPIWrapper()

tool = NaverSearchResults(api_wrapper=search)

tool.invoke("what is the weather in seoul?")[3:5]
[{'title': "2025 is here. Here's what to watch out for",
'link': 'https://n.news.naver.com/mnews/article/044/0000265707?sid=104',
'description': 'The trend was predicted in "Trend Korea 2025," written by Kim Ran-do, a professor of consumer science at Seoul National University, and his team. The annually published book also predicts that... ',
'pubDate': 'Sat, 18 Jan 2025 16:01:00 +0900'},
{'title': '[INTERVIEW] Korea to overhaul weather prediction model against climate ch...',
'link': 'https://www.koreatimes.co.kr/www/nation/2023/06/371_353628.html?utm_source=na',
'description': 'western Seoul to protest its confusing weather predictions, false forecasting is hardly accepted compared to what Yoo saw in Oklahoma. The administrator hopes the Korean public would understand... ',
'pubDate': 'Sun, 25 Jun 2023 17:22:00 +0900'}]

Use within an agent

The Naver Search tool can be integrated into LangChain agents for more complex tasks. Below we demonstrate how to set up an agent that can search Naver for current information.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4o-mini")

system_prompt = """
You are a helpful assistant that can search the web for information.
"""
API Reference:ChatOpenAI
from langchain_naver_community.tool import NaverNewsSearch
from langgraph.prebuilt import create_react_agent

tools = [NaverNewsSearch()]

agent_executor = create_react_agent(
llm,
tools,
prompt=system_prompt,
)
API Reference:create_react_agent

Now we can run the agent with a query.

query = "What is the weather in Seoul?"
result = agent_executor.invoke({"messages": [("human", query)]})
result["messages"][-1].content

API reference


Was this page helpful?