Get started with the APITube News API

Tasha Tatum

Tasha Tatum

·

17 分钟 阅读

Get started with the APITube News API

Get started with the APITube News API

APITube returns news articles from more than 300,000 sources in 60 languages and 177 countries. Use it to build a news reader, follow a market, or analyze coverage.

This guide walks through registration, authentication, your first request, and news filters.

What is the APITube News API?

APITube gives you news articles through one API. Responses include the article text and metadata such as its tone, names mentioned, and language.

Key features of APITube News API:

Live news on over 300,000 verifiable sources.
The coverage is over 177 countries in 60 languages.
Computer-generated analysis with sentiment analysis and entity recognition.
Basic, RESTful API architecture and regular format of response.
Customizable search features and numerous filtering features.
Various export formats such as JSON, CSV, and XML amongst others.

Step 1: Sign up and get your API key

Create an account and get an API key. Include the key in each request to authenticate it.

Go to the APITube home page and press Sign up.
Fill in your details in the registration process.
Upon registration, you will be issued with your own API key.
You should remember to save this key somewhere safe because it will be required whenever you make an API request.

Step 2: Understanding authentication methods

There are two ways to send your API key:

Method 1: Send it in an HTTP header (recommended)

For server-side requests, send the key in a header and keep it out of client-side code:

curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?per_page=10

Method 2: API key in query string

This method is simpler but not recommended for production because it exposes your API key in the URL:

curl https://api.apitube.io/v1/news/everything?per_page=10&api_key=YOUR_API_KEY

Step 3: Exploring available endpoints

APITube News API provides several endpoints to access different types of news content:

Endpoint描述
/v1/news/everythingGet all articles with flexible filtering
/v1/news/top-headlinesGet top headlines
/v1/news/storyGet a specific story by Article ID
/v1/news/articleGet a specific article by Article ID
/v1/news/categoryGet articles by category
/v1/news/topicGet articles by topic
/v1/news/industryGet articles by industry
/v1/news/entityGet articles by entity

Step 4: Making your first API request

Let's start with a simple request to get the latest news articles. This example retrieves 10 recent articles:

curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?per_page=10

The response will be in JSON format and contains the requested news articles along with metadata about the request.

Step 5: Understanding the response structure

All APITube responses are returned in JSON format with a consistent structure:

