Skip to content

Commit 889e37d

Browse files
authored
chore: rename API_KEY env var to SERPAPI_KEY (#4)
1 parent 7bdd8b7 commit 889e37d

4 files changed

Lines changed: 42 additions & 42 deletions

File tree

‎.github/workflows/serpapi-php.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PHP build
1+
name: serpapi-php
22
on:
33
push:
44
branches: [ master ]
@@ -63,4 +63,4 @@ jobs:
6363
- name: Run test suite
6464
run: composer run-script test
6565
env:
66-
API_KEY: ${{ secrets.API_KEY }}
66+
SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}

‎README.md‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ require 'vendor/autoload.php';
5050

5151
use SerpApi\Client;
5252

53-
$client = new Client(getenv('API_KEY'));
53+
$client = new Client(getenv('SERPAPI_KEY'));
5454
$results = $client->search([
5555
'q' => 'coffee',
5656
]);
@@ -88,7 +88,7 @@ The default engine is `google`. You can change it via the second constructor par
8888
```php
8989
use SerpApi\Client;
9090

91-
$client = new Client(getenv('API_KEY'), 'bing');
91+
$client = new Client(getenv('SERPAPI_KEY'), 'bing');
9292
$results = $client->search(['q' => 'coffee']);
9393
```
9494

@@ -99,7 +99,7 @@ The default request timeout is 120 seconds. Customize it via the third construct
9999
```php
100100
use SerpApi\Client;
101101

102-
$client = new Client(getenv('API_KEY'), 'google', 30);
102+
$client = new Client(getenv('SERPAPI_KEY'), 'google', 30);
103103
```
104104

105105
## Search API
@@ -108,7 +108,7 @@ $client = new Client(getenv('API_KEY'), 'google', 30);
108108
```php
109109
use SerpApi\Client;
110110

111-
$client = new Client(getenv('API_KEY'));
111+
$client = new Client(getenv('SERPAPI_KEY'));
112112
$results = $client->search([
113113
'engine' => 'google',
114114
'tbm' => 'isch',
@@ -125,7 +125,7 @@ see: [https://serpapi.com/search-api](https://serpapi.com/search-api)
125125
```php
126126
use SerpApi\Client;
127127

