News API Advanced Research Component Query Format

Here are the query instructions for this component:

Query
Surround phrases with quotes (") for exact match. Prepend words or phrases that must appear with a + symbol (e.g. +bitcoin). Prepend words that must not appear with a - symbol (e.g. -bitcoin). Boolean AND/OR/NOT also works with parentheses. The complete value for the query must be URL-encoded.

Contrary to the instructions “General Electric” throws an error while General_Electric works fine. Also, I can’t get the booleans to work no matter how I format the terms and the booleans. Can someone explain what I’m doing wrong?

1 Like

Hi @rfeigel,

is it correct, that you are trying to use the following Component: News API Advanced Search – KNIME Hub ?

If yes, could you please share your exact settings (without your News API Key) ? If not would you mind sharing your current workflow so I can have a look at it? (Of course without any API Key)

Cheers
Kathrin

I’m using the attached example which I found. Its unchanged from the original I downloaded.
News API Components Example.knwf (162.2 KB)

Hey @rfeigel,

I’m glad you’re using the News API components :slight_smile:

My guess is that your issue is occurring because, “The complete value for the query must be URL-encoded”. This is likely why the value of General_Electric works fine but General Electric does not.

Could you please try URL-encoding your query after writing it up (online tools such as https://www.urlencoder.org/ can do this easily) and let us know if that works for you? For instance, the search term some search term -bitcoin becomes some%20search%20term%20-bitcoin and general electric would become general%20electric. We’ll take it as feedback that the URL encoding should be done under the hood so that the user isn’t responsible for knowing to do that.

If that does not solve your issue, could you please share the error that you are seeing, ideally a screenshot and output from the console?

Cheers,

@sjporter

3 Likes

Thanks very much. Works perfectly. Sorry for my ignorance. I didn’t know what “URL encoding” meant.

2 Likes

No need to apologize; it’s unintuitive. Feedback has been noted!

1 Like

Another problem. If I use General%20Electric it returns things like “electric vehicles” and “General Motors” as well as General Electric. If I enclose General%20Electric in quotes I get an error. What am I doing wrong now?

Hey @rfeigel,

I’d have to see a screenshot of the error and ideally a screenshot of the component config dialog window in order to help you with that.

Cheers,

@sjporter

Here’s config. Error message attached.

(EDIT via ScottF: Screenshot and attachment removed since API key was exposed)

@rfeigel your API key is shared in this post :sweat_smile: it’s included in the text file and screenshot. I highly recommend contacting News API support to request it be changed immediately. Their support email is support@newsapi.org according to their website (it took me a second to find their support link, check the footer of the website): https://newsapi.org/

2 Likes

The proper encoding in this case would be %22General%20Electric%22%20AND%20Westinghouse which uses %22 for quotation characters. I pasted "General Electric" AND Westinghouse into https://www.urlencoder.org/ to get that answer.

However, we’ll likely add a feature in the very near future to the News API Advanced Search component that removes the need to perform URL encoding on the query, so please stay tuned!

1 Like

Thanks very much. Until the component is revised, I’ll use the online URL coder rather than guessing.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Hey @rfeigel,

The News API Headlines component has been updated :slight_smile:

Query strings are now URL-encoded by default. You can successfully submit queries such as:

"General Electric" AND Westinghouse

Instead of:

%22General%20Electric%22%20AND%20Westinghouse

Cheers,

@sjporter

3 Likes

Thanks for the heads up.

Thank you @sjporter for maintaining and updating this verified component.
Verification peformed by @Francosinus
Find out more about the verified components project at:

1 Like

Hey @rfeigel :wave:

I am probably a bit late to the party, but you could also give the native News API Nodes a try! We used them internally with a few customers for a while and just decided to make them available for free to the community. Just let me know in case you encounter any issues: mail@nodepit.com

Best regards,
Daniel

3 Likes

You guys develop cool thinks. Do you have a top 10 Nodes List somewhere? :wink:

2 Likes

@Daniel_Weikert Thanks for the compliment. This kind of feedback is exactly what motivates us to do the things we do :slight_smile:

We indeed have a few nodes in the pipeline and a lot of ideas for new nodes, but usually prioritise according to what community and/or partners need. So feel free to let us know what you are missing :wink:

1 Like