Dealing with API end points and arguments

I will use this url but I am hoping for general response.
Here is an Example:

[https://api.first.org/data/v1/countries?region=africa&limit.=3&pretty=true]

My question is: How to use inject node to provide the "variables" by that I mean region and limit and pretty. ( africa, 3 and true) I know each API has it's own "rules" but I am hoping for a response to help me deal with these "variable"

The 3rd and 4th example in the cookbook for http requests demonstrate this.

https://cookbook.nodered.org/#http-requests

Thank you for the link. It is a goldmine. Unfortunately I cannot use the info to help me with this post. In other words, I need some basic hand holding. I am aware of the fact that I can input some data in the inject node and refer to it using {{}} in the http request url.
I am not sure if this is the ideal way.

The ideal way is what works :person_shrugging:

Aside from an inject node

  • what do you really want to trigger this HTTP request?
  • where would the variables value ideally come from?

Yes these are the things that I have address. Starting with the first one , funny enough the inject node is the perfect way to specify the variables, The second one is really what I asked for in the post,
Are we off track?

Possibly.

But I think you are maybe asking how do you setup the inject node to send the variables?

Well, this is one way:

Then your URL in the http-request would be https://api.first.org/data/v1/countries?region={{region}}&limit.={{limit}}&pretty={{pretty}}


I hope you don't mind me saying, this is pretty base knowledge of Node-RED - perhaps investing an hour or so in some videos would help you help yourself?

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Totally agree. I will follow your advice. But remember with all this help from ytube etc... You start working and you get stuck, so what to do; start fishing for an answer and it might take to many rough roads. Or, come to this forum and you get the answer. Which what you did exactly.
Perhaps you want to teach me a lesson or two......just kidding.
P.S. Did I mention the fact I am 84!!!!

1 Like

You did not Sir (or I missed it)

Good for you friend!

I hope I helped & don't be afraid to ask for help and support here. There are a lot of very knowledgeable and friendly regulars who can get you though pretty much anything.

One thing, always try to be clear and concise in what you have done and what you are trying to achieve - that will get you the best and most accurate responses.

In the mean time, I will paste some of the regular tips for you to refer back to as you get used to the environment.


There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi


In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json


This post should help to clarify the difference between Javascript objects and JSON.


See this article in the cookbook for an example of how to join messages into one object.

If I had more time, I absolutely would, it would be an honour. Alas, time is the enemy :frowning:

It is a pleasure reading your response(s). I finished downloading the playlist you recommended. And with your help I will keep learning this important topic; I mean API which I believe will be more common than it used to be.

1 Like

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