128-
$client = new Client(getenv('API_KEY'));
128+
$client = new Client(getenv('SERPAPI_KEY'));
129129
$results = $client->search([
130130
'engine' => 'google_scholar',
131131
'q' => 'coffee',
@@ -141,7 +141,7 @@ see: [https://serpapi.com/google-scholar-api](https://serpapi.com/google-scholar
141141
```php
142142
use SerpApi\Client;
143143

144-
$client = new Client(getenv('API_KEY'));
144+
$client = new Client(getenv('SERPAPI_KEY'));
145145
$results = $client->search([
146146
'engine' => 'google_autocomplete',
147147
'q' => 'coffee',
@@ -157,7 +157,7 @@ see: [https://serpapi.com/google-autocomplete-api](https://serpapi.com/google-au
157157
```php
158158
use SerpApi\Client;
159159

160-
$client = new Client(getenv('API_KEY'));
160+
$client = new Client(getenv('SERPAPI_KEY'));
161161
$results = $client->search([
162162
'engine' => 'google_shopping',
163163
'q' => 'coffee',
@@ -173,7 +173,7 @@ see: [https://serpapi.com/google-shopping-api](https://serpapi.com/google-shoppi
173173
```php
174174
use SerpApi\Client;
175175

176-
$client = new Client(getenv('API_KEY'));
176+
$client = new Client(getenv('SERPAPI_KEY'));
177177
$results = $client->search([
178178
'engine' => 'google_maps',
179179
'q' => 'pizza',
@@ -191,7 +191,7 @@ see: [https://serpapi.com/google-maps-api](https://serpapi.com/google-maps-api)
191191
```php
192192
use SerpApi\Client;
193193

194-
$client = new Client(getenv('API_KEY'));
194+
$client = new Client(getenv('SERPAPI_KEY'));
195195
$results = $client->search([
196196
'engine' => 'google_jobs',
197197
'q' => 'coffee',
@@ -207,7 +207,7 @@ see: [https://serpapi.com/google-jobs-api](https://serpapi.com/google-jobs-api)
207207
```php
208208
use SerpApi\Client;
209209

210-
$client = new Client(getenv('API_KEY'));
210+
$client = new Client(getenv('SERPAPI_KEY'));
211211
$results = $client->search([
212212
'engine' => 'google_events',
213213
'q' => 'Events in Austin',
@@ -224,7 +224,7 @@ see: [https://serpapi.com/google-events-api](https://serpapi.com/google-events-a
224224
```php
225225
use SerpApi\Client;
226226

227-
$client = new Client(getenv('API_KEY'));
227+
$client = new Client(getenv('SERPAPI_KEY'));
228228
$results = $client->search([
229229
'engine' => 'google_lens',
230230
'url' => 'https://i.imgur.com/5bGzZi7.jpg',
@@ -242,7 +242,7 @@ see: [https://serpapi.com/google-lens-api](https://serpapi.com/google-lens-api)
242242
```php
243243
use SerpApi\Client;
244244

245-
$client = new Client(getenv('API_KEY'));
245+
$client = new Client(getenv('SERPAPI_KEY'));
246246
$results = $client->search([
247247
'engine' => 'google_play',
248248
'q' => 'kite',
@@ -259,7 +259,7 @@ see: [https://serpapi.com/google-play-api](https://serpapi.com/google-play-api)
259259
```php
260260
use SerpApi\Client;
261261

262-
$client = new Client(getenv('API_KEY'));
262+
$client = new Client(getenv('SERPAPI_KEY'));
263263
$results = $client->search([
264264
'engine' => 'google_local_services',
265265
'q' => 'electrician',
@@ -276,7 +276,7 @@ see: [https://serpapi.com/google-local-services-api](https://serpapi.com/google-
276276
```php
277277
use SerpApi\Client;
278278

279-
$client = new Client(getenv('API_KEY'));
279+
$client = new Client(getenv('SERPAPI_KEY'));
280280
$results = $client->search([
281281
'engine' => 'bing',
282282
'q' => 'coffee',
@@ -292,7 +292,7 @@ see: [https://serpapi.com/bing-search-api](https://serpapi.com/bing-search-api)
292292
```php
293293
use SerpApi\Client;
294294

295-
$client = new Client(getenv('API_KEY'));
295+
$client = new Client(getenv('SERPAPI_KEY'));
296296
$results = $client->search([
297297
'engine' => 'baidu',
298298
'q' => 'coffee',
@@ -308,7 +308,7 @@ see: [https://serpapi.com/baidu-search-api](https://serpapi.com/baidu-search-api
308308
```php
309309
use SerpApi\Client;
310310

311-
$client = new Client(getenv('API_KEY'));
311+
$client = new Client(getenv('SERPAPI_KEY'));
312312
$results = $client->search([
313313
'engine' => 'yahoo',
314314
'p' => 'coffee',
@@ -324,7 +324,7 @@ see: [https://serpapi.com/yahoo-search-api](https://serpapi.com/yahoo-search-api
324324
```php
325325
use SerpApi\Client;
326326

327-
$client = new Client(getenv('API_KEY'));
327+
$client = new Client(getenv('SERPAPI_KEY'));
328328
$results = $client->search([
329329
'engine' => 'youtube',
330330
'search_query' => 'coffee',
@@ -340,7 +340,7 @@ see: [https://serpapi.com/youtube-search-api](https://serpapi.com/youtube-search
340340
```php
341341
use SerpApi\Client;
342342

343-
$client = new Client(getenv('API_KEY'));
343+
$client = new Client(getenv('SERPAPI_KEY'));
344344
$results = $client->search([
345345
'engine' => 'walmart',
346346
'query' => 'coffee',
@@ -356,7 +356,7 @@ see: [https://serpapi.com/walmart-search-api](https://serpapi.com/walmart-search
356356
```php
357357
use SerpApi\Client;
358358

359-
$client = new Client(getenv('API_KEY'));
359+
$client = new Client(getenv('SERPAPI_KEY'));
360360
$results = $client->search([
361361
'engine' => 'ebay',
362362
'_nkw' => 'water',
@@ -372,7 +372,7 @@ see: [https://serpapi.com/ebay-search-api](https://serpapi.com/ebay-search-api)
372372
```php
373373
use SerpApi\Client;
374374

375-
$client = new Client(getenv('API_KEY'));
375+
$client = new Client(getenv('SERPAPI_KEY'));
376376
$results = $client->search([
377377
'engine' => 'naver',
378378
'query' => 'coffee',
@@ -388,7 +388,7 @@ see: [https://serpapi.com/naver-search-api](https://serpapi.com/naver-search-api
388388
```php
389389
use SerpApi\Client;
390390

391-
$client = new Client(getenv('API_KEY'));
391+
$client = new Client(getenv('SERPAPI_KEY'));
392392
$results = $client->search([
393393
'engine' => 'home_depot',
394394
'q' => 'table',
@@ -404,7 +404,7 @@ see: [https://serpapi.com/home-depot-search-api](https://serpapi.com/home-depot-
404404
```php
405405
use SerpApi\Client;
406406

407-
$client = new Client(getenv('API_KEY'));
407+
$client = new Client(getenv('SERPAPI_KEY'));
408408
$results = $client->search([
409409
'engine' => 'apple_app_store',
410410
'term' => 'coffee',
@@ -420,7 +420,7 @@ see: [https://serpapi.com/apple-app-store](https://serpapi.com/apple-app-store)
420420
```php
421421
use SerpApi\Client;
422422

423-
$client = new Client(getenv('API_KEY'));
423+
$client = new Client(getenv('SERPAPI_KEY'));
424424
$results = $client->search([
425425
'engine' => 'duckduckgo',
426426
'q' => 'coffee',
@@ -439,7 +439,7 @@ see: [https://serpapi.com/duckduckgo-search-api](https://serpapi.com/duckduckgo-
439439
```php
440440
use SerpApi\Client;
441441

442-
$client = new Client(getenv('API_KEY'));
442+
$client = new Client(getenv('SERPAPI_KEY'));
443443
$locations = $client->location(['q' => 'Austin', 'limit' => 3]);
444444

445445
echo "Number of locations: " . count($locations) . "\n";
@@ -455,7 +455,7 @@ First, run a search and save the search ID:
455455
```php
456456
use SerpApi\Client;
457457

458-
$client = new Client(getenv('API_KEY'));
458+
$client = new Client(getenv('SERPAPI_KEY'));
459459
$results = $client->search([
460460
'q' => 'Coffee',
461461
'location' => 'Austin, Texas',
@@ -475,7 +475,7 @@ print_r($archived);
475475
```php
476476
use SerpApi\Client;
477477

478-
$client = new Client(getenv('API_KEY'));
478+
$client = new Client(getenv('SERPAPI_KEY'));
479479
$account = $client->account();
480480
print_r($account);
481481
```
@@ -485,7 +485,7 @@ print_r($account);
485485
```php
486486
use SerpApi\Client;
487487

488-
$client = new Client(getenv('API_KEY'));
488+
$client = new Client(getenv('SERPAPI_KEY'));
489489
$html = $client->html(['q' => 'Coffee']);
490490

491491
echo strlen($html) . " bytes of HTML\n";
@@ -524,7 +524,7 @@ The `tests/` directory includes specifications which serve the dual purposes of
524524
Set your secret API key in your shell before running tests:
525525

526526
```bash
527-
export API_KEY="your_secret_key"
527+
export SERPAPI_KEY="your_secret_key"
528528
```
529529

530530
Install dependencies and run the test suite:

‎README.md.erb‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def snippet(path)
1515
property = source[/assertResponseHasProperty\(\$response,\s*'([^']+)'/, 1] || 'organic_results'
1616

1717
code = "use SerpApi\\Client;\n\n"
18-
code += "$client = new Client(getenv('API_KEY'));\n"
18+
code += "$client = new Client(getenv('SERPAPI_KEY'));\n"
1919
code += "$results = $client->search(#{params});\n\n"
2020
code += "print_r($results->#{property});\n"
2121

@@ -74,7 +74,7 @@ require 'vendor/autoload.php';
7474

7575
use SerpApi\Client;
7676

77-
$client = new Client(getenv('API_KEY'));
77+
$client = new Client(getenv('SERPAPI_KEY'));
7878
$results = $client->search([
7979
'q' => 'coffee',
8080
]);
@@ -112,7 +112,7 @@ The default engine is `google`. You can change it via the second constructor par
112112
```php
113113
use SerpApi\Client;
114114

115-
$client = new Client(getenv('API_KEY'), 'bing');
115+
$client = new Client(getenv('SERPAPI_KEY'), 'bing');
116116
$results = $client->search(['q' => 'coffee']);
117117
```
118118

@@ -123,7 +123,7 @@ The default request timeout is 120 seconds. Customize it via the third construct
123123
```php
124124
use SerpApi\Client;
125125

126-
$client = new Client(getenv('API_KEY'), 'google', 30);
126+
$client = new Client(getenv('SERPAPI_KEY'), 'google', 30);
127127
```
128128

129129
## Search API
@@ -215,7 +215,7 @@ see: [https://serpapi.com/duckduckgo-search-api](https://serpapi.com/duckduckgo-
215215
```php
216216
use SerpApi\Client;
217217

218-
$client = new Client(getenv('API_KEY'));
218+
$client = new Client(getenv('SERPAPI_KEY'));
219219
$locations = $client->location(['q' => 'Austin', 'limit' => 3]);
220220

221221
echo "Number of locations: " . count($locations) . "\n";
@@ -231,7 +231,7 @@ First, run a search and save the search ID:
231231
```php
232232
use SerpApi\Client;
233233

234-
$client = new Client(getenv('API_KEY'));
234+
$client = new Client(getenv('SERPAPI_KEY'));
235235
$results = $client->search([
236236
'q' => 'Coffee',
237237
'location' => 'Austin, Texas',
@@ -251,7 +251,7 @@ print_r($archived);
251251
```php
252252
use SerpApi\Client;
253253

254-
$client = new Client(getenv('API_KEY'));
254+
$client = new Client(getenv('SERPAPI_KEY'));
255255
$account = $client->account();
256256
print_r($account);
257257
```
@@ -261,7 +261,7 @@ print_r($account);
261261
```php
262262
use SerpApi\Client;
263263

264-
$client = new Client(getenv('API_KEY'));
264+
$client = new Client(getenv('SERPAPI_KEY'));
265265
$html = $client->html(['q' => 'Coffee']);
266266

267267
echo strlen($html) . " bytes of HTML\n";
@@ -300,7 +300,7 @@ The `tests/` directory includes specifications which serve the dual purposes of
300300
Set your secret API key in your shell before running tests:
301301

302302
```bash
303-
export API_KEY="your_secret_key"
303+
export SERPAPI_KEY="your_secret_key"
304304
```
305305

306306
Install dependencies and run the test suite:

‎tests/SerpApiTestCase.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected function setUp(): void
1616
$resolved = $this->resolveApiKey();
1717

1818
if ($resolved === null && $this->requiresApiKey()) {
19-
$this->markTestSkipped('API_KEY is not set');
19+
$this->markTestSkipped('SERPAPI_KEY is not set');
2020
return;
2121
}
2222

@@ -30,13 +30,13 @@ protected function requiresApiKey(): bool
3030

3131
protected function resolveApiKey(): ?string
3232
{
33-
$env = $_ENV['API_KEY'] ?? null;
33+
$env = $_ENV['SERPAPI_KEY'] ?? null;
3434

3535
if (!empty($env)) {
3636
return $env;
3737
}
3838

39-
$value = getenv('API_KEY');
39+
$value = getenv('SERPAPI_KEY');
4040
if (!empty($value)) {
4141
return $value;
4242
}

0 commit comments

Comments
 (0)