-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
The Marketstack PHP SDK is designed to be highly configurable, allowing you to tailor its behavior to your application's needs. Configuration can be managed through a dedicated configuration file and environment variables.
For Laravel applications, you can publish the configuration file to config/marketstack.php by running:
php artisan vendor:publish --tag=marketstack-configThis file allows you to set your API key, the base URL for the API, and other essential settings. Here is the default content of the configuration file:
return [
'api_key' => env('MARKETSTACK_API_KEY'),
'base_url' => env('MARKETSTACK_BASE_URL', 'http://api.marketstack.com/v1'),
'use_https' => env('MARKETSTACK_USE_HTTPS', false),
'timeout' => env('MARKETSTACK_TIMEOUT', 30),
];Using environment variables is the recommended way to configure the SDK, as it keeps your sensitive credentials out of your codebase. The following variables are supported:
| Variable | Description |
|---|---|
MARKETSTACK_API_KEY |
Required. Your unique API key from your Marketstack account. |
MARKETSTACK_USE_HTTPS |
Set to true for paid Marketstack plans that support HTTPS. Defaults to false. |
MARKETSTACK_TIMEOUT |
The maximum number of seconds to wait for a response from the API. Defaults to 30. |
MARKETSTACK_BASE_URL |
The base URL for the Marketstack API. Defaults to http://api.marketstack.com/v1. |
Marketstack provides HTTPS access for all paid subscription plans. If you have a paid plan, you should set MARKETSTACK_USE_HTTPS to true to ensure your API requests are encrypted.
MARKETSTACK_USE_HTTPS=trueIf you are on the free plan, you must use HTTP, so this variable should be set to false.
While the default base URL is set for version 1 of the Marketstack API, you can override it if you need to use a different API version or a custom endpoint. This can be done by setting the MARKETSTACK_BASE_URL environment variable.
The default timeout for API requests is 30 seconds. You can adjust this value based on your network conditions and the expected response time from the API. For long-running requests, you may need to increase this value.
MARKETSTACK_TIMEOUT=60