जब आपको किसी एप्लिकेशन में समाचार खोजने की सुविधा जोड़नी हो, तो सबसे पहले उपयोगी परिणामों को अपने कोड में लाना होता है—बिना खुद सर्च पाइपलाइन बनाए। इस गाइड के अंत तक, आप News API को कॉल कर पाएँगे, Python में लौटाए गए समाचार फ़ील्ड पढ़ पाएँगे और MCP-संगत AI एजेंट से भी इसी इंटीग्रेशन का उपयोग कर पाएँगे।
News API क्या लौटाता है
News API एक Search News एंडपॉइंट प्रदान करता है, जो खोज शब्द लेता है और समाचार परिणाम लौटाता है। दिए गए रिस्पॉन्स में खोज पैरामीटर और news ऐरे शामिल होता है, जिसमें शीर्षक, लिंक, स्निपेट, तारीखें, स्रोत, इमेज URL और स्थान होते हैं।
इससे यह एंडपॉइंट समाचार-खोज इंटरफ़ेस, विषय-निगरानी डैशबोर्ड या प्रासंगिक कवरेज के लिंक चाहने वाले एजेंट के लिए उपयोगी बनता है। परिणामों के स्निपेट खोज-परिणाम का टेक्स्ट होते हैं, इसलिए एप्लिकेशन को पाठकों को स्रोत से जोड़ना चाहिए, न कि स्निपेट को पूरा लेख बताकर प्रस्तुत करना चाहिए।
Zyla API Hub पर शुरुआत करना
Zyla API Hub पर News API पेज खोलें, अगर आपका पहले से खाता नहीं है तो मुफ़्त खाता बनाएँ, और उपलब्ध होने पर Subscribe या Start Free Trial पर क्लिक करें। Hub से अपनी API key प्राप्त करें और उसे Bearer token के रूप में Authorization हेडर में इस्तेमाल करें।
Zyla प्रति-कॉल बिलिंग के बजाय कोटा वाली सदस्यताओं का उपयोग करता है। पहला API ट्रायल 7-दिन या 50-अनुरोध की सीमा के अधीन है; मौजूदा एक्सेस विकल्पों और कीमतों के लिए API पेज देखें। कुंजी को ब्राउज़र कोड में एम्बेड करने के बजाय अपने सर्वर या स्थानीय एनवायरनमेंट में रखें।
GET अनुरोध से समाचार खोजें
उपलब्ध एंडपॉइंट Search News है। यह q में दिए गए शब्द को खोजता है।
विधि: GET
अनुरोध URL: https://zylalabs.com/api/2088/news-api/8710/search-news
qएक आवश्यक स्ट्रिंग है, जिसमें खोज शब्द होता है। नीचे दिए गए अनुरोध मेंUSAका उपयोग किया गया है।glएक आवश्यक स्ट्रिंग है। नीचे दिए गए अनुरोध मेंusका उपयोग किया गया है।numएक वैकल्पिक स्ट्रिंग है। नीचे दिए गए अनुरोध में50का उपयोग किया गया है।
YOUR_API_KEY को अपनी Hub कुंजी से बदलें और यह अनुरोध चलाएँ:
curl -s -X GET "https://zylalabs.com/api/2088/news-api/8710/search-news?q=USA&gl=us&num=50" \
-H "Authorization: Bearer YOUR_API_KEY"
नीचे दिया गया उदाहरण उपलब्ध कराया गया रिस्पॉन्स है। इसका खोज शब्द frauds and scams है, इसलिए यह ऊपर दिए गए USA अनुरोध के सटीक परिणामों के बजाय रिस्पॉन्स फ़ील्ड दिखाता है। उपलब्ध उदाहरण एक परिणाम के बीच में समाप्त होता है और इसे अंश के रूप में दिखाया गया है, पूर्णतः पार्स किए जा सकने वाले JSON के रूप में नहीं।
{"searchParameters":{"q":"frauds and scams","gl":"us","type":"news","engine":"google"},"news":[{"title":"Crypto Scam Tracker","link":"https://dfpi.ca.gov/consumers/crypto/crypto-scam-tracker/","snippet":"Crypto Blackmail Scam – Scammer sends emails or physical mails to victims saying they have personal information about the victim or embarrassing...","date":"3 days ago","source":"CA.gov","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSgiicmdcYcwifMoZJo-zKUAlcEIOZCvDl1-wz0dAAJigCnwL1z3Ty3m8o1fw&s","position":1},{"title":"Common Frauds and Scams | Federal Bureau of Investigation","link":"https://www.fbi.gov/how-we-can-help-you/scams-and-safety/common-frauds-and-scams","snippet":"Learn about some of the most common frauds and scams that the FBI encounters—as well as tips to help you stay safe and what to do if you're...","date":"7 months ago","source":"FBI.gov","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSKdrUO5MRmVg0GI7z198fT6rtJ9ylsRFmKjXykDrvrzaC4wQILPvbvtMqikg&s","position":2},{"title":"Bank transfer fraud losses outpace crypto","link":"https://www.paymentsdive.com/news/bank-transfer-fraud-losses-crypto-federal-trade-commission/743202/","snippet":"The value of fraud losses last year was highest for bank transfers and payments, followed by cryptocurrency transactions, according to a...","date":"1 day ago","source":"Payments Dive","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj9XxTsKfvCq3xM6xpFGVIXaL9i09IEtjl_EKOBwt2lgDXfA6K1eccwZdTwQ&s","position":3},{"title":"New FTC Data Show a Big Jump in Reported Losses to Fraud to $12.5 Billion in 2024","link":"https://www.ftc.gov/news-events/news/press-releases/2025/03/new-ftc-data-show-big-jump-reported-losses-fraud-125-billion-2024","snippet":"Newly released Federal Trade Commission data show that consumers reported losing more than $12.5 billion to fraud in 2024, which represents...","date":"2 weeks ago","source":"Federal Trade Commission (.gov)","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR5Bw4fovNk1XEEElT5Y6JAs56siR5QuVXvijYIBxwSyRuUC0Mk2lBN9ajnLg&s","position":4},{"title":"Fraud Prevention, Worker Protection, and Fighting Alleged Big Tech…","link":"https://www.kelleydrye.com/viewpoints/blogs/ad-law-access/fraud-prevention-worker-protection-and-fighting-alleged-big-tech-censorship-a-roundup-of-the-new-ftcs-agenda-after-the-first-50-days","snippet":"So far, the FTC has issued several business blog posts, formed two new task forces…
परिणामों की सूची के लिए शीर्षक हेतु title और link का उपयोग करें, और सहायक टेक्स्ट के रूप में source, date तथा snippet दिखाएँ। उदाहरण में date के मान 3 days ago जैसी सापेक्ष स्ट्रिंग हैं; इन्हें सटीक टाइमस्टैम्प न मानें और न ही कोई टाइमज़ोन मानकर चलें। position परिणाम का स्थान दर्ज करता है, जबकि imageUrl से इमेज का संदर्भ मिल सकता है।
Python से एंडपॉइंट कॉल करें
यह नमूना Python की मानक लाइब्रेरी का उपयोग करता है, curl उदाहरण जैसा ही अनुरोध भेजता है और लौटाए गए प्रत्येक समाचार आइटम के फ़ील्ड प्रिंट करता है। इसे चलाने से पहले अपने एनवायरनमेंट में YOUR_API_KEY सेट करें।
import json
import os
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
url = "https://zylalabs.com/api/2088/news-api/8710/search-news?q=USA&gl=us&num=50"
request = Request(
url,
headers={"Authorization": f"Bearer {os.environ['YOUR_API_KEY']}"},
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
data = json.load(response)
for item in data.get("news", []):
print(item.get("title", ""))
print(item.get("source", ""), item.get("date", ""))
print(item.get("link", ""))
print(item.get("snippet", ""))
print()
except HTTPError as exc:
print(f"News API request failed: HTTP {exc.code}")
except URLError as exc:
print(f"Could not reach News API: {exc.reason}")
यह स्क्रिप्ट ऊपर दिए गए कटे हुए उदाहरण के बजाय लाइव रिस्पॉन्स पढ़ती है। अलग-अलग फ़ील्ड दिखाते समय यह get का उपयोग करती है, ताकि किसी डिस्प्ले मान के गायब होने पर पूरी परिणाम सूची रुक न जाए। उपयोगकर्ता-सामना करने वाले एप्लिकेशन में HTML रेंडर करते समय लौटाए गए टेक्स्ट को एस्केप भी करें और लौटाए गए लिंक को बाहरी लिंक मानें।
अगर आप खोजों को कैश करते हैं, तो अपनी कैश कुंजी में खोज शब्द और अनुरोध के अन्य पैरामीटर शामिल करें। एप्लिकेशन के अनुरूप रिफ़्रेश नीति चुनें: कैश की गई सापेक्ष तारीख फ़ेच के समय लौटाया गया टेक्स्ट होती है, लगातार अपडेट होने वाला टाइमस्टैम्प नहीं।
किसी एप्लिकेशन या AI एजेंट में परिणामों का उपयोग करें
विषय-निगरानी डैशबोर्ड किसी विषय की खोज करके समीक्षा के लिए लौटाए गए शीर्षक, स्रोत और लिंक दिखा सकता है। समाचार-खोज पेज परिणामों की सूची बनाने के लिए उन्हीं फ़ील्ड का उपयोग कर सकता है; अगर आप रिस्पॉन्स का क्रम बनाए रखना चाहते हैं, तो लौटाए गए स्थान को सुरक्षित रखें। दोनों ही मामलों में, खाली news सूची को अनुरोध की विफलता न मानें।
AI वर्कफ़्लो के लिए, किसी संगत क्लाइंट को https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY से कनेक्ट करें। Zyla का MCP एंडपॉइंट Claude Code, Cursor, Windsurf और अन्य MCP-संगत क्लाइंट के साथ काम करता है।
कनेक्ट होने के बाद, एजेंट समाचार खोजने और लौटाए गए शीर्षकों, स्निपेट, स्रोतों तथा लिंक के साथ काम करने के लिए Hub इंटीग्रेशन का उपयोग कर सकता है। उससे कहें कि वह अपने आउटपुट में स्रोत लिंक बनाए रखे, ताकि पाठक मूल कवरेज देख सकें, और API key को प्रॉम्प्ट या साझा ट्रांसक्रिप्ट से बाहर रखें।
अक्सर पूछे जाने वाले प्रश्न
समाचार खोजने के लिए कौन-से पैरामीटर आवश्यक हैं?
q और gl आवश्यक स्ट्रिंग हैं। num वैकल्पिक है; दस्तावेज़ीकृत अनुरोध में q=USA, gl=us और num=50 का उपयोग किया गया है।
क्या रिस्पॉन्स में लेखों के लिंक शामिल होते हैं?
हाँ। दिए गए रिस्पॉन्स में दिखाए गए हर पूर्ण समाचार परिणाम के लिए link शामिल है, साथ ही शीर्षक, स्निपेट, स्रोत और सापेक्ष तारीख भी है।
क्या लौटाई गई तारीख को सटीक प्रकाशन टाइमस्टैम्प के रूप में इस्तेमाल कर सकता हूँ?
दिए गए उदाहरण के आधार पर नहीं। इसकी तारीखें सापेक्ष टेक्स्ट हैं, इसलिए सटीक तारीख या टाइमज़ोन मानने के बजाय उन्हें वैसे ही दिखाएँ जैसे वे लौटाई गई हैं।
क्या AI एजेंट News API को कॉल कर सकता है?
हाँ। अपनी API key का उपयोग करके किसी MCP-संगत क्लाइंट को Zyla के MCP एंडपॉइंट से कनेक्ट करें, फिर समाचार-खोज वर्कफ़्लो के लिए Hub इंटीग्रेशन का उपयोग करें।
मुफ़्त Zyla खाता बनाएँ, फिर API key पाने और मौजूदा ट्रायल तथा सदस्यता विकल्प देखने के लिए News API पर 7-दिन का ट्रायल शुरू करें।
आधिकारिक API रिस्पॉन्स
{"searchParameters":{"q":"frauds and scams","gl":"us","type":"news","engine":"google"},"news":[{"title":"Crypto Scam Tracker","link":"https://dfpi.ca.gov/consumers/crypto/crypto-scam-tracker/","snippet":"Crypto Blackmail Scam – Scammer sends emails or physical mails to victims saying they have personal information about the victim or embarrassing...","date":"3 days ago","source":"CA.gov","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSgiicmdcYcwifMoZJo-zKUAlcEIOZCvDl1-wz0dAAJigCnwL1z3Ty3m8o1fw&s","position":1},{"title":"Common Frauds and Scams | Federal Bureau of Investigation","link":"https://www.fbi.gov/how-we-can-help-you/scams-and-safety/common-frauds-and-scams","snippet":"Learn about some of the most common frauds and scams that the FBI encounters—as well as tips to help you stay safe and what to do if you're...","date":"7 months ago","source":"FBI.gov","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSKdrUO5MRmVg0GI7z198fT6rtJ9ylsRFmKjXykDrvrzaC4wQILPvbvtMqikg&s","position":2},{"title":"Bank transfer fraud losses outpace crypto","link":"https://www.paymentsdive.com/news/bank-transfer-fraud-losses-crypto-federal-trade-commission/743202/","snippet":"The value of fraud losses last year was highest for bank transfers and payments, followed by cryptocurrency transactions, according to a...","date":"1 day ago","source":"Payments Dive","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj9XxTsKfvCq3xM6xpFGVIXaL9i09IEtjl_EKOBwt2lgDXfA6K1eccwZdTwQ&s","position":3},{"title":"New FTC Data Show a Big Jump in Reported Losses to Fraud to $12.5 Billion in 2024","link":"https://www.ftc.gov/news-events/news/press-releases/2025/03/new-ftc-data-show-big-jump-reported-losses-fraud-125-billion-2024","snippet":"Newly released Federal Trade Commission data show that consumers reported losing more than $12.5 billion to fraud in 2024, which represents...","date":"2 weeks ago","source":"Federal Trade Commission (.gov)","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR5Bw4fovNk1XEEElT5Y6JAs56siR5QuVXvijYIBxwSyRuUC0Mk2lBN9ajnLg&s","position":4},{"title":"Fraud Prevention, Worker Protection, and Fighting Alleged Big Tech…","link":"https://www.kelleydrye.com/viewpoints/blogs/ad-law-access/fraud-prevention-worker-protection-and-fighting-alleged-big-tech-censorship-a-roundup-of-the-new-ftcs-agenda-after-the-first-50-days","snippet":"So far, the FTC has issued several business blog posts, formed two new task forces…
आधिकारिक API रिस्पॉन्स
{"searchParameters":{"q":"frauds and scams","gl":"us","type":"news","engine":"google"},"news":[{"title":"Crypto Scam Tracker","link":"https://dfpi.ca.gov/consumers/crypto/crypto-scam-tracker/","snippet":"Crypto Blackmail Scam – Scammer sends emails or physical mails to victims saying they have personal information about the victim or embarrassing...","date":"3 days ago","source":"CA.gov","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSgiicmdcYcwifMoZJo-zKUAlcEIOZCvDl1-wz0dAAJigCnwL1z3Ty3m8o1fw&s","position":1},{"title":"Common Frauds and Scams | Federal Bureau of Investigation","link":"https://www.fbi.gov/how-we-can-help-you/scams-and-safety/common-frauds-and-scams","snippet":"Learn about some of the most common frauds and scams that the FBI encounters—as well as tips to help you stay safe and what to do if you're...","date":"7 months ago","source":"FBI.gov","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSKdrUO5MRmVg0GI7z198fT6rtJ9ylsRFmKjXykDrvrzaC4wQILPvbvtMqikg&s","position":2},{"title":"Bank transfer fraud losses outpace crypto","link":"https://www.paymentsdive.com/news/bank-transfer-fraud-losses-crypto-federal-trade-commission/743202/","snippet":"The value of fraud losses last year was highest for bank transfers and payments, followed by cryptocurrency transactions, according to a...","date":"1 day ago","source":"Payments Dive","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj9XxTsKfvCq3xM6xpFGVIXaL9i09IEtjl_EKOBwt2lgDXfA6K1eccwZdTwQ&s","position":3},{"title":"New FTC Data Show a Big Jump in Reported Losses to Fraud to $12.5 Billion in 2024","link":"https://www.ftc.gov/news-events/news/press-releases/2025/03/new-ftc-data-show-big-jump-reported-losses-fraud-125-billion-2024","snippet":"Newly released Federal Trade Commission data show that consumers reported losing more than $12.5 billion to fraud in 2024, which represents...","date":"2 weeks ago","source":"Federal Trade Commission (.gov)","imageUrl":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR5Bw4fovNk1XEEElT5Y6JAs56siR5QuVXvijYIBxwSyRuUC0Mk2lBN9ajnLg&s","position":4},{"title":"Fraud Prevention, Worker Protection, and Fighting Alleged Big Tech…","link":"https://www.kelleydrye.com/viewpoints/blogs/ad-law-access/fraud-prevention-worker-protection-and-fighting-alleged-big-tech-censorship-a-roundup-of-the-new-ftcs-agenda-after-the-first-50-days","snippet":"So far, the FTC has issued several business blog posts, formed two new task forces…