In this article, we’ll delve into the significance of “q”, “qInTitle”, and “qInMeta” Advanced Search parameters, exploring how they help users to extract precise and narrowed news data.
Before we indulge ourselves in learning about the q, qInTitle and qInMeta parameters, it is important to know where and how you can search content related to your topic.
The search bar inserted here is the same as the one found on the dashboard of the Newsdata.io, and can be accessed to fetch data as well as get data on the number of articles available from previous 48 hours related to the given query.
What are the q, qInTitle, and qInMeta parameters?
The “q”, “qInTitle”, and “qInMeta” parameters are exclusive features of NewsData.io’s Advanced Search function. They are designed to enhance the quality of your searches and enable you to retrieve articles that are directly related to your specified keywords.
1. q
The “q” parameter is short for the query. You can enter your keyword or phrase in the q parameter, and the API will retrieve all articles containing that keyword or phrase in the title, URL, meta description, or meta keywords anywhere in the articles.
The request parameter ‘q=Messi’, will fetch you all articles related to the given query.
2. qInTitle
The “qInTitle” parameter is short for “query in title.”. It is designed specifically to fetch those articles that contain the keyword/phrase in the title only.
The qInTitle parameter doesn’t search for the given keyword in the URL, meta description, or meta keywords of the articles. This helps narrow down the search results, ensuring that the retrieved articles are more relevant to your searched keyword/phrase.
The request parameter ‘qInTitle=Messi’, will fetch you all articles with the keyword in their title.
3. qInMeta
The “qInMeta” parameter is short for “query in meta.”. This will help you fetch those articles that contain the given keyword or phrase in the title, URL, meta description, or meta keywords.
The request parameter ‘qInMeta=Messi’, will fetch you articles with the given keyword in their title, URL, meta description, and meta keywords.
NOTE: You can’t use the ‘q’, ‘qInTitle’, and ‘qInMeta’ simultaneously in a single query.
NOTE: To know more about q, qInTitle and qInMeta parameters you can visit the Documentation section.
Use cases of q, qInTitle, and qInMeta
Let’s understand how q, qInTitle, and qInMeta work with the help of an example.
Let’s consider that you are looking for articles related to Messi.
Use Case: ‘q’ parameter
The ‘q’ or ‘query’ parameter is useful when you want to search and retrieve articles related to a specific keyword or phrase.
To help understand better, we will use the above-mentioned example.
- If you want to fetch articles related to Messi, then the keyword would be “Messi.”.
- The request parameter for this query would be ‘q=Messi’.
Use Case: ‘qInTitle’ parameter
The ‘qInTitle’ or ‘query in the title’ parameter is useful in conditions where the user wants specific news related to that query rather than getting irrelevant news.
To help understand better, we will use the above-mentioned example.
- If you want to fetch articles related to Messi in titles only, then the keyword would be “Messi.”.
- The request parameter for this query would be ‘qInTitle=Messi’.
By using the ‘qInTitle’ parameter, you would get specific articles related to the given query and would end up saving your credits.
Use Case: ‘qInMeta’ parameter
The ‘qInMeta’ or ‘query in meta’ parameter is useful for a user wanting to search for data which contains the given keyword in the URL, Title, Meta Keywords, and Meta description only.
To help understand better, we will use the above-mentioned example.
- If you want to fetch articles related to Messi, then the keyword would be “Messi”.
- For fetching articles with a given keyword in the title, URL, meta keywords, and meta description only, the request parameter would be ‘qInMeta=Messi’.
How to use the q, qInTitle, and qInMeta parameters?
- First, determine the keyword you want to target and fetch articles about.
- When making an API request, include the “q”, “qInTitle”, and “qInMeta” parameters along with your chosen keywords.
- The API will then return articles that match your specified criteria. This precision ensures you only receive articles that directly relate to your chosen keywords to retrieve articles that mention this topic in their URLs, titles, meta keywords, and meta descriptions.
Quick Tips and Tricks
- For a single keyphrase, your parameter would be ‘q=football’ or ‘qintitle=Messi’.
- If you are looking for articles that contain exact phrases, then you need to put the phrase between double quotes (“ “).
For example, q=“global warming”.
- If you want to search for multiple keywords present in each news article but not necessarily together, then either write all the keywords separated by a space or put the ‘AND’ operator between those keywords.
For example,
You can use ‘q=movie AND marvel’ or ‘q=movie marvel’, to search all the articles having both movie and marvel keywords anywhere in the title, URL, meta description, and content.
These keywords may or may not be present in those articles together.
- For searching those articles that should exclude some terms, you can use the ‘NOT’ operator after the keyword.For Example,If you want to fetch articles related to Global warming but not from the USA, then you can use q= “global warming” NOT (USA).This query will show those articles that contain the term global warming and exclude all those articles that contain the term USA.
- For searching for one keyword and excluding multiple keywords, you can use ‘q=social NOT (pizza AND wildfire)’.
https://newsdata.io/api/1/latest?apikey=pub_YOUR_API_KEY&q=social NOT (pizza AND wildfire)
This will exclude all those articles which contain ‘pizza’ and ‘wildfire’. - For searching for any one keyword among the two options, you can use the ‘OR’ operator.For Example, ‘q=pizza OR pasta’, will retrieve those articles which contain pizza or pasta in the entire content.If you want this keyword to be specifically mentioned in the title, then change the q to qInTitle.
- For searching any one of the keywords between two keywords, excluding one keyword, you use ‘OR’ AND ‘NOT’ operators simultaneously.For example, if q=(pizza OR pasta) NOT global, this query will retrieve the article that contains the term pizza or pasta but won’t contain the term global.
- To exclude the specific phrase rather than the keyword, the request parameter would be q=oscars NOT (“best actor”)
NOTE: The maximum character limit for a single query (“q” and “qInTitle”) is 512 characters. If the number of characters exceeds this limit, the API will show an error.
NOTE: The operators AND, OR, and NOT, as well as brackets, spaces, and quotes, are included in the character count.
This is the maximum character limit of a query that one can use to search for and retrieve data.
https://newsdata.io/api/1/latest?apikey=pub_YOUR_API_KEY&q=world OR UNESCO OR NATO OR USA OR BRICS OR meetings OR global OR INTERNATIONAL OR universal OR globally OR multinational NOT (war OR peace OR guns OR politics OR food OR fashion OR G20 OR debate OR russia OR pakistan OR deaths OR money OR GDP OR LGBTQ OR Racism OR music OR movies OR influencers OR concerts OR strike OR aliens OR killing OR illegal OR cryptocurrency OR internet OR climate OR UFO OR cartoons OR cars OR bitcoin OR flood OR earthquake OR strike OR accidents OR japan) AND mountains AND ocean
Benefits of the q, qlnTitle, and qInMeta parameters
Relevance
By utilizing these parameters, you ensure that the articles you receive are directly related to your chosen keywords, minimizing noise and maximizing relevance.
Focused Insights
Whether you’re researching a specific event, tracking trends, or staying updated on a particular topic, “q” and “qInTitle” filters provide focused insights that align with your interests.
Efficiency
These parameters streamline the process of finding information by allowing you to filter out articles that don’t match your criteria.
Efficient Credit Consumption
These parameters help ensure minimal credit consumption by enabling you to specify the articles you want to fetch. You can also fetch articles that contain the given keyword/phrase in a particular part (i.e., the title, URL, or the whole content).
Difference Between q, qInTitle, and qInMeta
Basis | q | qInTitle | qInMeta |
---|---|---|---|
News extraction points | q will extract news that contains keywords on Title, Content, URL, and Description | qInTitle will only extract news that contains keywords in Title only. | qInMeta will extract news that contains keywords in Title, URL, and Meta Description. |
query | https://newsdata.io/api/1/latest?apikey=pub_YOU API KEY&q=spider | https://newsdata.io/api/1/latest?apikey=pub_YOU API KEY&qInTitle=spider | https://newsdata.io/api/1/latest?apikey=pub_YOU API KEY&qInMeta=spider |
Suitability | Suitable for those users who want to fetch articles based on their keyword or phrase choice present anywhere in the article. | Suitable for those users who want to fetch articles based on their keyword/phrase choice as presented in the titles only. | Suitable for those users who want to fetch articles based on their keyword or phrase choice present in the meta keywords, meta description, URL, or title. |
Hello, Curious Minds!
Welcome to my corner of the digital world, a space brimming with words and woven with ideas. Fresh out of the rigorous trenches of an Economics honors degree at the esteemed University of Delhi, I know a thing or two about crunching numbers and dissecting trends. But beyond the world of graphs and equations, lies my love for reading and writing. Admittedly, I’m a newbie in the content writing scene, still tasting the ink of fresh beginnings. I believe every corner of life holds a story waiting to be told, and I’m eager to be your storyteller. So, strap yourselves in, dear readers, and let’s dive into the captivating world of words together!
P.S. Feel free to drop a comment or reach out – I’m always up for a good conversation!
Good morning/day/evening.
I have a question about qInMeta: Can i write in query some url like ‘https://….’ or not?
If no, then please rell me how to return news by source_url, or name. I make some news site on Python using framework FastAPI.
Until 2 september i maked a lot of queries like : ‘https://newsdata.io/api/1/latest?apikey={api_key}&qInMeta=https://www.obozrevatel.com’
And articles by source ‘…’ were displayed. Why it doesn’t work now?
Thank you for your attention to my questions.
PS: Sory for my english if i did mistakes. It is not my native language.
The command that you mentioned using in Python using FastAPI framework, still works. You can try inserting double quotes (“”) in the beginning as well as ending of the link to make sure the command gets through.
In case of any further queries, feel free to reach out to us via contact@newsdata.io