{
  "status": "ok",
  "limit": 2,
  "path": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=1",
  "page": 1,
  "has_next_pages": true,
  "next_page": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=2",
  "has_previous_page": false,
  "previous_page": "",
  "export": {
    "json": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=1&export=json",
    "xlsx": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=1&export=xlsx",
    "csv": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=1&export=csv",
    "tsv": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=1&export=tsv",
    "xml": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=1&export=xml",
    "rss": "https://api.apitube.io/v1/news/everything?language.code=en&per_page=2&page=1&export=rss"
  },
  "request_id": "5978d89c-46f6-4ab4-b65c-8b4a6000d4ac",
  "results": [
    {
      "id": 12345678,
      "href": "https://example.com/tech/new-smartphone-release",
      "published_at": "2025-02-07T10:30:00Z",
      "title": "New XYZ Smartphone Makes Waves in the Market",
      "description": "XYZ Company has introduced a new flagship smartphone that significantly outperforms competitors in performance and camera quality.",
      "body": "Today, XYZ Company introduced its new flagship smartphone. The device is equipped with the latest generation processor and a revolutionary camera capable of professional quality photos even in low light.",
      "body_html": "<p>Today, XYZ Company introduced its new flagship smartphone. The device is equipped with the latest generation processor and a revolutionary camera capable of professional quality photos even in low light.</p>",
      "language": "en",
      "author": {
        "id": 5678,
        "name": "John Smith"
      },
      "image": "https://example.com/images/xyz-smartphone.jpg",
      "categories": [
        {
          "id": 199,
          "name": "economy, business and finance",
          "score": 0.6,
          "taxonomy": "iptc_mediatopics",
          "links": {
            "self": "https://api.apitube.io/v1/news/category/iptc_mediatopics/medtop:04000000"
          }
        }
      ],
      "topics": [
        {
          "id": "industry.financial_news",
          "name": "Finance Industry News",
          "score": 0.1,
          "links": {
            "self": "https://api.apitube.io/v1/news/topic/industry.financial_news"
          }
        }
      ],
      "industries": [
        {
          "id": 456,
          "name": "Consumer Electronics",
          "links": {
            "self": "https://api.apitube.io/v1/news/industry/456"
          }
        }
      ],
      "entities": [
        {
          "id": 789,
          "name": "XYZ Company",
          "type": "organization",
          "links": {
            "self": "https://api.apitube.io/v1/news/entity/789",
            "wikipedia": "https://en.wikipedia.org/wiki/XYZ_Company",
            "wikidata": "https://www.wikidata.org/wiki/Q12345"
          },
          "frequency": 3,
          "title": {
            "pos": [
              {"start": 4, "end": 15}
            ]
          },
          "body": {
            "pos": [
              {"start": 6, "end": 17},
              {"start": 122, "end": 133}
            ]
          },
          "metadata": {
            "name": "XYZ Company",
            "type": "business",
            "country": {"code": "US", "name": "United States"},
            "description": "Technology company"
          }
        }
      ],
      "source": {
        "id": 123,
        "domain": "example.com",
        "home_page_url": "https://example.com",
        "type": "news",
        "bias": "center",
        "rankings": {
          "opr": 8
        },
        "location": {
          "country_name": "United States",
          "country_code": "us"
        },
        "favicon": "https://example.com/favicon.ico"
      },
      "sentiment": {
        "overall": {"score": 0.45, "polarity": "positive"},
        "title": {"score": 0.3, "polarity": "positive"},
        "body": {"score": 0.6, "polarity": "positive"}
      },
      "summary": [
        {
          "sentence": "Today, XYZ Company introduced its new flagship smartphone.",
          "sentiment": {"score": 0.2, "polarity": "positive"}
        },
        {
          "sentence": "Industry experts have already highly rated the novelty, noting its excellent performance and innovative features.",
          "sentiment": {"score": 0.8, "polarity": "positive"}
        }
      ],
      "keywords": ["smartphone", "XYZ", "technology"],
      "links": [
        {"url": "https://example.com/related/xyz-previous-model", "type": "link"}
      ],
      "media": [
        {"url": "https://example.com/images/xyz-smartphone.jpg", "type": "image"},
        {"url": "https://example.com/videos/xyz-smartphone-preview.mp4", "type": "video"}
      ],
      "story": {
        "id": 3019419820,
        "uri": "https://api.apitube.io/v1/news/story/3019419820"
      },
      "shares": {
        "total": 288,
        "facebook": 149,
        "twitter": 74,
        "reddit": 65
      },
      "is_duplicate": false,
      "is_free": true,
      "is_breaking": false,
      "read_time": 2,
      "sentences_count": 3,
      "paragraphs_count": 1,
      "words_count": 60,
      "characters_count": 354
    }
  ]
}

Each article in the response contains detailed information including title, content, source, publication date, and more.

Step 6: Filtering news with parameters

APITube News API has extensive filtering capabilities. Here are some common parameters you can use:

Title-based filtering

# Get articles with "technology" in the title
curl -X GET "https://api.apitube.io/v1/news/everything?title=technology&api_key=YOUR_API_KEY"

# Get articles with either "AI" or "innovation" in the title
curl -X GET "https://api.apitube.io/v1/news/everything?title=AI,innovation&api_key=YOUR_API_KEY"

# Exclude articles with "celebrity" in the title
curl -X GET "https://api.apitube.io/v1/news/everything?ignore.title=celebrity&api_key=YOUR_API_KEY"

Language and country filtering

# Get English language articles
curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?language.code=en

# Get articles from the United States
curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?source.country.code=us

Date range filtering

# Get articles published after a specific date
curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?published_at.start=2025-01-01T00:00:00Z

