Loading...
Loading...
Generate Python code for Naver Open APIs (News Search, Blog Search, Web Search, Datalab Trends, Image Search, Book Search, and other openapi.naver.com APIs). Use this skill whenever the user wants to call Naver APIs, search Naver News/Blog/Web/Images, fetch Datalab keyword trends, or write Python scripts that interact with Naver's Open API platform. This includes requests for code examples, API integration, parameter explanations, endpoint lookup, or troubleshooting Naver Open API calls. Even if the user just mentions 'Naver API', 'Naver news data', 'search trends', or 'openapi.naver.com', activate this skill immediately.
npx skill4agent add dwk601/naver-openapi-helper naver-openapi-helperrequestsdevelopers.naver.comhttps://openapi.naver.com/v1/search/news/v1/search/blog/v1/search/webkr/v1/search/image/v1/search/book/v1/datalab/searchapi.searchad.naver.comX-Naver-Client-IdX-Naver-Client-Secretimport os
CLIENT_ID = os.environ.get("NAVER_CLIENT_ID")
CLIENT_SECRET = os.environ.get("NAVER_CLIENT_SECRET")# WARNING: Hardcoding credentials is insecure. Use environment variables in production.errorCode: "024"| User mentions | API | Docs URL |
|---|---|---|
| "news", "article", "headline" | News Search | |
| "blog", "blog post" | Blog Search | |
| "web", "web document", "webkr" | Web Search | |
| "image", "picture", "photo" | Image Search | |
| "book", "책" | Book Search | |
| "datalab", "trend", "keyword trend", "search trend" | Datalab Search | |
| "shopping", "shop" | Shopping Search | |
| "encyc", "encyclopedia", "knowledge" | Encyclopedia | |
| "cafe", "cafegroup" | Cafe Search | |
npx @playwright/clinpx @playwright/cli open --browser=chromium <docs-url>
npx @playwright/cli snapshothttps://openapi.naver.com/v1/search/news.jsonnpx @playwright/cli eval "window.scrollTo(0, document.body.scrollHeight)"
npx @playwright/cli snapshotnpx @playwright/cli goto <specific-docs-url>
npx @playwright/cli snapshotrequestsimport os
import requests
import json
from urllib.parse import quote
def main():
# Load credentials from environment variables
client_id = os.environ.get("NAVER_CLIENT_ID")
client_secret = os.environ.get("NAVER_CLIENT_SECRET")
if not client_id or not client_secret:
raise ValueError("NAVER_CLIENT_ID and NAVER_CLIENT_SECRET must be set")
# API endpoint
url = "<endpoint-url>"
# Auth headers
headers = {
"X-Naver-Client-Id": client_id,
"X-Naver-Client-Secret": client_secret,
}
# For POST requests (Datalab), add Content-Type
# headers["Content-Type"] = "application/json"
# Parameters
params = {
"query": quote("<search-term>"),
"display": 10,
"start": 1,
"sort": "sim", # sim (accuracy) or date
}
# Make request
response = requests.get(url, headers=headers, params=params)
# For POST: response = requests.post(url, headers=headers, json=params)
# Handle response
if response.status_code == 200:
data = response.json()
print(json.dumps(data, ensure_ascii=False, indent=2))
elif response.status_code == 400:
print(f"Error 400 - Bad Request: {response.text}")
print("Check your parameters (query encoding, display/start/sort values).")
elif response.status_code == 401:
print(f"Error 401 - Unauthorized: {response.text}")
print("Check your Client ID and Secret. Ensure the API scope is enabled in Naver Developer Center.")
elif response.status_code == 403:
print(f"Error 403 - Forbidden: {response.text}")
print("Ensure the API is enabled for your application in the Naver Developer Center.")
elif response.status_code == 500:
print(f"Error 500 - Internal Server Error: {response.text}")
else:
print(f"Error {response.status_code}: {response.text}")
if __name__ == "__main__":
main()requestsurlliburllib.parse.quote(query, safe='')requestsparamsos.environContent-Type: application/jsonjson=body_dictparams=requestsensure_ascii=Falseindent=2argparseimport argparse
parser = argparse.ArgumentParser(description="Naver API Client")
parser.add_argument("query", help="Search query")
parser.add_argument("--display", type=int, default=10, help="Results per page (1-100)")
parser.add_argument("--sort", choices=["sim", "date"], default="sim", help="Sort order")
args = parser.parse_args()with open("output.json", "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)for item in data.get("items", []):
print(item["title"].replace("<b>", "").replace("</b>", ""))python3 -m py_compile generated_script.pyhttps://openapi.naver.comhttps://api.searchad.naver.comrequestsparamsurllib.parse.quoteGET /v1/search/news.json?query=AIitems<b>POST /v1/datalab/searchkeywordGroupstimeUnitargparseGET /v1/search/blog.json