Ask coding questions

← Back to all posts
Clash Royale API with Axios
Jackbaklava

Hello everyone, I tried using the ClashRoyaleAPI with node.js but it doesn’t work cause there’s and error 403 forbidden. I know that it means that I don’t have permission to access the data, but it should be because my token is correct. So am I missing something in my code?

Answered by RemoryX [earned 5 cycles]
View Answer
Voters
RemoryX
Jackbaklava
Comments
hotnewtop
RemoryX

Hey! So I was a bit confused as to why this wasn't working when I saw it. I checked the Clash Royale API and got a key, and I believe the issue is that it requires you to register a static IP address for the key. I did some searching and found there is a 3rd party service that can and will serve as a proxy for your requests.

The proxy URL is proxy.royaleapi.dev - and the static IP you should use when you get a key is 128.128.128.128

Should work on Replit if you use this method!

Edit for clarification: Your code is correct, as it is making the request- the reason you need to use the proxy url is because Repls will occasionally shift between machines, meaning the whole static IP requirement becomes an issue. I tested this method before posting this, and it worked perfectly :)

Jackbaklava

@RemoryX Oh my god thank you so much! I was so frustrated over this problem for like a week straight. If there was an option for rewarding 50 cycles, I would honestly give you that! :)

Jackbaklava

@RemoryX but just curious, why does only the ip “ 128.128.128.128” work with the proxy?

RemoryX

@Jackbaklava It is possible I may be incorrect, but from what I could tell, that is the IP of the machine the proxy server runs on

Jackbaklava

@RemoryX Thanks alot! Btw you play clash royale?

RemoryX

@Jackbaklava I do not actually, I just saw this question and was puzzled, and decided to solve said puzzle ;)

Jackbaklava

@RemoryX lol, my bad!

Jackbaklava

Sorry for the mistake but I didn’t use axios