# Get articles published within a date range
curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?published_at.start=2025-01-01T00:00:00Z&published_at.end=2025-01-31T23:59:59Z

Sentiment analysis filtering

# Get positive news about technology
curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?title=technology&sentiment.overall.polarity=positive

Step 7: Implementing pagination

When working with large datasets, pagination is essential. APITube makes this easy with the page and per_page parameters:

# Get the first page with 20 results per page
curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?per_page=20&page=1

The response includes pagination links:

  • next_page: URL for the next page of results
  • previous_page: URL for the previous page of results

Step 8: Implementing in your programming language

The examples above use curl for simplicity, but you can implement APITube News API in any programming language. Here are examples in popular languages:

Python implementation

import requests

api_key = "YOUR_API_KEY"
url = "https://api.apitube.io/v1/news/everything"

# Set up parameters
params = {
    "title": "technology",
    "language.code": "en",
    "per_page": 10
}

# Set up headers with API key
headers = {
    "X-API-Key": api_key
}

# Make the request
response = requests.get(url, params=params, headers=headers)

# Check if request was successful
if response.status_code == 200:
    data = response.json()
    articles = data["results"]
    
    # Process the articles
    for article in articles:
        print(f"Title: {article['title']}")
        print(f"Source: {article['source']['domain']}")
        print(f"Published: {article['published_at']}")
        print(f"URL: {article['href']}")
        print("---")
else:
    print(f"Error: {response.status_code}")
    print(response.text)

JavaScript implementation

const fetchNews = async () => {
  const apiKey = 'YOUR_API_KEY';
  const url = 'https://api.apitube.io/v1/news/everything';
  
  const params = new URLSearchParams({
    'title': 'technology',
    'language.code': 'en',
    'per_page': 10
  });
  
  try {
    const response = await fetch(`${url}?${params}`, {
      headers: {
        'X-API-Key': apiKey
      }
    });
    
    if (!response.ok) {
      throw new Error(`HTTP error! Status: ${response.status}`);
    }
    
    const data = await response.json();
    
    // Process the articles
    data.results.forEach(article => {
      console.log(`Title: ${article.title}`);
      console.log(`Source: ${article.source.domain}`);
      console.log(`Published: ${article.published_at}`);
      console.log(`URL: ${article.href}`);
      console.log('---');
    });
    
  } catch (error) {
    console.error('Error fetching news:', error);
  }
};

fetchNews();

Step 9: Advanced features and use cases

APITube News API offers several advanced features:

情感分析

Track public opinion and sentiment trends:

curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?title=bitcoin&sentiment.overall.polarity=positive

Entity recognition

Find articles mentioning specific entities:

curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?organization.name=Apple

Industry monitoring

Track news related to specific industries:

curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?industry.id=88

Content export

Export data in various formats for analysis:

curl -H "X-API-Key: YOUR_API_KEY" https://api.apitube.io/v1/news/everything?title=technology&export=csv

Step 10: Best practices

Use these practices when connecting your application:

  • Filter results: Use specific parameters to reduce the data returned.
  • Cache responses where appropriate to reduce repeat requests.
  • Respect your plan’s rate limits and retry failed requests with a delay.
  • Use pagination when a result set spans several pages.
  • Protect your API key: Send it in a header from your server and keep it out of client-side code.
  • Monitor usage so you know when you are approaching a limit.

Additional resources

APITube - News API

相关文章

按类别搜索新闻
Product

按类别搜索新闻

查找有关娱乐、商业、技术、体育和其他主题的新闻文章。

按语言搜索新闻
Product

按语言搜索新闻

查找英文、西班牙文、法文、德文及其他语言的新闻文章。

Use the APITube Postman Collection
Product

Use the APITube Postman Collection

Send APITube requests in Postman, reuse your API key, and test news filters with a collection you can share.

APITube Cookbook 可用
Product

APITube Cookbook 可用

常见任务的新闻 API 请求示例。

我们使用 Cookie

点击“接受”即表示您同意在您的设备上使用 Cookie,以使网站正常运行并用于分析。