laravel maintained by datacircle
Datacircle for Laravel
Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website.
This package adds a Datacircle facade and four artisan commands to a Laravel app. The facade and the commands call Datacircle's public API, https://api.datacircle.dev/v1. You need no key and no account.
| Facade method | Command | Answer | Call |
|---|---|---|---|
Datacircle::apis() |
datacircle:apis |
Every GTM API on Datacircle, with the API's slug, number of plans, number of providers and best plan | GET /apis |
Datacircle::best($slug, $limit) |
datacircle:best |
One API's plans, sorted by score out of 100, best first. Each plan comes with a rank and a price per 1,000 calls | GET /apis/{slug}/best |
Datacircle::plans($api, $query, $sort, $limit, $offset) |
datacircle:plans |
Plans that match a provider name or plan name. Search all APIs or one API. Sort the plans by score, provider or price | GET /plans |
Datacircle::provider($provider, $plans) |
datacircle:provider |
The APIs a provider sells, and the provider's rank on each API | GET /providers/{slug} |
Install
composer require datacircle/laravel
The package needs PHP 8.2 or later and Laravel 11, 12 or 13. Laravel finds the service provider and the facade by itself.
Commands
php artisan datacircle:apis
php artisan datacircle:best email-finder --limit=5
php artisan datacircle:plans "hunter" --api=email-finder --sort=price
php artisan datacircle:provider "Bright Data" --best
datacircle:apislists every API and the API's slug. Use the slug indatacircle:best.datacircle:best {slug}shows the API's best plans.--limittakes 1 to 50 plans, 10 by default.datacircle:plans {query?}searches plans by provider name and plan name. A match needs each word of the query in the provider name or the plan name.--apishows only the plans of one API. Give the API's name or slug.--sorttakesscore(the default),providerorprice. Use--limitand--offsetto page through the plans.datacircle:provider {provider}takes the provider's slug or name.--bestadds the provider's best plan on each API.
Add --json to any command to print the Datacircle API's answer as JSON.
The facade
use Datacircle\Laravel\Facades\Datacircle;
$apis = Datacircle::apis();
$best = Datacircle::best('email-finder', limit: 3);
foreach ($best['plans'] as $plan) {
echo $plan['rank'], ' ', $plan['provider'], ' ', $plan['plan'], ' ', $plan['score'], ' $', $plan['perThousand'], PHP_EOL;
}
$cheapest = Datacircle::plans(api: 'email-finder', sort: 'price', limit: 5);
$ranks = Datacircle::provider('Bright Data', plans: 'none');
Each method returns the API's JSON answer as an array. A plan has about 90 keys. The keys give the provider, plan name, score and price per 1,000 calls (perThousand, in dollars). Other keys give the rate limits, speed and fields. Read https://datacircle.dev/fields for the meaning of each key.
provider() gives the provider's plans on each API. With plans: 'best', you get only the best plan on each API. plans: 'none' gives the ranks with no plans. Bright Data has plans on 65 APIs. Use plans: 'best' or plans: 'none' for a shorter answer.
Instead of the facade, you can inject Datacircle\Laravel\DatacircleClient. The container gives one client to the whole app.
Errors
The package throws Datacircle\Laravel\ApiError on a 4xx answer, like an unknown slug or a limit over 50. The error message holds the API's own words. The status property holds the HTTP status. The body property holds the API's answer. After an unknown slug, body['slugs'] lists every valid slug. On any other failure, like a network error or a 5xx answer, the package throws a RuntimeException.
Config
The client calls https://api.datacircle.dev/v1 and waits 30 seconds for an answer. Set DATACIRCLE_BASE_URL in .env to change the URL. Set DATACIRCLE_TIMEOUT in .env to change the timeout. You can also publish the config file:
php artisan vendor:publish --tag=datacircle-config
Tests
The Datacircle client sends requests through Laravel's HTTP client. Http::fake() fakes those requests in your tests:
use Datacircle\Laravel\Facades\Datacircle;
use Illuminate\Support\Facades\Http;
Http::fake([
'api.datacircle.dev/v1/apis' => Http::response([['api' => 'Employee email', 'slug' => 'email-finder']]),
]);
$this->assertSame('email-finder', Datacircle::apis()[0]['slug']);
Network
Each method makes one HTTPS GET request to https://api.datacircle.dev/v1 and nothing else. The request holds only the method's own arguments: no key and nothing from your app or your app's users. The client asks for gzip. The API sends large answers compressed. The API takes up to 60 calls a minute from one IP address. The API can ask the client to wait. The client then waits once, for a minute at most. The package stores nothing.
Links
- Datacircle: https://datacircle.dev
- The API: https://datacircle.dev/api
- The API's spec: https://api.datacircle.dev/v1/openapi.json
- What each key means: https://datacircle.dev/fields
MIT license.