Using Postman Collection with apitube.io

Tasha Tatum

Tasha Tatum

·

20 minuti Leggete

Using Postman Collection with apitube.io

In today's software development world, APIs (Application Programming Interfaces) play a key role in enabling interaction between different systems and services. Effective testing, documentation, and use of APIs become critical for successful development and integration. In this article, we'll explore how to use the powerful Postman Collection tool to work with apitube.io — a platform providing access to news APIs from around the world.

What is Postman Collection?

Postman Collection is a set of organized API requests that can be saved, structured, and reused. Collections in Postman are like project files that combine related requests and allow you to work efficiently with APIs. They serve as a starting point for a new API and can be considered as living, interactive documentation.

The main advantages of using Postman Collection include:

  1. Request organization — collections allow you to group requests by the meaning of actions performed, API versions, or any other criteria, which significantly simplifies navigation and search for the necessary requests.

  2. Test automation — using Pre-request and Tests scripts, you can automate the API testing process, checking response statuses, data formats, and saving results for later use.

  3. API documentation — collections can serve as interactive documentation that not only describes the API but also allows you to execute requests immediately.

  4. Collaboration — collections can be exported, shared with the team, and imported, which simplifies collaborative work on a project.

  5. Service monitoring — Postman allows you to create collections for monitoring the health of API services.

What is apitube.io?

APITube.io is a powerful platform for accessing news APIs that aggregates content from more than 500,000 sources worldwide in 60 languages from 177 countries. This service provides developers with an easy way to integrate current news into their applications and websites.

The main features of apitube.io include:

  1. Access to global news in real-time — the platform allows you to monitor news sources from around the world and receive current articles almost instantly.

  2. Multilingual support — the API supports 60 languages, making it ideal for international projects.

  3. Advanced search — the ability to search for news by various parameters: location, date, source, category, industry, and many others.

  4. Analytical capabilities — the platform offers tools for sentiment analysis, public opinion analysis, content categorization, and much more.

  5. Easy integration — the API can be easily integrated with various applications and websites using your preferred programming language.

Combining the powerful capabilities of Postman Collection and the rich functionality of apitube.io opens up broad prospects for developers to create applications with current news content. In the following sections, we'll look at how to set up and use Postman Collection to work effectively with the apitube.io platform API.

Setting up Postman Collection for apitube.io

Before starting to use Postman Collection to interact with apitube.io, you need to complete several preparatory steps. In this section, we'll look in detail at the process of setting up and creating a collection for working with the news API.

Step 1: Registration and obtaining an API key

The first step to working with apitube.io is registering on the platform and obtaining a unique API key. This key is necessary to authenticate your requests to the API. The registration process is quite simple:

  1. Go to the official website apitube.io
  2. Click the "Sign up" button and fill in the required data
  3. After registration, go to the API key management section
  4. Create a new key or use the automatically generated one

The obtained API key will be used in all requests to the service, so it's important to store it in a secure place and not share it with third parties.

Step 2: Installing Postman

If you don't have Postman installed yet, you need to download and install it. Postman is available for various operating systems, including Windows, macOS, and Linux. You can download the latest version from the official website postman.com.

After installation, launch the application and create an account or log in to an existing one. This will allow you to synchronize your collections between different devices and share them with colleagues.

Step 3: Creating a new collection for apitube.io

Now that you have an API key and Postman installed, you can proceed to create a collection:

  1. Open Postman and click the "New" button
  2. Select "Collection"
  3. Enter a collection name, for example, "APITube News API"
  4. Add a collection description so that other users can understand its purpose
  5. Click "Create"

Step 4: Setting up environment variables

One of the key advantages of Postman is the ability to use environment variables. This is especially useful for storing API keys and base URLs that will be used in many requests.

To create an environment for apitube.io:

  1. Click on the gear icon in the upper right corner of Postman
  2. Select "Manage Environments"
  3. Click "Add"
  4. Enter an environment name, for example, "APITube Environment"
  5. Add the following variables:
    • base_url: https://api.apitube.io
    • api_key: your_API_key
  6. Click "Save"
  7. Select the created environment from the dropdown list in the upper right corner of Postman

