Quickstart
This guide will get you all set up and ready to use the Fireboost.io API. We'll cover how to get started using one of our API clients and how to make your first API request.
Before you get started, you need to create an account and grab your API key and Project Name from the fireboost API dashboard.
Create an account
- Create an account in the Fireboost Dashboard
- API Dashboard >> API Keys
- Generate key >> Select read/write access
- Copy your API key
- Copy your Project Name
Install the Fireboost SDK
composer require fireboostio/fireboost-php-sdk
Include in your project:
require_once __DIR__ . 'vendor/autoload.php';
Making your first API request
After instaling the SDK, you are ready to make your first call to the Fireboost API.
- Writing a public cache entry will make it avaiable to the world.
- Writing a private cache entry will only be avaiable to be read by providing a valid JWT access token.
Let's start by writing a public cache entry.
Write your first public cache entry
Let's write a public cache entry.
use FireboostIO\SDK\CacheManager;
use FireboostIO\SDK\Adapter\SessionAdapter;
// Create a CacheManager instance with default SessionAdapter
$apiKey = 'your-api-key'; // Or set FIREBOOST_API_KEY environment variable
$cacheManager = new CacheManager(new SessionAdapter(), $apiKey);
// Save data to cache
$cacheKey = 'my-public-cache-key';
$content = ['name' => 'Example', 'value' => 123];
$isPublic = true; // Set to true for publicly accessible cache
$response = $cacheManager->saveCache($cacheKey, $content, $isPublic);
Your cache entry is now available to be read by anyone using the following URL:
https://{your-project-name}.api.fireboost.io/public-cache/get/my-public-cache-key
Read your public cache entry
Let's read your public cache entry with code:
// Read public data (no authentication required)
$cacheKey = 'my-public-cache-key';
$publicData = $cacheManager->readPublicCache($cacheKey);
// Read private data from cache
$data = $cacheManager->readCache($cacheKey);
Write your first private cache entry
Let's write a private cache entry. This will only be avaiable to be read by providing a valid JWT access token.
The only difference here is that we set the isPublic
parameter to false
.
// Create a CacheManager instance with default SessionAdapter
$apiKey = 'your-api-key'; // Or set FIREBOOST_API_KEY environment variable
$cacheManager = new CacheManager(new SessionAdapter(), $apiKey);
// Save data to cache
$cacheKey = 'my-private-cache-key';
$content = ['name' => 'Private Example', 'value' => 456];
$isPublic = false;
$response = $cacheManager->saveCache($cacheKey, $content, $isPublic);
Read your private cache entry
Your private cache entry is now available only to those with a valid JWT access token to your project. Let's read your private cache entry with code:
$apiKey = 'atleast-read-access-api-key';
$cacheManager = new CacheManager(new SessionAdapter(), $apiKey);
// Read private data from cache
$data = $cacheManager->readCache($cacheKey);
Delete your cache entry
Let's delete both of your cache entries with code:
$cacheKey = 'my-public-cache-key';
$cacheManager->deleteCache($cacheKey);
$cacheKey = 'my-private-cache-key';
$cacheManager->deleteCache($cacheKey);
What's next?
If you skipped the Introduction, we strongly recommend reading it before moving on to the rest of the documentation.
Great, you're now set up with an API client and have made your first request to the API. Here are a few links that might be handy as you venture further into the Fireboost API: