-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathoutscraper.php
More file actions
1440 lines (1295 loc) · 79.2 KB
/
outscraper.php
File metadata and controls
1440 lines (1295 loc) · 79.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* OutscraperClient - PHP SDK that allows using Outscraper's services and Outscraper's API.
*
* @copyright Outscraper 2025
* @license https://raw.githubusercontent.com/outscraper/outscraper-php/main/LICENSE
* @version Release: 4.2.5
* @link https://github.com/outscraper/outscraper-php
*/
const QUERY_DELIMITER = ' ';
function format_direction_queries(string|array $q): array {
if (is_array($q) && !empty($q) && is_array($q[0])) {
return array_map(
fn($pair) => implode(QUERY_DELIMITER, $pair),
$q
);
}
if (is_array($q)) {
return $q;
}
return [$q];
}
class OutscraperClient {
public $version = "4.2.6";
private $api_url = "https://api.app.outscraper.com";
private $api_headers;
private $max_ttl = 60 * 60;
private $requests_pause = 5;
/**
* @param string $api_key API KEY from https://app.outscraper.com/profile
*/
public function __construct(?string $api_key = NULL, int $requests_pause = 5) {
if($api_key == NULL)
throw new Exception("api_key must have a value");
$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Client: PHP SDK {$this->version}";
$headers[] = "X-API-KEY: {$api_key}";
$this->api_headers = $headers;
$this->requests_pause = $requests_pause;
}
private function wait_request_archive(string $request_id) : array {
$ttl = $this->max_ttl / $this->requests_pause;
while ($ttl > 0) {
$ttl--;
sleep($this->requests_pause);
$result = $this->get_request_archive($request_id);
if ($result["status"] != "Pending") {
return $result;
}
}
throw new Exception("Timeout exceeded");
}
private function make_get_request(string $url) : array {
$url = preg_replace('/%5B[0-9]+%5D/simU', '', $url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$this->api_url}/{$url}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->api_headers);
$result = json_decode(curl_exec($ch), true);
if (curl_errno($ch)) {
throw new Exception("API Error: " . curl_error($ch));
}
curl_close($ch);
if (array_key_exists("error", $result) && $result["error"] == TRUE) {
throw new Exception($result["errorMessage"]);
}
return $result;
}
private function make_post_request(string $path, array $payload = []): array {
$ch = curl_init();
$json = json_encode($payload);
curl_setopt($ch, CURLOPT_URL, "{$this->api_url}/{$path}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge(
$this->api_headers,
["Content-Type: application/json"]
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = json_decode(curl_exec($ch), true);
if (curl_errno($ch)) {
throw new Exception("API Error: " . curl_error($ch));
}
curl_close($ch);
if (is_array($result) && array_key_exists("error", $result) && $result["error"] == TRUE) {
throw new Exception($result["errorMessage"]);
}
return $result;
}
/**
* Low-level POST helper (Node-like naming).
*
* @param string $path API path (e.g. "/businesses")
* @param array $parameters JSON payload
*
* @return array decoded JSON response
*/
public function postAPIRequest(string $path, array $parameters = []): array {
$path = ltrim($path, '/');
return $this->make_post_request($path, $parameters);
}
/**
* Fetch up to 100 of your last requests.
*
* @return array requests history
*/
public function get_requests_history() : array {
return $this->make_get_request("requests");
}
/**
* Fetch request data from archive
*
* @param string $request_id id for the request/task provided by ["id"]
*
* @return array result from the archive
*/
public function get_request_archive(string $request_id) : array {
if($request_id == NULL)
throw new Exception("request_id must have a value");
return $this->make_get_request("requests/{$request_id}");
}
/**
* Returns search results from Google based on a given search query (or many queries).
*
* @param array $query Parameter defines the queries to search on Google (e.g., bitcoin, 37th president of usa). Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param int $pages_per_query Parameter specifies the limit of pages to return from one query.
* @param string $uule Google UULE parameter is used to encode a place or an exact location (with latitude and longitude) into a code. By using it you can see a Google result page like someone located at the specified location.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param bool $webhook Parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
*
* @return array request/task result
*/
public function google_search(
array $query, int $pages_per_query = 1, string $uule = "", string $language = "en", ?string $region = NULL, ?string $webhook = NULL
) : array {
$params = http_build_query(array(
"query" => $query,
"pagesPerQuery" => $pages_per_query,
"uule" => $uule,
"language" => $language,
"region" => $region,
"webhook" => $webhook,
));
$result = $this->make_get_request("google-search-v3?{$params}");
return $result["data"];
}
/**
* Fetches search results from Google News based on a given search query.
*
* @param array $query Parameter defines the queries to search on Google News (e.g., bitcoin, 37th president of usa). Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param int $pages_per_query Parameter specifies the limit of pages to return from one query.
* @param string $uule Google UULE parameter is used to encode a place or an exact location (with latitude and longitude) into a code. By using it you can see a Google result page like someone located at the specified location.
* @param string $tbs Google TBS parameter is used to search for news in Google News by specific time range. For example, `tbs=qdr:h` will search for news in the last hour.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param bool $async_request Parameter defines whether to run the request in an asynchronous manner. When set to true, the request will be processed in the background and the response will return a task id to check the status of the request.
*
* @return array request/task result
*/
public function google_search_news(
array $query, int $pages_per_query = 1, string $uule = "", string $tbs = "", string $language = "en",
?string $region = NULL, bool $async_request = FALSE
) : array {
$params = http_build_query(array(
"query" => $query,
"pagesPerQuery" => $pages_per_query,
"uule" => $uule,
"tbs" => $tbs,
"language" => $language,
"region" => $region,
"async" => $async_request,
));
$result = $this->make_get_request("google-search-news?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result["id"]);
}
/**
* Get data from Google Maps (speed optimized endpoint)
*
* @param array $query Parameter defines queries you want to search on Google Maps. Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param int $limit Parameter specifies the limit of organizations to take from one query search. Usually, there are no more than 400 organizations per one query search on Google Maps. Use more precise categories (asian restaurant, italian restaurant, etc.) to overcome this limitation.
* @param bool $extract_contacts Parameter specifies whether the bot will scrape additional data (emails, social links, site keywords…) from companies’ websites. It increases the time of the extraction.
* @param string $coordinates Parameter defines the coordinates to use along with the query. Example: "@41.3954381,2.1628662,15.1z".
* @param bool $drop_duplicates Parameter specifies whether the bot will drop the same organizations from different queries. Using the parameter combines results from each query inside one big array.
* @param int $skip Skip first N places, where N should be multiple to 20 (e.g. 0, 20, 40). It's commonly used in pagination.
* @param bool $async_request Parameter defines the way you want to submit your task to Outscraper. It can be set to `False` (default) to send a task and wait until you got your results, or `True` to submit your task and retrieve the results later using a request ID with `get_request_archive`. Each response is available for `2` hours after a request has been completed.
* @param bool $webhook Parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
*
* @return array request/task result
*/
public function google_maps_search(
array $query, string $language = "en", ?string $region = NULL, int $limit = 400,
?string $coordinates = NULL, bool $drop_duplicates = FALSE, int $skip = 0, bool $async_request = FALSE, ?string $webhook = NULL
) : array {
$params = http_build_query(array(
"query" => $query,
"language" => $language,
"region" => $region,
"organizationsPerQueryLimit" => $limit,
"coordinates" => $coordinates,
"dropDuplicates" => $drop_duplicates,
"skipPlaces" => $skip,
"async" => $async_request,
"webhook" => $webhook,
));
$result = $this->make_get_request("maps/search-v2?{$params}");
if($async_request)
return $result;
return $result["data"];
}
/**
* Get data from Google Maps
*
* @param array $query Parameter defines queries you want to search on Google Maps. Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param int $limit Parameter specifies the limit of organizations to take from one query search. Usually, there are no more than 400 organizations per one query search on Google Maps. Use more precise categories (asian restaurant, italian restaurant, etc.) to overcome this limitation.
* @param bool $extract_contacts Parameter specifies whether the bot will scrape additional data (emails, social links, site keywords…) from companies’ websites. It increases the time of the extraction.
* @param string $coordinates Parameter defines the coordinates to use along with the query. Example: "@41.3954381,2.1628662,15.1z".
* @param bool $drop_duplicates Parameter specifies whether the bot will drop the same organizations from different queries. Using the parameter combines results from each query inside one big array.
*
* @return array request/task result
*/
public function google_maps_search_v1(
array $query, string $language = "en", ?string $region = NULL, int $limit = 400,
bool $extract_contacts = FALSE, ?string $coordinates = NULL, bool $drop_duplicates = FALSE
) : array {
$params = http_build_query(array(
"query" => $query,
"language" => $language,
"region" => $region,
"organizationsPerQueryLimit" => $limit,
"coordinates" => $coordinates,
"extractContacts" => $extract_contacts,
"dropDuplicates" => $drop_duplicates,
));
$result = $this->make_get_request("maps/search?{$params}");
return $this->wait_request_archive($result["id"]);
}
/**
* Perform a search on Google Maps using the optimized v3 endpoint.
*
* @param array $query Array of search queries for Google Maps.
* @param int $limit Maximum number of results per query. Default is 20.
* @param string $language Language for Google Maps results. Default is "en".
* @param string|null $region Optional region code to specify the search region.
* @param int $skip Number of places to skip for pagination. Must be a multiple of 20.
* @param bool $drop_duplicates Whether to remove duplicate results across queries.
* @param array|null $enrichment Optional additional data enrichment options.
* @param bool $async_request If true, returns immediately with a task ID for asynchronous processing.
*
* @return array The search results or task ID if asynchronous request is enabled.
*/
public function google_maps_search_v3(
array $query, int $limit = 20, string $language = "en", ?string $region = NULL, int $skip = 0,
bool $drop_duplicates = FALSE, ?array $enrichment = NULL, bool $async_request = TRUE
) : array {
$params = http_build_query(array(
"query" => $query,
"language" => $language,
"region" => $region,
"organizationsPerQueryLimit" => $limit,
"skipPlaces" => $skip,
"dropDuplicates" => $drop_duplicates,
"enrichment" => $enrichment,
"async" => $async_request,
));
$result = $this->make_get_request("maps/search-v3?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result["id"]);
}
/**
* Perform a directions search on Google Maps.
*
* @param string|array query Directions query or list of queries. Accepted formats: string: "<origin> <destination>" (4 spaces between origin and destination); array of strings: each string in the same "<origin> <destination>" format.
* @param string|array $origin The starting point for directions. Can be an address, a latitude/longitude pair, or a place ID.
* @param string|array $destination The ending point for directions. Can be an address, a latitude/longitude pair, or a place ID.
* @param string $departure_time The desired departure time for the directions. Must be in the format "YYYY-MM-DDTHH:MM:SS".
* @param string $finish_time The desired finish time for the directions. Must be in the format "YYYY-MM-DDTHH:MM:SS".
* @param string $interval The interval for repeated directions. Must be in the format "YYYY-MM-DDTHH:MM:SS".
* @param string $travel_mode The travel mode to use for directions. Can be "best", "driving", "walking", "bicycling", or "transit".
* @param string $language The language to use for directions. Can be a two-letter ISO 639-1 language code.
* @param string $region The region to use for directions. Can be a two-letter ISO 3166-1 country code.
* @param array $fields The fields to include in the directions response. Can be an array of strings.
* @param bool $async_request If true, returns immediately with a task ID for asynchronous processing.
*
* @return array The directions results or task ID if asynchronous request is enabled.
*/
public function google_maps_directions(
string|array $query,
?string $departure_time = null,
?string $finish_time = null,
?string $interval = null,
string $travel_mode = 'best',
string $language = 'en',
?string $region = null,
?array $fields = null,
bool $async_request = true
): array {
$queries = format_direction_queries($query);
$params = http_build_query([
'query' => $queries,
'departure_time'=> $departure_time,
'finish_time' => $finish_time,
'interval' => $interval,
'travel_mode' => $travel_mode,
'language' => $language,
'region' => $region,
'async' => $async_request,
'fields' => $fields,
]);
$result = $this->make_get_request("maps/directions?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Get reviews from Google Maps (speed optimized endpoint for real time data)
*
* @param array $query Parameter defines queries you want to search on Google Maps. Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param int $limit Parameter specifies the limit of organizations to take from one query search. Usually, there are no more than 400 organizations per one query search on Google Maps. Use more precise categories (asian restaurant, italian restaurant, etc.) to overcome this limitation.
* @param int $reviews_limit Parameter specifies the limit of reviews to extract from one organization.
* @param string $coordinates Parameter defines the coordinates to use along with the query. Example: "@41.3954381,2.1628662,15.1z".
* @param int $start Parameter specifies the start timestamp value for reviews (newest review). The current timestamp is used when the value is not provided. Using the start parameter overwrites the sort parameter to newest. Therefore, the latest reviews will be at the beginning.
* @param int $cutoff Parameter specifies the maximum timestamp value for reviews. Using the cutoff parameter overwrites sort parameter to newest. Using the cutoff parameter overwrites sort parameter to newest. Therefore, the latest reviews will be at the beginning.
* @param int $cutoff_rating Parameter specifies the maximum (for lowest_rating sorting) or minimum (for highest_rating sorting) rating for reviews. Using the cutoffRating requires sorting to be set to "lowest_rating" or "highest_rating".
* @param string $sort Parameter specifies one of the sorting types. Available values: "most_relevant", "newest", "highest_rating", "lowest_rating".
* @param string $reviews_query Parameter specifies the query to search among the reviews (e.g. wow, amazing, horrible place).
* @param bool $ignore_empty Parameter specifies whether to ignore reviews without text or not.
* @param string $last_pagination_id Parameter specifies the review_pagination_id of the last item. It's commonly used in pagination.
* @param bool $async_request Parameter defines the way you want to submit your task to Outscraper. It can be set to `False` (default) to send a task and wait until you got your results, or `True` to submit your task and retrieve the results later using a request ID with `get_request_archive`. Each response is available for `2` hours after a request has been completed.
* @param bool $webhook Parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
*
* @return array request/task result
*/
public function google_maps_reviews(
array $query, string $language = "en", ?string $region = NULL, int $limit = 1,
int $reviews_limit = 100, ?string $coordinates = NULL, ?int $start = NULL, ?int $cutoff = NULL, ?int $cutoff_rating = NULL,
string $sort = "most_relevant", ?string $reviews_query = NULL, bool $ignore_empty = FALSE, ?string $source = NULL,
?string $last_pagination_id = NULL, bool $async_request = FALSE, ?string $webhook = NULL
) : array {
$params = http_build_query(array(
"query" => $query,
"language" => $language,
"region" => $region,
"organizationsPerQueryLimit" => $limit,
"reviewsPerOrganizationLimit" => $reviews_limit,
"coordinates" => $coordinates,
"start" => $start,
"cutoff" => $cutoff,
"cutoffRating" => $cutoff_rating,
"sort" => $sort,
"reviewsQuery" => $reviews_query,
"ignoreEmpty" => $ignore_empty,
"source" => $source,
"lastPaginationId" => $last_pagination_id,
"async" => $async_request,
"webhook" => $webhook,
));
$result = $this->make_get_request("maps/reviews-v3?{$params}");
if($async_request)
return $result;
return $result["data"];
}
/**
* Get reviews from Google Maps
*
* @param array $query Parameter defines queries you want to search on Google Maps. Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param int $limit Parameter specifies the limit of organizations to take from one query search. Usually, there are no more than 400 organizations per one query search on Google Maps. Use more precise categories (asian restaurant, italian restaurant, etc.) to overcome this limitation.
* @param int $reviews_limit Parameter specifies the limit of reviews to extract from one organization.
* @param string $coordinates Parameter defines the coordinates to use along with the query. Example: "@41.3954381,2.1628662,15.1z".
* @param int $cutoff Parameter specifies the maximum timestamp value for reviews. Using the cutoff parameter overwrites sort parameter to newest.
* @param int $cutoff_rating Parameter specifies the maximum (for lowest_rating sorting) or minimum (for highest_rating sorting) rating for reviews. Using the cutoffRating requires sorting to be set to "lowest_rating" or "highest_rating".
* @param string $sort Parameter specifies one of the sorting types. Available values: "most_relevant", "newest", "highest_rating", "lowest_rating".
* @param string $reviews_query Parameter specifies the query to search among the reviews (e.g. wow, amazing, horrible place).
* @param bool $ignore_empty Parameter specifies whether to ignore reviews without text or not.
* @param bool $source (str): parameter specifies source filter. This commonly used for hotels where you can find reviews from other sources like Booking.com, Expedia, etc.
*
* @return array request/task result
*/
public function google_maps_reviews_v2(
array $query, string $language = "en", ?string $region = NULL, int $limit = 1,
int $reviews_limit = 100, ?string $coordinates = NULL, ?int $cutoff = NULL, ?int $cutoff_rating = NULL,
string $sort = "most_relevant", ?string $reviews_query = NULL, bool $ignore_empty = FALSE
) : array {
$params = http_build_query(array(
"query" => $query,
"language" => $language,
"region" => $region,
"organizationsPerQueryLimit" => $limit,
"reviewsPerOrganizationLimit" => $reviews_limit,
"coordinates" => $coordinates,
"cutoff" => $cutoff,
"cutoffRating" => $cutoff_rating,
"reviewsQuery" => $reviews_query,
"ignoreEmpty" => $ignore_empty,
"sort" => $sort
));
$result = $this->make_get_request("maps/reviews-v2?{$params}");
return $this->wait_request_archive($result["id"]);
}
/**
* Get photos from Google Maps (speed optimized endpoint for real time data)
*
* @param string|array $query Parameter defines queries you want to search on Google Maps. Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param int $photos_limit Parameter specifies the maximum number of photos per place. Available values: 0-100. Default: 100.
* @param int $limit Parameter specifies the maximum number of places. Available values: 1-100. Default: 1.
* @param string $tag Parameter specifies the tag to filter photos by. Available values: "all", "profile", "cover", "avatar". Default: "all".
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO",
* @param array $fields Parameter specifies which fields to return. Available values: "name", "address", "categories", "photos", "reviews", "type", "url", "website", "place_id", "phone", "latitude", "longitude", "rating", "working_hours", "images".
* @param bool $async Parameter specifies whether to run the request in the background or not. Default: TRUE.
* @param bool $ui Parameter specifies whether to return the full request or only the id. Default: FALSE.
* @param string $webhook Parameter specifies the webhook to call when the request is finished.
*
* @return array request/task result
*/
public function get_google_maps_photos(
string|array $query,
int $photos_limit = 100,
int $limit = 1,
string $tag = 'all',
string $language = 'en',
?string $region = null,
?array $fields = null,
bool $async = true,
bool $ui = false,
?string $webhook = null
): array {
$params = http_build_query([
'query' => (array) $query,
'photosLimit' => $photos_limit,
'limit' => $limit,
'tag' => $tag,
'language' => $language,
'region' => $region,
'fields' => $fields,
'async' => $async,
'ui' => $ui,
'webhook' => $webhook,
]);
$result = $this->make_get_request("maps/photos-v3?{$params}");
if ($async) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Retrieve reviews from Google Play.
*
* @param string|array $query The query or queries to search for reviews on Google Play.
* @param int $reviews_limit The maximum number of reviews to retrieve. Default is 100.
* @param string $sort The sorting order of the reviews. Options include 'most_relevant', 'newest', etc. Default is 'most_relevant'.
* @param string|null $cutoff Optional parameter to specify the maximum timestamp for reviews.
* @param int|null $rating Optional parameter to filter reviews by rating.
* @param string $language The language for the reviews. Default is 'en'.
* @param array|null $fields Optional parameter to specify which fields to return.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the reviews request or the request ID if async_request is true.
*/
public function google_play_reviews(
string|array $query,
int $reviews_limit = 100,
string $sort = 'most_relevant',
?string $cutoff = null,
?int $rating = null,
string $language = 'en',
?array $fields = null,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $reviews_limit,
'sort' => $sort,
'cutoff' => $cutoff,
'rating' => $rating,
'language' => $language,
'async' => $async_request,
'fields' => $fields,
]);
$result = $this->make_get_request("google-play/reviews?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Contacts and Leads Scraper.
*
* Returns emails, social links, phones, and other contacts from websites
* based on domain names or URLs. Supports batching by sending arrays with
* up to 250 queries and allows multiple queries to be sent in one request
* to save on network latency time.
*
* @param string|array $query Company domains or URLs
* (e.g. 'outscraper.com' or ['tesla.com', 'microsoft.com']).
* @param string|array|null $fields Defines which fields to include in each returned item.
* By default, all fields are returned.
* @param bool $async_request The parameter defines the way you want to submit your task.
* When true, the request is submitted asynchronously and the
* method returns the task meta (ID). When false, the client
* waits for the archived result and returns the final data.
* @param string|array|null $preferred_contacts Contact roles you want to prioritize
* (e.g. 'influencers', 'technical', ['decision makers', 'sales']).
* @param int $contacts_per_company Number of contacts to return per company. Default is 3.
* @param int $emails_per_contact Number of email addresses to return per contact. Default is 1.
* @param int $skip_contacts Number of contacts to skip (for pagination). Default is 0.
* @param bool $general_emails Whether to include only general emails
* (info@, support@, etc.) or only non-general emails
* (paul@, john@, etc.). Default is false.
* @param bool $ui Execute as a UI task. On the API side this forces async mode.
* Default is false.
* @param string|null $webhook URL for callback notifications when a task completes.
*
* @return array Request/task result. If $async_request is true, returns the task meta
* (with ID). If false, waits for completion and returns the archived result data.
*/
public function contacts_and_leads(
string|array $query,
string|array|null $fields = null,
bool $async_request = true,
string|array|null $preferred_contacts = null,
int $contacts_per_company = 3,
int $emails_per_contact = 1,
int $skip_contacts = 0,
bool $general_emails = false,
bool $ui = false,
?string $webhook = null
): array {
$queries = (array) $query;
$wait_async = $async_request || count($queries) > 1;
$params = http_build_query([
'query' => $queries,
'fields' => $fields,
'async' => $wait_async,
'preferred_contacts' => $preferred_contacts,
'contacts_per_company'=> $contacts_per_company,
'emails_per_contact' => $emails_per_contact,
'skip_contacts' => $skip_contacts,
'general_emails' => $general_emails,
'ui' => $ui,
'webhook' => $webhook,
]);
$result = $this->make_get_request("contacts-and-leads?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Return email addresses, social links and phones from domains in seconds.
*
* @param array $query Domains or links (e.g., outscraper.com).
*
* @return array json result
*/
public function emails_and_contacts(array $query) : array {
$params = http_build_query(array(
"query" => $query,
"async" => FALSE,
));
$result = $this->make_get_request("emails-and-contacts?{$params}");
return $result["data"];
}
/**
* Returns phones carrier data (name/type), validates phones, ensures messages deliverability.
*
* @param array $query Phone numbers (e.g., +1 281 236 8208).
*
* @return array json result
*/
public function phones_enricher(array $query) : array {
$params = http_build_query(array(
"query" => $query,
"async" => FALSE,
));
$result = $this->make_get_request("phones-enricher?{$params}");
return $result["data"];
}
/**
* Returns data from Amazon product pages.
*
* @param string|array $query The query or queries to search for products on Amazon.
* @param int $limit The maximum number of products to retrieve. Default is 24.
* @param string $domain The domain to search on. Default is 'amazon.com'.
* @param string $postal_code The postal code to search on. Default is '11201'.
* @param array|null $fields Optional parameter to specify which fields to return.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the products request or the request ID if async_request is true.
*/
public function amazon_products(
string|array $query,
int $limit = 24,
string $domain = 'amazon.com',
string $postal_code = '11201',
?array $fields = null,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'domain' => $domain,
'postal_code' => $postal_code,
'async' => $async_request,
'fields' => $fields,
]);
$result = $this->make_get_request("amazon/products-v2?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Returns reviews from Amazon product pages.
*
* @param string|array $query The query or queries to search for reviews on Amazon.
* @param int $limit The maximum number of reviews to retrieve. Default is 10.
* @param string $sort The sorting order of the reviews. Options include 'helpful', 'newest', etc. Default is 'helpful'.
* @param string $filter_by_reviewer The type of reviewer to filter reviews by. Options include 'all_reviews', 'verified_purchase', etc. Default is 'all_reviews'.
* @param string $filter_by_star The star rating to filter reviews by. Options include 'all_stars', 'positive', etc. Default is 'all_stars'.
* @param string|null $domain The domain to search on. Default is null.
* @param array|null $fields Optional parameter to specify which fields to return.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the reviews request or the request ID if async_request is true.
*/
public function amazon_reviews(
string|array $query,
int $limit = 10,
string $sort = 'helpful',
string $filter_by_reviewer = 'all_reviews',
string $filter_by_star = 'all_stars',
?string $domain = null,
?array $fields = null,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'sort' => $sort,
'filterByReviewer' => $filter_by_reviewer,
'filterByStar' => $filter_by_star,
'domain' => $domain,
'async' => $async_request,
'fields' => $fields,
]);
$result = $this->make_get_request("amazon/reviews?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Retrieve Yelp search results.
*
* @param string|array $query The query or queries to search for on Yelp.
* @param int $limit The maximum number of results to retrieve. Default is 100.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the search request or the request ID if async_request is true.
*/
public function yelp_search(
string|array $query,
int $limit = 100,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'async' => $async_request,
]);
$result = $this->make_get_request("yelp-search?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Retrieve Yelp reviews.
*
* @param string|array $query The query or queries to search for on Yelp.
* @param int $limit The maximum number of reviews to retrieve. Default is 100.
* @param string $cursor The pagination cursor to retrieve the next set of results. Default is empty string.
* @param string $sort The sorting order of the reviews. Options include 'relevance_desc', 'rating_asc', etc. Default is 'relevance_desc'.
* @param string $cutoff The time-based cutoff for the reviews. Options include 'week', 'month', 'quarter', etc. Default is empty string.
* @param string|array|null $fields Optional parameter to specify which fields to return. Default is null.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the reviews request or the request ID if async_request is true.
*/
public function yelp_reviews(
string|array $query,
int $limit = 100,
string $cursor = '',
string $sort = 'relevance_desc',
string $cutoff = '',
string|array|null $fields = null,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'cursor' => $cursor,
'sort' => $sort,
'cutoff' => $cutoff,
'fields' => $fields,
'async' => $async_request,
]);
$result = $this->make_get_request("yelp/reviews?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Retrieve reviews from TripAdvisor.
*
* @param string|array $query The query or queries to search for on TripAdvisor.
* @param int $limit The maximum number of reviews to retrieve. Default is 100.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the reviews request or the request ID if async_request is true.
*/
public function tripadvisor_reviews(
string|array $query,
int $limit = 100,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'async' => $async_request,
]);
$result = $this->make_get_request("tripadvisor-reviews?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Retrieve reviews from AppStore.
*
* @param string|array $query The query or queries to search for on AppStore.
* @param int $limit The maximum number of reviews to retrieve. Default is 100.
* @param string $sort The sorting order of the reviews. Options include 'mosthelpful', 'newest', etc. Default is 'mosthelpful'.
* @param string|null $cutoff Optional parameter to specify the maximum timestamp for reviews.
* @param string|array $fields Optional parameter to specify which fields to return.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the reviews request or the request ID if async_request is true.
*/
public function appstore_reviews(
string|array $query,
int $limit = 100,
string $sort = 'mosthelpful',
?string $cutoff = null,
string|array $fields = '',
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'sort' => $sort,
'cutoff' => $cutoff,
'fields' => $fields,
'async' => $async_request,
]);
$result = $this->make_get_request("appstore/reviews?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Retrieve YouTube comments.
*
* @param string|array $query The query or queries to search for on YouTube.
* @param int $per_query The maximum number of comments to retrieve per query. Default is 100.
* @param string $language The language to use for the search. Default is 'en'.
* @param string $region The region to use for the search. Default is empty string.
* @param string|array $fields Optional parameter to specify which fields to return. Default is empty string.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the comments request or the request ID if async_request is true.
*/
public function youtube_comments(
string|array $query,
int $per_query = 100,
string $language = 'en',
string $region = '',
string|array $fields = '',
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'perQuery' => $per_query,
'language' => $language,
'region' => $region,
'fields' => $fields,
'async' => $async_request,
]);
$result = $this->make_get_request("youtube-comments?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Retrieve reviews from G2.
*
* @param string|array $query The query or queries to search for on G2. Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param int $limit The maximum number of reviews to retrieve. Default is 100.
* @param string $sort The sorting order of the reviews. Default is empty string.
* @param string|null $cutoff Optional parameter to specify the maximum timestamp for reviews.
* @param string|array|null $fields Optional parameter to specify which fields to return.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the reviews request or the request ID if async_request is true.
*/
public function g2_reviews(
string|array $query,
int $limit = 100,
string $sort = '',
?string $cutoff = null,
string|array|null $fields = null,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'sort' => $sort,
'cutoff' => $cutoff,
'fields' => $fields,
'async' => $async_request,
]);
$result = $this->make_get_request("g2/reviews?{$params}");
if ($async_request) {
return $result;
}
return $this->wait_request_archive($result['id']);
}
/**
* Returns reviews from Trustpilot businesses.
*
* @param array $query Links to Trustpilot pages or domain names (e.g., outscraper.com, https://www.trustpilot.com/review/outscraper.com). Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param int $limit Parameter specifies the limit of items to get from one query.
* @param string $sort Parameter specifies one of the sorting types (e.g., recency).
* @param int $cutoff Parameter specifies the oldest timestamp value for items. Using the cutoff parameter overwrites sort parameter`. Therefore, the latest records will be at the beginning (newest first).
*
* @return array request/task result
*/
public function trustpilot_reviews(array $query, int $limit = 100, ?string $sort = NULL, ?int $cutoff = NULL) : array {
$params = http_build_query(array(
"query" => $query,
"limit" => $limit,
"sort" => $sort,
"cutoff" => $cutoff,
));
$result = $this->make_get_request("trustpilot/reviews?{$params}");
return $this->wait_request_archive($result["id"]);
}
/**
* Retrieve reviews from Glassdoor.
*
* @param string|array $query The query or queries to search for on Glassdoor.
* @param int $limit The maximum number of reviews to retrieve. Default is 100.
* @param string $sort The sorting order of the reviews. Default is 'DATE'.
* @param string|null $cutoff Optional parameter to specify the maximum timestamp for reviews.
* @param bool $async_request Whether to run the request asynchronously. Default is false.
*
* @return array The result of the reviews request or the request ID if async_request is true.
*/
public function glassdoor_reviews(
string|array $query,
int $limit = 100,
string $sort = 'DATE',
?string $cutoff = null,
bool $async_request = false
): array {
$params = http_build_query([
'query' => (array) $query,
'limit' => $limit,
'sort' => $sort,
'cutoff'=> $cutoff,
'async' => $async_request,