## How to Use the CNN API: Retrieve News with Ease
The **CNN API** allows developers to access real-time news from one of the world's leading news outlets—CNN. By leveraging this API, you can retrieve categorized news stories, get detailed reports on specific articles, and stay up to date with the latest news across various sectors like politics, business, health, and entertainment. This blog will provide a comprehensive guide on how to call the CNN API using various methods, highlight creative ideas for using the API, and cover the benefits and features of the API.
---
### What is the CNN API?
The **CNN API**, available via the RapidAPI platform, enables access to CNN's latest news headlines and detailed articles. It simplifies retrieving news articles from categories like **US**, **World**, **Politics**, **Entertainment**, and more. The API can be called to extract both short headlines and full article details with images, descriptions, and videos.
---
### Key Features and Benefits
1. **Access to Real-Time News**: Get the latest breaking news across various categories.
2. **Easy Integration**: The API is built on REST, making it easy to integrate with any system that supports HTTP requests.
3. **Detailed News Articles**: The details endpoint provides rich information such as images, headlines, descriptions, word counts, and even related videos.
4. **Flexibility**: The API allows you to filter news by category, ensuring you retrieve the news that’s most relevant to your audience.
5. **Multimedia Support**: Retrieve not just text-based news but also related images and embedded videos.
6. **Use Case Versatility**: Whether you’re building a news aggregation app, a news chatbot, or simply need up-to-date headlines for your website, the CNN API is your go-to tool.
---
### How to Call the CNN API
#### Example 1: Get News by Category
You can fetch the latest news by category using the following cURL command:
```bash
curl --request GET \
--url 'https://cnn-api.p.rapidapi.com/category?url=https%3A%2F%2Fedition.cnn.com%2Fentertainment' \
--header 'x-rapidapi-host: cnn-api.p.rapidapi.com' \
--header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY'
```
This command retrieves the latest entertainment news from CNN. You can replace the URL with other category links to retrieve news from other sections such as **World**, **US**, **Politics**, or **Health**.
##### Example of Categories:
- US: `https://edition.cnn.com/us`
- World: `https://edition.cnn.com/world`
- Politics: `https://edition.cnn.com/politics`
- Business: `https://edition.cnn.com/business`
- Health: `https://edition.cnn.com/health`
---
#### Example 2: Get Detailed News Article
For a deeper look at specific articles, use the "details" endpoint. Here’s how you can retrieve detailed information like the headline, description, images, videos, and article body:
```bash
curl --request GET \
--url 'https://cnn-api.p.rapidapi.com/details?url=https%3A%2F%2Fedition.cnn.com%2F2024%2F07%2F08%2Fpolitics%2Fbiden-fate-political-career%2Findex.html' \
--header 'x-rapidapi-host: cnn-api.p.rapidapi.com' \
--header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY'
```
The response provides:
- **Headline**: Article title.
- **Description**: A short summary of the article.
- **Images**: Thumbnail and main images.
- **Video links**: Embedded videos relevant to the story.
- **Word Count**: Total words in the article.
- **Article Body**: Full content of the article.
##### Example Response (Shortened):
```json
{
"headline": "Biden's fate is on the line in the most critical days of his political career",
"description": "The high-stakes week ahead is critical...",
"thumbnailUrl": "https://media.cnn.com/api/v1/images/stellar/prod/gettyimages-2159959397.jpg",
"articleBody": "The high-stakes week ahead is critical to whether President Joe Biden's..."
}
```
---
### Ideas for Using the CNN API
#### 1. **News Aggregation Websites**
If you're developing a news aggregation platform, you can use the CNN API to fetch top headlines in real-time. By pulling articles from different categories (e.g., politics, health, business), you can keep your readers informed with the latest updates across various sectors.
#### 2. **News-Based Mobile Apps**
Create a mobile app that delivers breaking news and updates. Use push notifications to alert users when new articles in specific categories, like sports or entertainment, are available.
#### 3. **Smart Assistants**
Integrate the CNN API with voice-enabled smart assistants like Alexa or Google Assistant, providing users with instant access to news updates on demand.
#### 4. **Custom Newsletters**
Use the API to curate daily or weekly email newsletters for your audience. You can filter articles by categories relevant to their interests and provide them with the most recent news right in their inbox.
#### 5. **Chatbots**
Create an intelligent chatbot that can answer user queries about current events, retrieve the latest news articles, and share breaking headlines. This is useful for customer service platforms or interactive media bots.
---
### Conclusion
The CNN API is an excellent tool for developers seeking to integrate real-time news content into their apps, websites, or services. With a simple, user-friendly design and extensive categories, it’s perfect for a wide range of use cases. Whether you're building a news app, newsletter, or chatbot, the CNN API helps keep your audience informed with the latest headlines and detailed reports from CNN's vast content library.
Be sure to explore its full potential by customizing requests based on categories and fetching detailed articles for a comprehensive news experience.
get details news by URL
details news - Endpoint Features
| Object | Description |
|---|---|
url |
[Required] |
{
"url": "https:\/\/edition.cnn.com\/2024\/10\/23\/entertainment\/martha-stewart-golden-bachelorette\/index.html",
"headline": "Martha Stewart has the funniest reason for not wanting to do \u00e2\u0080\u0098The Golden Bachelorette\u00e2\u0080\u0099 | CNN",
"description": "Martha Stewart may be hot in the kitchen, but she\u00e2\u0080\u0099s not looking to replicate that on a dating reality show.",
"image": "https:\/\/media.cnn.com\/api\/v1\/images\/stellar\/prod\/gettyimages-2178806460.jpg?c=16x9&q=w_800,c_fill",
"author": "Lisa Respers France",
"datePublished": "2024-10-23T13:19:27.261Z",
"dateModified": "2024-10-23T13:19:27.261Z",
"section": "2024",
"site_name": "CNN",
"locale": "en_US",
"keywords": "",
"tags": [
""
]
}
curl --location --request GET 'https://zylalabs.com/api/6437/cnn+api/9263/details+news?url=https://edition.cnn.com/2024/10/23/entertainment/martha-stewart-golden-bachelorette/index.html' --header 'Authorization: Bearer YOUR_API_KEY'
Get news by category URL
news by category - Endpoint Features
| Object | Description |
|---|---|
url |
[Required] |
{
"category": "top",
"page": 1,
"per_page": 10,
"total_pages": 7,
"total_items": 69,
"items": [
{
"headline": "Some on-air claims about Dominion Voting Systems were false, Fox News acknowledges in statement after deal is announced",
"description": "",
"link": "https:\/\/www.cnn.com\/business\/live-news\/fox-news-dominion-trial-04-18-23\/index.html",
"image": "https:\/\/cdn.cnn.com\/cnnnext\/dam\/assets\/fox-news-dominion-trial-04-18-23-large-169.jpg",
"pubDate": "Wed, 19 Apr 2023 12:44:51 GMT"
},
{
"headline": "Dominion still has pending lawsuits against election deniers such as Rudy Giuliani and Sidney Powell",
"description": "",
"link": "https:\/\/www.cnn.com\/business\/live-news\/fox-news-dominion-trial-04-18-23\/h_8d51e3ae2714edaa0dace837305d03b8",
"image": "",
"pubDate": ""
},
{
"headline": "Here are the 20 specific Fox broadcasts and tweets Dominion says were defamatory",
"description": "\u2022 Fox-Dominion trial delay 'is not unusual,' judge says\n\u2022 Fox News' defamation battle isn't stopping Trump's election lies",
"link": "https:\/\/www.cnn.com\/2023\/04\/17\/media\/dominion-fox-news-allegations\/index.html",
"image": "https:\/\/cdn.cnn.com\/cnnnext\/dam\/assets\/dominion-fox-news-allegations-large-169.jpg",
"pubDate": "Mon, 17 Apr 2023 16:01:11 GMT"
},
{
"headline": "Judge in Fox News-Dominion defamation trial: 'The parties have resolved their case'",
"description": "The judge just announced in court that a settlement has been reached in the historic defamation case between Fox News and Dominion Voting Systems.",
"link": "https:\/\/www.cnn.com\/2023\/04\/18\/media\/fox-dominion-settlement\/index.html",
"image": "https:\/\/cdn.cnn.com\/cnnnext\/dam\/assets\/fox-dominion-settlement-large-169.jpg",
"pubDate": "Wed, 19 Apr 2023 08:28:17 GMT"
},
{
"headline": "'Difficult to say with a straight face': Tapper reacts to Fox News' statement on settlement",
"description": "A settlement has been reached in Dominion Voting Systems' defamation case against Fox News, the judge for the case announced. The network will pay more than $787 million to Dominion, a lawyer for the company said.",
"link": "https:\/\/www.cnn.com\/videos\/politics\/2023\/04\/18\/jake-tapper-dominion-lawsuit-settlement-fox-news-statement-lead-vpx.cnn",
"image": "",
"pubDate": "Tue, 18 Apr 2023 21:17:44 GMT"
},
{
"headline": "Millions in the US could face massive consequences unless McCarthy can navigate out of a debt trap he set for Biden",
"description": "\u2022 DeSantis goes to Washington, a place he once despised, looking for support to take on Trump\n\u2022 Opinion: For the GOP to win, it must ditch Trump\n\u2022 Chris Christie mulling 2024 White House bid\n\u2022 Analysis: The fire next time has begun burning in Tennessee ",
"link": "https:\/\/www.cnn.com\/2023\/04\/18\/politics\/mccarthy-biden-debt-ceiling\/index.html",
"image": "https:\/\/cdn.cnn.com\/cnnnext\/dam\/assets\/mccarthy-biden-debt-ceiling-large-169.jpg",
"pubDate": "Tue, 18 Apr 2023 20:34:45 GMT"
},
{
"headline": "White homeowner accused of shooting a Black teen who rang his doorbell turns himself in to face criminal charges",
"description": "\u2022 'A major part of Ralph died': Aunt of teen shot after ringing wrong doorbell speaks\n\u2022 20-year-old woman shot after friend turned into the wrong driveway in upstate New York, officials say",
"link": "https:\/\/www.cnn.com\/2023\/04\/18\/us\/kansas-city-ralph-yarl-shooting-tuesday\/index.html",
"image": "https:\/\/cdn.cnn.com\/cnnnext\/dam\/assets\/kansas-city-ralph-yarl-shooting-tuesday-large-169.jpg",
"pubDate": "Wed, 19 Apr 2023 04:29:05 GMT"
},
{
"headline": "Newly released video shows scene of Jeremy Renner's snowplow accident",
"description": "Newly released body camera footage shows firefighters and sheriff's deputies rushing to help actor Jeremy Renner after a near-fatal snowplow accident in January. The \"Avengers\" actor broke more than 30 bones and suffered other severe injuries. CNN's Chloe Melas has more. ",
"link": "https:\/\/www.cnn.com\/videos\/us\/2023\/04\/18\/jeremy-renner-snowplow-accident-bodycam-nc-melas-contd-vpx.cnn",
"image": "",
"pubDate": "Tue, 18 Apr 2023 14:09:43 GMT"
},
{
"headline": "Jake Gyllenhaal and Jamie Lee Curtis spent the Covid-19 lockdown together",
"description": "It's sourdough bread and handstands for Jake Gyllenhaal and Jamie Lee Curtis.",
"link": "https:\/\/www.cnn.com\/2023\/04\/18\/entertainment\/jake-gyllenhaal-jamie-lee-curtis-pandemic-living\/index.html",
"image": "https:\/\/cdn.cnn.com\/cnnnext\/dam\/assets\/jake-gyllenhaal-jamie-lee-curtis-pandemic-living-large-169.jpg",
"pubDate": "Tue, 18 Apr 2023 14:40:32 GMT"
},
{
"headline": "Toddler crawls through White House fence, prompts Secret Service response",
"description": "A tiny intruder infiltrated White House grounds Tuesday, prompting a swift response from the US Secret Service.",
"link": "https:\/\/www.cnn.com\/2023\/04\/18\/politics\/white-house-toddler\/index.html",
"image": "https:\/\/cdn.cnn.com\/cnnnext\/dam\/assets\/white-house-toddler-large-169.jpg",
"pubDate": "Tue, 18 Apr 2023 17:38:16 GMT"
}
],
"available_categories": [
"top",
"world",
"us",
"politics",
"business",
"tech",
"health",
"entertainment",
"travel",
"sports",
"opinion",
"justice",
"weather",
"latest",
"europe",
"asia",
"africa",
"middleeast",
"americas",
"energy",
"space",
"food",
"style",
"living",
"education"
]
}
curl --location --request GET 'https://zylalabs.com/api/6437/cnn+api/9264/news+by+category?url=https://edition.cnn.com/entertainment' --header 'Authorization: Bearer YOUR_API_KEY'
| Header | Description |
|---|---|
Authorization
|
[Required] Should be Bearer access_key. See "Your API Access Key" above when you are subscribed. |
No long-term commitment. Upgrade, downgrade, or cancel anytime. Free Trial includes up to 50 requests.
The CNN API has two main endpoints. The "Get News by Category" endpoint returns a list of headlines and links for articles in specified categories. The "Get Detailed News Article" endpoint provides comprehensive details about a specific article, including the headline, description, images, videos, word count, and the full article body.
Key fields in the "Get News by Category" response include "headline" and "link." For the "Get Detailed News Article," important fields are "headline," "description," "thumbnailUrl," "articleBody," and "video links." These fields provide essential information for displaying news content.
The response data is structured in JSON format. For the category endpoint, it returns an array of articles under the "latest" key. The detailed article endpoint returns a single object with various keys representing different aspects of the article, such as "headline," "description," and "images."
The "Get News by Category" endpoint provides headlines and links to articles across various categories like U.S., World, Politics, and more. The "Get Detailed News Article" endpoint offers in-depth information about a specific article, including multimedia elements and a full text body.
The primary parameter for both endpoints is the "url" parameter, which specifies the CNN article or category URL you want to retrieve. Users can customize their requests by changing the URL to target different news categories or specific articles.
Users can display headlines and links from the category endpoint on news aggregation sites or apps. The detailed article data can be used to create rich content displays, including images and summaries, enhancing user engagement with multimedia elements.
Typical use cases include building news aggregation websites, developing mobile news apps, creating custom newsletters, and integrating with chatbots or smart assistants to provide users with real-time news updates tailored to their interests.
The CNN API sources its data directly from CNN, a reputable news organization. Data accuracy is maintained through regular updates and quality checks performed by CNN's editorial team, ensuring that the information provided is reliable and up-to-date.
Zyla API Hub is like a big store for APIs, where you can find thousands of them all in one place. We also offer dedicated support and real-time monitoring of all APIs. Once you sign up, you can pick and choose which APIs you want to use. Just remember, each API needs its own subscription. But if you subscribe to multiple ones, you'll use the same key for all of them, making things easier for you.
Prices are listed in USD (United States Dollar), EUR (Euro), CAD (Canadian Dollar), AUD (Australian Dollar), and GBP (British Pound). We accept all major debit and credit cards. Our payment system uses the latest security technology and is powered by Stripe, one of the world's most reliable payment companies. If you have any trouble paying by card, just contact us at [email protected]
Additionally, if you already have an active subscription in any of these currencies (USD, EUR, CAD, AUD, GBP), that currency will remain for subsequent subscriptions. You can change the currency at any time as long as you don't have any active subscriptions.
The local currency shown on the pricing page is based on the country of your IP address and is provided for reference only. The actual prices are in USD (United States Dollar). When you make a payment, the charge will appear on your card statement in USD, even if you see the equivalent amount in your local currency on our website. This means you cannot pay directly with your local currency.
Occasionally, a bank may decline the charge due to its fraud protection settings. We suggest reaching out to your bank initially to check if they are blocking our charges. Also, you can access the Billing Portal and change the card associated to make the payment. If these does not work and you need further assistance, please contact our team at [email protected]
Prices are determined by a recurring monthly or yearly subscription, depending on the chosen plan.
API calls are deducted from your plan based on successful requests. Each plan comes with a specific number of calls that you can make per month. Only successful calls, indicated by a Status 200 response, will be counted against your total. This ensures that failed or incomplete requests do not impact your monthly quota.
Zyla API Hub works on a recurring monthly subscription system. Your billing cycle will start the day you purchase one of the paid plans, and it will renew the same day of the next month. So be aware to cancel your subscription beforehand if you want to avoid future charges.
To upgrade your current subscription plan, simply go to the pricing page of the API and select the plan you want to upgrade to. The upgrade will be instant, allowing you to immediately enjoy the features of the new plan. Please note that any remaining calls from your previous plan will not be carried over to the new plan, so be aware of this when upgrading. You will be charged the full amount of the new plan.
To check how many API calls you have left for the current month, refer to the 'X-Zyla-API-Calls-Monthly-Remaining' field in the response header. For example, if your plan allows 1,000 requests per month and you've used 100, this field in the response header will indicate 900 remaining calls.
To see the maximum number of API requests your plan allows, check the 'X-Zyla-RateLimit-Limit' response header. For instance, if your plan includes 1,000 requests per month, this header will display 1,000.
The 'X-Zyla-RateLimit-Reset' header shows the number of seconds until your rate limit resets. This tells you when your request count will start fresh. For example, if it displays 3,600, it means 3,600 seconds are left until the limit resets.
Yes, you can cancel your plan anytime by going to your account and selecting the cancellation option on the Billing page. Please note that upgrades, downgrades, and cancellations take effect immediately. Additionally, upon cancellation, you will no longer have access to the service, even if you have remaining calls left in your quota.
You can contact us through our chat channel to receive immediate assistance. We are always online from 8 am to 5 pm (EST). If you reach us after that time, we will get back to you as soon as possible. Additionally, you can contact us via email at [email protected]
To give you the opportunity to experience our APIs without any commitment, we offer a 7-day free trial that allows you to make up to 50 API calls at no cost. This trial can be used only once, so we recommend applying it to the API that interests you the most. While most of our APIs offer a free trial, some may not. The trial concludes after 7 days or once you've made 50 requests, whichever occurs first. If you reach the 50 request limit during the trial, you will need to "Start Your Paid Plan" to continue making requests. You can find the "Start Your Paid Plan" button in your profile under Subscription -> Choose the API you are subscribed to -> Pricing tab. Alternatively, if you don't cancel your subscription before the 7th day, your free trial will end, and your plan will automatically be billed, granting you access to all the API calls specified in your plan. Please keep this in mind to avoid unwanted charges.
After 7 days, you will be charged the full amount for the plan you were subscribed to during the trial. Therefore, it's important to cancel before the trial period ends. Refund requests for forgetting to cancel on time are not accepted.
When you subscribe to an API free trial, you can make up to 50 API calls. If you wish to make additional API calls beyond this limit, the API will prompt you to perform an "Start Your Paid Plan." You can find the "Start Your Paid Plan" button in your profile under Subscription -> Choose the API you are subscribed to -> Pricing tab.
Payout Orders are processed between the 20th and the 30th of each month. If you submit your request before the 20th, your payment will be processed within this timeframe.
Service Level:
100%
Response Time:
12,696ms
Service Level:
100%
Response Time:
100ms
Service Level:
100%
Response Time:
350ms
Service Level:
100%
Response Time:
869ms
Service Level:
100%
Response Time:
1,645ms
Service Level:
100%
Response Time:
378ms
Service Level:
100%
Response Time:
479ms
Service Level:
100%
Response Time:
1,284ms
Service Level:
96%
Response Time:
391ms
Service Level:
100%
Response Time:
116ms
Service Level:
100%
Response Time:
2,472ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
0ms
Service Level:
100%
Response Time:
65ms
Service Level:
100%
Response Time:
910ms