Previously, I wrote an article Put the Clash Royale API from lambda and send it to LINE.
The system itself is completed here, but there was a problem that it cost a lot of money.
The cause of this problem was that the Clash Royale API (Clash Royale API) restricted the accessible IPs. This time, by using the public proxy provided by Royale API, I was able to ** hit the Clash Royale API from lambda and send it to LINE ** for free, so I will write it as an article.
Exactly the same as the previous article, the player name
and the period of neglect
will arrive on LINE
Clash Royale API needs to specify the IP address, but by using Proxy of Royale API, it is no longer necessary to fix the IP address on the AWS side.
In a nutshell, it's the ** informal being closest to the official ** If you are a Clarova user, you may have heard about it, such as promptly communicating update information and collecting and publishing play data statistics.
Also, although it is currently stopped, it provided an unofficial API even before the official API of Clash Royale was provided.
As written in Document
128.128.128.128
when creating the Clash Royale API Keyapi.clashroyale.com
in the URL to send the request to proxy.royaleapi.dev
There are many opinions that "public proxy is dangerous"
-[Personal information extraction case] Never use a public proxy server -Beware of malicious "public proxies", passwords may be stolen
The dangers mentioned here are as you say and should be kept in mind.
The information via the Royale API Proxy will be the official Clash Royale API key in the header
and the data obtained from the API
.
The API key is free and there are no restrictions, and I don't want to keep the data I get secret, so I think that's okay (in my opinion).
It's up to you to decide whether to take convenience or security.
Select My Account
from the name in the upper right corner of developer.clashroyale.com and create a new key from Create New Key
Specify 128.128.128.128
for ALLOWED IP ADDRESS
Generate a key with Create Key
and save the created token
Describes the changes in Old Code and Modified Code.
Please refer to Previous article for explanations other than the changes.
#Change before
CR_BASE_URL = 'https://api.clashroyale.com/v1'
#After change
CR_BASE_URL = 'https://proxy.royaleapi.dev/v1'
serverless.yml
#Removed description of VPC roles
iamRoleStatements:
- Effect: "Allow"
Action:
- "ec2:CreateNetworkInterface"
- "ec2:DescribeNetworkInterfaces"
- "ec2:DeleteNetworkInterface"
Resource:
- "*"
#Removed description about VPC security group
vpc:
securityGroupIds:
${env:VPC_SECURITY_GROUP_IDS}
subnetIds:
${env:VPC_SUBNET_IDS}
Add API key to .env
file
CR_ACCESS_KEY_EIP=[Old API key]
CR_ACCESS_KEY_PROXY=[API key created this time]
Change the environment variable of API key set in serverless.yml
# you can define service wide environment variables here
environment:
#Change before
CR_ACCESS_KEY: ${env:CR_ACCESS_KEY_EIP}
#After change
CR_ACCESS_KEY: ${env:CR_ACCESS_KEY_PROXY}
Finally, run serverless deploy
and you're done
Thanks to RoyaleAPI, he returned to Lambda, who can do anything easily.
Royale API is a site operated by volunteers. You can help from the Donate Page
You can also help with the creator code Royale API
.
This configuration is free thanks to the Royale API. Let's support with the creator code etc.!
Recommended Posts