TRN.Developers icon indicating copy to clipboard operation
TRN.Developers copied to clipboard

How to access RocketLeague API using PHP?

Open samjco opened this issue 3 years ago • 6 comments

I have signup for the developer API on TRN site and received my KEY.

If I go here I can see the data in my browser: https://api.tracker.gg/api/v2/rocket-league/standard/profile/epic/all4gaming

However.... I have tried using the following:

using a simple php function: file_get_contents("https://api.tracker.gg/api/v2/rocket-league/standard/profile/epic/all4gaming"); Doesn't work or maybe there is a blocking

// Create a stream
$opts = array(
	'http'=>array(
		'method'=>"GET",
		"header" =>  "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36\r\n"
		. "TRN-Api-Key: XXXXX-XXXX-XXXXX\r\n" //My TRN KEY
		. "Accept: application/json\r\n"

	)
  );
  
$context = stream_context_create($opts);
echo file_get_contents("https://api.tracker.gg/api/v2/rocket-league/standard/profile/epic/all4gaming", false, $context);

Nothing doesnt seem to work. How can I get this working?

samjco avatar Dec 21 '22 07:12 samjco

#40 #35 #50 #54 #31 #10

You went to great lengths not to search for a solution.

xorth avatar Dec 21 '22 16:12 xorth

@bladefist Why am I able to access RL data from the browser but not able to access with code? Seem that RL is blocking from a browser origin using Cloudflare.

samjco avatar Dec 21 '22 20:12 samjco

Because the api is protected with cloudflare. Cloudflare see that it's not a real browser that make the request, and return you a well HTTP 403.

I bypassed that with puppeteer StealthPlugin (typescript) but i don't know if it is possible in php.

SN4K-OFF avatar Jul 24 '24 00:07 SN4K-OFF

Please do not try to bypass our Cloudflare protection. We are not allowed to offer a rocket league api.

@SN4K-OFF please stop.

xorth avatar Jul 24 '24 00:07 xorth

Please do not try to bypass our Cloudflare protection. We are not allowed to offer a rocket league api.

@SN4K-OFF please stop.

Hello xorth, I understand the importance of respecting security measures and policies. My intention is not to bypass protections for malicious purposes but simply to access the data for personal and learning purposes, without any commercial or harmful intentions. I just want to better understand how to integrate Rocket League data into my personal projects. If there is an official way or an appropriate method to access this data, I would be happy to use it. Thank you for your understanding

SN4K-OFF avatar Jul 24 '24 12:07 SN4K-OFF

If there is a concern about unauthorized access, perhaps implementing an authentication system on the API, such as a private server key, in addition to Cloudflare, would be a more coherent and professional solution to secure access to the JSON data. Thank you for your understanding.

SN4K-OFF avatar Jul 24 '24 12:07 SN4K-OFF