Skip to content

Creating the Client

supergrecko edited this page Apr 22, 2019 · 10 revisions

Before you can request data from the API you'll need to insert your API keys into the app. This is done using Environment variables.

The cool thing about using environment to load the framework is that you'll have to write zero code to initialize the framework and start making requests.

Setting up the Environment

There process of using environment variables might seem scary at first, but it makes managing your API keys safer and simpler.

Usually the environment is loaded from a file. If you already know how to load variables into the environment you can skip to the list of required variables.

Loading variables from File

To load variables from file you need to create a .env file. This can be put anywhere, but if it's outside of RiotQuest's root you'll have to load the file yourself.

Loading the file yourself is a really simple process. RiotQuest depends on symfony/dotenv to load environment variables. Just take a look at their tutorial for loading variables from a file.

As mentioned, if the file is placed inside the same directory as RiotQuest the framework will automatically find the file and load the variables. The framework directory root is the same one which as the src/ folder in it as well as a .env.example file.

Variable List

Here's a table of every environment variable RiotQuest utilizes.

Variable Data Type Description
RIOTQUEST_LOAD_ENV boolean Decide whether to load the framework using environment variables or not.
RIOTQUEST_STANDARD_KEY string The raw API key for all standard Riot Games APIs
RIOTQUEST_TOURNAMENT_KEY string The raw API key for tournament APIs. (Not required)
RIOTQUEST_STANDARD_LIMIT string The rate limits on the regular API key, in requests:interval format. If you have 20 requests per 60 seconds you'll enter 20:60.
RIOTQUEST_TOURNAMENT_LIMIT string The rate limits on the tournament API key, in requests:interval format. If you have 20 requests per 60 seconds you'll enter 20:60. (Only required if you use the tournament APIs )

Bootstrapping

After we've set up our environment variables we need to boot the client. This is with a single function which takes care of everything.

Simply run the boot function.

Client::boot();

Your client is now ready to be used.

Now that you know how to bootstrap the Client, you'll want to take a look at how you'll send a request using the Client you've just set up!

Let's go! Moving onto "Sending the Request"

Clone this wiki locally
You can’t perform that action at this time.