Using environment variables not only simplifies working with the API but also enhances security, as you can share the collection without revealing your API key.

Step 5: Creating the first request

Now we're ready to create our first request to the apitube.io API:

  1. In the created collection, click the "..." (three dots) button and select "Add Request"
  2. Name the request "Get Latest News"
  3. Select the GET method from the dropdown list
  4. In the URL field, enter: https://api.apitube.io/v1/news/everything?api_key={{api_key}}&limit=10
  5. Click "Save"

Note that we're using the environment variables https://api.apitube.io and {{api_key}}, which will be automatically replaced with the corresponding values when the request is executed.

Step 6: Testing the request

After creating the request, you can test it immediately:

  1. Click the "Send" button
  2. In the lower part of the screen, you'll see the response from the API, which should contain a list of the latest news

If the request is executed successfully, you'll receive a JSON response with news articles. If an error occurs, check the correctness of the entered API key and URL.

Now that the basic setup is complete, we can move on to more complex scenarios of using Postman Collection with apitube.io and expand our collection with additional requests and tests.

Examples of using the apitube.io API with Postman Collection

After setting up the basic collection in Postman, let's look at specific examples of requests to the apitube.io API that you can add to your collection. These examples are based on the official API documentation and demonstrate various capabilities of the platform.

Example 1: Searching for news by keywords in the title

One of the most common scenarios for using apitube.io is searching for news by keywords in the title. In Postman, this request can be implemented as follows:

  1. Create a new request in your collection and name it "Search News by Title"
  2. Select the GET method
  3. In the URL field, enter: https://api.apitube.io/v1/news/everything?title=technology&api_key={{api_key}}

This request will return all news containing the word "technology" in the title. According to the official documentation, the title parameter supports up to 5 languages simultaneously, separated by commas.

To search for news with multiple keywords in the title, you can use the following request:

https://api.apitube.io/v1/news/everything?title=AI,innovation&api_key={{api_key}}

This request will return news containing either "AI" or "innovation" in the title.

Example 2: Filtering news by language

APITube supports more than 60 languages, making it ideal for international projects. To filter news by language, you can use the language.code parameter:

  1. Create a new request "Get News by Language"
  2. Select the GET method
  3. In the URL field, enter: https://api.apitube.io/v1/news/everything?language.code=en,fr&api_key={{api_key}}

This request will return news in English and French. According to the documentation, the language.code parameter supports up to 3 languages simultaneously, separated by commas.

To exclude news in a specific language, you can use the ignore.language.code parameter:

https://api.apitube.io/v1/news/everything?ignore.language.code=fr&api_key={{api_key}}

This request will return news in all languages except French.

Example 3: Filtering by categories

APITube offers the ability to filter news by categories. For this, the category.id parameter is used:

  1. Create a new request "Get News by Category"
  2. Select the GET method
  3. In the URL field, enter: https://api.apitube.io/v1/news/everything?category.id=2&api_key={{api_key}}

This request will return news from the "Business" category (category ID 2). To get news from the "Technology" category, use ID 4.

To combine filters by category and language:

https://api.apitube.io/v1/news/everything?category.id=3&language.code=fr&api_key={{api_key}}

This request will return news from the "Politics" category (category ID 3) in French.

Example 4: Using complex patterns in titles

APITube allows you to use regular expressions to search for news with specific patterns in titles:

  1. Create a new request "Get News by Title Pattern"
  2. Select the GET method
  3. In the URL field, enter: https://api.apitube.io/v1/news/everything?title_pattern=^Breaking%20News:%20[A-Za-z]+&api_key={{api_key}}

This request will return news whose titles start with "Breaking News:" and contain one or more alphabetic characters after that.

For more complex scenarios, you can combine various parameters:

https://api.apitube.io/v1/news/everything?title=AI&ignore.title=layoffs,job%20losses&title_starts_with=Breaking&api_key={{api_key}}

This request will return news with "AI" in the title, excluding those containing the words "layoffs" or "job losses", and the title must start with the word "Breaking".

Example 5: Market trend analysis

For market trend analysis, you can use a combination of parameters:

https://api.apitube.io/v1/news/everything?title_pattern=(bull|bear)%20market&category.id=2&published_at.start=2023-01-01&sort.by=published_at&sort.order=asc&api_key={{api_key}}

This request will return news containing the phrases "bull market" or "bear market" in the title, related to the "Business" category, published after January 1, 2023, and sorted by publication date in ascending order.

Example 6: Multilingual brand sentiment analysis

APITube provides the ability to analyze sentiment in news about specific brands:

https://api.apitube.io/v1/news/everything?language.code=en,fr,de,ja&brand.name=Netflix&sentiment.overall.polarity=positive&published_at.start=2023-01-01&sort.by=published_at&api_key={{api_key}}

This request will return positive news about Netflix in English, French, German, and Japanese, published after January 1, 2023, and sorted by publication date.

Advanced capabilities of Postman Collection for working with apitube.io

After exploring basic examples of requests to the apitube.io API, let's look at more advanced capabilities of Postman Collection that will help you work with this platform most effectively.

Creating complex requests with parameters

APITube provides a rich set of parameters for filtering and configuring requests to the news API. Using Postman, we can easily create and test requests with various parameter combinations.

Let's consider an example of creating a request to search for news on a specific topic with additional filters:

  1. Create a new request in your collection and name it "Search News by Topic"
  2. Select the GET method
  3. In the URL field, enter: https://api.apitube.io/v1/news/everything?api_key={{api_key}}
  4. Go to the "Params" tab and add the following parameters:
    • title: "artificial intelligence" (search query)
    • language.code: "en" (article language)
    • from: "2025-05-01" (search start date)
    • to: "2025-05-24" (search end date)
    • limit: "20" (number of results)
    • sort.by: "date" (sort by date)

Such a request will return up to 20 English-language news about artificial intelligence published in the specified period and sorted by date.

Using Pre-request and Tests scripts

One of the most powerful tools in Postman is scripts that can be executed before and after a request. Let's look at how they can be used when working with apitube.io.

Pre-request scripts

Pre-request scripts are executed before sending a request and can be used for dynamic parameter generation. For example, we can automatically set dates for searching news for the last week:

// Get the current date
var today = new Date();

// Get the date a week ago
var lastWeek = new Date();
lastWeek.setDate(today.getDate() - 7);

// Format dates in YYYY-MM-DD format
function formatDate(date) {
    var d = date.getDate();
    var m = date.getMonth() + 1;
    var y = date.getFullYear();
    return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d);
}

// Set environment variables
pm.environment.set('today', formatDate(today));
pm.environment.set('lastWeek', formatDate(lastWeek));

Now in the request parameters, we can use {{lastWeek}} and {{today}} instead of hard-coded dates.

Tests scripts

Tests scripts are executed after receiving a response and can be used to check the correctness of the response and save data for subsequent requests:

// Check response status
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

// Check that the response contains news
pm.test("Response contains news articles", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.articles).to.be.an('array').that.is.not.empty;
});

// Save the ID of the first article for use in other requests
if (pm.response.json().articles && pm.response.json().articles.length > 0) {
    pm.environment.set('firstArticleId', pm.response.json().articles[0].id);
}

Creating a chain of requests

By saving data from responses in environment variables, we can create chains of interconnected requests. For example, after getting a list of news, we can automatically request detailed information about the first article:

  1. Create a new request "Get Article Details"
  2. Set the GET method
  3. In the URL, enter: https://api.apitube.io/v1/news/article/{{firstArticleId}}?api_key={{api_key}}

Now, if you execute the "Search News by Topic" request and then "Get Article Details", the second request will use the article ID obtained from the results of the first request.

Test automation using Collection Runner

Postman provides the Collection Runner tool, which allows you to automatically execute all requests in a collection in a specified order. This is especially useful for testing APIs and checking various usage scenarios.

To run Collection Runner:

  1. Click the "Runner" button at the top of Postman
  2. Select your APITube collection
  3. Configure the order of requests if necessary
  4. Set the number of iterations and delay between requests
  5. Click "Start Run"

After execution, you'll receive a detailed report on the results of each request and test, which allows you to quickly identify any problems in the API operation.