This repository was archived by the owner on Sep 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
2248 lines (2075 loc) · 102 KB
/
index.html
File metadata and controls
2248 lines (2075 loc) · 102 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Zetascan - API Reference - v2.0</title>
<style>
.highlight table td { padding: 5px; }
.highlight table pre { margin: 0; }
.highlight .gh {
color: #999999;
}
.highlight .sr {
color: #f6aa11;
}
.highlight .go {
color: #888888;
}
.highlight .gp {
color: #555555;
}
.highlight .gs {
}
.highlight .gu {
color: #aaaaaa;
}
.highlight .nb {
color: #f6aa11;
}
.highlight .cm {
color: #75715e;
}
.highlight .cp {
color: #75715e;
}
.highlight .c1 {
color: #75715e;
}
.highlight .cs {
color: #75715e;
}
.highlight .c, .highlight .cd {
color: #75715e;
}
.highlight .err {
color: #960050;
}
.highlight .gr {
color: #960050;
}
.highlight .gt {
color: #960050;
}
.highlight .gd {
color: #49483e;
}
.highlight .gi {
color: #49483e;
}
.highlight .ge {
color: #49483e;
}
.highlight .kc {
color: #66d9ef;
}
.highlight .kd {
color: #66d9ef;
}
.highlight .kr {
color: #66d9ef;
}
.highlight .no {
color: #66d9ef;
}
.highlight .kt {
color: #66d9ef;
}
.highlight .mf {
color: #ae81ff;
}
.highlight .mh {
color: #ae81ff;
}
.highlight .il {
color: #ae81ff;
}
.highlight .mi {
color: #ae81ff;
}
.highlight .mo {
color: #ae81ff;
}
.highlight .m, .highlight .mb, .highlight .mx {
color: #ae81ff;
}
.highlight .sc {
color: #ae81ff;
}
.highlight .se {
color: #ae81ff;
}
.highlight .ss {
color: #ae81ff;
}
.highlight .sd {
color: #e6db74;
}
.highlight .s2 {
color: #e6db74;
}
.highlight .sb {
color: #e6db74;
}
.highlight .sh {
color: #e6db74;
}
.highlight .si {
color: #e6db74;
}
.highlight .sx {
color: #e6db74;
}
.highlight .s1 {
color: #e6db74;
}
.highlight .s {
color: #e6db74;
}
.highlight .na {
color: #a6e22e;
}
.highlight .nc {
color: #a6e22e;
}
.highlight .nd {
color: #a6e22e;
}
.highlight .ne {
color: #a6e22e;
}
.highlight .nf {
color: #a6e22e;
}
.highlight .vc {
color: #ffffff;
}
.highlight .nn {
color: #ffffff;
}
.highlight .nl {
color: #ffffff;
}
.highlight .ni {
color: #ffffff;
}
.highlight .bp {
color: #ffffff;
}
.highlight .vg {
color: #ffffff;
}
.highlight .vi {
color: #ffffff;
}
.highlight .nv {
color: #ffffff;
}
.highlight .w {
color: #ffffff;
}
.highlight {
color: #ffffff;
}
.highlight .n, .highlight .py, .highlight .nx {
color: #ffffff;
}
.highlight .ow {
color: #f92672;
}
.highlight .nt {
color: #f92672;
}
.highlight .k, .highlight .kv {
color: #f92672;
}
.highlight .kn {
color: #f92672;
}
.highlight .kp {
color: #f92672;
}
.highlight .o {
color: #f92672;
}
</style>
<link href="stylesheets/screen.css" rel="stylesheet" media="screen" />
<link href="stylesheets/print.css" rel="stylesheet" media="print" />
<script src="javascripts/all.js"></script>
</head>
<body class="index" data-languages="["shell","php"]">
<a href="#" id="nav-button">
<span>
NAV
<img src="images/navbar.png" alt="Navbar" />
</span>
</a>
<div class="toc-wrapper">
<img src="images/logo.png" class="logo" alt="Logo" />
<div class="lang-selector">
<a href="#" data-language-name="shell">shell</a>
<a href="#" data-language-name="php">php</a>
</div>
<div class="search">
<input type="text" class="search" id="input-search" placeholder="Search">
</div>
<ul class="search-results"></ul>
<div id="toc" class="toc-list-h1">
<li>
<a href="#api-introduction" class="toc-h1 toc-link" data-title="API Introduction">API Introduction</a>
</li>
<li>
<a href="#developer-library" class="toc-h1 toc-link" data-title="Developer library">Developer library</a>
</li>
<li>
<a href="#authentication" class="toc-h1 toc-link" data-title="Authentication">Authentication</a>
<ul class="toc-list-h2">
<li>
<a href="#api-key" class="toc-h2 toc-link" data-title="Authentication">API key</a>
</li>
<li>
<a href="#ip-authentication" class="toc-h2 toc-link" data-title="Authentication">IP authentication</a>
</li>
<li>
<a href="#checking-authentication" class="toc-h2 toc-link" data-title="Authentication">Checking authentication</a>
</li>
</ul>
</li>
<li>
<a href="#api-overview" class="toc-h1 toc-link" data-title="API Overview">API Overview</a>
<ul class="toc-list-h2">
<li>
<a href="#query-formats" class="toc-h2 toc-link" data-title="API Overview">Query formats</a>
</li>
<li>
<a href="#score-calculation" class="toc-h2 toc-link" data-title="API Overview">Score calculation</a>
</li>
<li>
<a href="#test-cases" class="toc-h2 toc-link" data-title="API Overview">Test Cases</a>
</li>
<li>
<a href="#error-handling" class="toc-h2 toc-link" data-title="API Overview">Error handling</a>
</li>
</ul>
</li>
<li>
<a href="#data-sources" class="toc-h1 toc-link" data-title="Data Sources">Data Sources</a>
<ul class="toc-list-h2">
<li>
<a href="#ip-addresses-sources" class="toc-h2 toc-link" data-title="Data Sources">IP Addresses sources</a>
</li>
<li>
<a href="#domains-sources" class="toc-h2 toc-link" data-title="Data Sources">Domains sources</a>
</li>
</ul>
</li>
<li>
<a href="#http-format" class="toc-h1 toc-link" data-title="HTTP Format">HTTP Format</a>
<ul class="toc-list-h2">
<li>
<a href="#response-headers" class="toc-h2 toc-link" data-title="HTTP Format">Response headers</a>
</li>
<li>
<a href="#error-handling-2" class="toc-h2 toc-link" data-title="HTTP Format">Error handling</a>
</li>
<li>
<a href="#multiple-items" class="toc-h2 toc-link" data-title="HTTP Format">Multiple items</a>
</li>
</ul>
</li>
<li>
<a href="#text-format" class="toc-h1 toc-link" data-title="Text Format">Text Format</a>
<ul class="toc-list-h2">
<li>
<a href="#format" class="toc-h2 toc-link" data-title="Text Format">Format</a>
</li>
<li>
<a href="#error-handling-3" class="toc-h2 toc-link" data-title="Text Format">Error handling</a>
</li>
<li>
<a href="#multiple-items-2" class="toc-h2 toc-link" data-title="Text Format">Multiple items</a>
</li>
</ul>
</li>
<li>
<a href="#json-format" class="toc-h1 toc-link" data-title="JSON Format">JSON Format</a>
<ul class="toc-list-h2">
<li>
<a href="#json-response" class="toc-h2 toc-link" data-title="JSON Format">JSON response</a>
</li>
<li>
<a href="#error-handling-4" class="toc-h2 toc-link" data-title="JSON Format">Error handling</a>
</li>
<li>
<a href="#multiple-items-3" class="toc-h2 toc-link" data-title="JSON Format">Multiple items</a>
</li>
</ul>
</li>
<li>
<a href="#jsonx-format" class="toc-h1 toc-link" data-title="JSONx Format">JSONx Format</a>
<ul class="toc-list-h2">
<li>
<a href="#jsonx-response" class="toc-h2 toc-link" data-title="JSONx Format">JSONx response</a>
</li>
<li>
<a href="#extended-element" class="toc-h2 toc-link" data-title="JSONx Format">Extended element</a>
</li>
<li>
<a href="#extended-smtp" class="toc-h2 toc-link" data-title="JSONx Format">Extended - SMTP</a>
</li>
<li>
<a href="#extendedsecl-element" class="toc-h2 toc-link" data-title="JSONx Format">ExtendedSecl element</a>
</li>
<li>
<a href="#error-handling-5" class="toc-h2 toc-link" data-title="JSONx Format">Error handling</a>
</li>
<li>
<a href="#multiple-items-4" class="toc-h2 toc-link" data-title="JSONx Format">Multiple items</a>
</li>
</ul>
</li>
<li>
<a href="#fqdn-queries" class="toc-h1 toc-link" data-title="FQDN Queries">FQDN Queries</a>
</li>
<li>
<a href="#dnswl-data-format" class="toc-h1 toc-link" data-title="DNSWL data format">DNSWL data format</a>
</li>
<li>
<a href="#browser-access" class="toc-h1 toc-link" data-title="Browser access">Browser access</a>
</li>
<li>
<a href="#dns-api" class="toc-h1 toc-link" data-title="DNS API">DNS API</a>
<ul class="toc-list-h2">
<li>
<a href="#lookup-access" class="toc-h2 toc-link" data-title="DNS API">Lookup access</a>
</li>
<li>
<a href="#domain-query" class="toc-h2 toc-link" data-title="DNS API">Domain query</a>
</li>
<li>
<a href="#direct-access" class="toc-h2 toc-link" data-title="DNS API">Direct access</a>
</li>
</ul>
</li>
<li>
<a href="#dns-response-codes" class="toc-h1 toc-link" data-title="DNS Response codes">DNS Response codes</a>
<ul class="toc-list-h2">
<li>
<a href="#txt-format" class="toc-h2 toc-link" data-title="DNS Response codes">TXT format</a>
</li>
<li>
<a href="#a-aaaa-ptr-format" class="toc-h2 toc-link" data-title="DNS Response codes">A, AAAA, PTR format</a>
</li>
<li>
<a href="#ipv6-responses" class="toc-h2 toc-link" data-title="DNS Response codes">IPv6 Responses</a>
</li>
</ul>
</li>
<li>
<a href="#scoring-factors" class="toc-h1 toc-link" data-title="Scoring factors">Scoring factors</a>
<ul class="toc-list-h2">
<li>
<a href="#providers" class="toc-h2 toc-link" data-title="Scoring factors">Providers</a>
</li>
<li>
<a href="#multiple-matches" class="toc-h2 toc-link" data-title="Scoring factors">Multiple matches</a>
</li>
<li>
<a href="#propagation" class="toc-h2 toc-link" data-title="Scoring factors">Propagation</a>
</li>
</ul>
</li>
<li>
<a href="#code-snippets" class="toc-h1 toc-link" data-title="Code snippets">Code snippets</a>
<ul class="toc-list-h2">
<li>
<a href="#python" class="toc-h2 toc-link" data-title="Code snippets">Python</a>
</li>
<li>
<a href="#node-js" class="toc-h2 toc-link" data-title="Code snippets">Node.js</a>
</li>
<li>
<a href="#javascript" class="toc-h2 toc-link" data-title="Code snippets">Javascript</a>
</li>
</ul>
</li>
</div>
<ul class="toc-footer">
<li><a href='https://zetascan.com/signup/?lang=en'>Sign Up for a Developer Key</a></li>
</ul>
</div>
<div class="page-wrapper">
<div class="dark-box"></div>
<div class="content">
<h1 id='api-introduction'>API Introduction</h1>
<blockquote>
<p>API endpoint:</p>
</blockquote>
<pre class="highlight plaintext"><code>https://api.zetascan.com/
</code></pre>
<p>The Zetascan Query Services <code>"ZQS"</code> was created to facilitate the real-time lookup of IP and Domain threat data into various applications and services. Currently there are dozens of various domain and IP data-feeds available to developers. Many of these feeds are available free of charge and some are paid for services when minimum query levels are exceeded. In addition, there are 2 main problems with trying to incorporate multiple data feed into a solution:</p>
<ol>
<li><p>The overlap between data feed providers in the content listed (IPs & URIs), and</p></li>
<li><p>The absence of normalized meta-data related to the IPs or Domains.</p></li>
</ol>
<p>Because of the above, many developers asked if we could do something to reduce the complexity related to accessing and using threat data as part of their applications - ZQS is our solution. We are introducing a <em>more elegant API for developers</em>, with an affordable pricing model to match.</p>
<p>To start, <a href="https://zetascan.com/signup/?lang=en">signup for a developer key</a> and begin to integrate ZQS into your web-apps and mobile applications. A free-trial for 5,000 API queries is available for a 60-day period.</p>
<h1 id='developer-library'>Developer library</h1>
<p>To ease implementation Zetascan provides developer libraries in various languages. This provides a straightforward way to add ZQS support into your application.</p>
<ul>
<li><a href="https://github.com/zetascan/go-zetascan">Go library</a>
<ul>
<li>HTTP, text, JSON and JSONx support</li>
<li>Support for DNS lookups</li>
<li>Example code provided</li>
</ul></li>
<li><a href="https://github.com/zetascan/php-zetascan">PHP library</a>
<ul>
<li>HTTP, text, JSON and JSONx support </li>
</ul></li>
<li>Python and NodeJS library, coming soon.</li>
</ul>
<h1 id='authentication'>Authentication</h1>
<p>Authentication to ZQS can be provided via an API key, or by specifying your servers' static IP address.</p>
<h3 id='api-key'>API key</h3><pre class="highlight shell tab-shell"><code>curl https://api.zetascan.com/?key<span class="o">=</span>YOURAPIKEY
</code></pre><pre class="highlight php tab-php"><code><span class="cp"><?</span>
<span class="nv">$ch</span> <span class="o">=</span> <span class="nb">curl_init</span><span class="p">();</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_URL</span><span class="p">,</span> <span class="s1">'https://api.zetascan.com/?key=YOURAPIKEY'</span><span class="p">);</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_RETURNTRANSFER</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="nv">$response</span> <span class="o">=</span> <span class="nb">curl_exec</span><span class="p">(</span><span class="nv">$ch</span><span class="p">);</span>
<span class="cp">?></span>
</code></pre>
<blockquote>
<p>Make sure to replace <code>YOURAPIKEY</code> with your API key.</p>
</blockquote>
<p>To query the ZQS an API key can be specified as an argument. No API key? <a href="https://zetascan.com/signup/?lang=en">Signup and receive</a> a key instantly. </p>
<p>ZQS uses API keys to allow access to the service, and expects the API key to be included in all requests, if IP authentication is not provided.</p>
<aside class="notice">
Zetascan only accepts the API key using SSL/https. If using the http interface without SSL, IP authentication must be used.
</aside>
<h3 id='ip-authentication'>IP authentication</h3>
<p>Alternatively, authentication to ZQS can be allowed by providing your servers' IP address via the <a href="https://zetascan.com/dashboard/?lang=en">Zetascan dashboard</a>.</p>
<h3 id='checking-authentication'>Checking authentication</h3><pre class="highlight shell tab-shell"><code>IP Address:
curl https://api.zetascan.com/v2/check/auth
API Key:
curl https://api.zetascan.com/v2/check/auth?key<span class="o">=</span>YOURAPIKEY
</code></pre>
<p>We provide a simple method to check if your requests will be allowed from a given IP or with your API key.
You'll get either 'Authorized' or 'Not Authorized'.</p>
<h1 id='api-overview'>API Overview</h1><h2 id='query-formats'>Query formats</h2>
<blockquote>
<p>Query end-points include 4 formatting options:</p>
</blockquote>
<pre class="highlight plaintext"><code>https://api.zetascan.com/v2/check/http/
</code></pre><pre class="highlight plaintext"><code>https://api.zetascan.com/v2/check/text/
</code></pre><pre class="highlight plaintext"><code>https://api.zetascan.com/v2/check/json/
</code></pre><pre class="highlight plaintext"><code>https://api.zetascan.com/v2/check/jsonx/
</code></pre>
<p>You can issue requests to our endpoints from virtually any operating system or programming language. REST queries are extremely fast and provide the richest set of information about an item.</p>
<p>Each client has a unique access key, generated by the system. You need to provide this key, if querying from an unregistered static IP address.</p>
<p>There are four types of REST queries:</p>
<ul>
<li>HTTP - response is returned in HTTP headers</li>
<li>Text - clear text response (comma, semicolon and space delimitated)</li>
<li>JSON - JSON-formatted document</li>
<li>JSONx - JSON-formatted document with additional (eXtended) data about items.</li>
</ul>
<p>The type of desired query is passed in the HTTP request.
The version of the API is now v2. We are constantly adding new features to the API, and increase the API version number. You can use the latest version (recommended), or stick with a previous one.</p>
<ul>
<li><a href="#dns-api">DNS Queries</a> are another fast and effective way to query ZQS. Using DNS TXT Queries you can get the same response as with a REST TEXT request.</li>
</ul>
<h2 id='score-calculation'>Score calculation</h2>
<p>ZQS provides two scoring mechanisms to grade an IP or domain-name for abuse, anti-spam measures and trustworthiness. </p>
<p>A negative score, like <code>-0.1</code>, means that an item was matched on a known trusted white-list.</p>
<p>If a score is <code>0</code>, the item is not found within Zetascan and can be considered neutral.</p>
<p>A score between <code>0 - 1.0</code> is a rating on the specified domain or IP address. Scores above <code>0.35</code> should be considered as spam or fraudulent.</p>
<p>Reference the <a href="#data-sources">data sources</a> chapter for more information on feeds used to calculate the scores.
See the <a href="#scoring-factors">Scoring Factors</a> section for exact values and logic used when generating item's score.</p>
<h3 id='webscore'>webscore</h3>
<p>Webscore is returned by all query methods, except DNS A and AAAA queries.
It is used to determine a score for integrating your web-application, mobile-app or protecting your application infrastructure.</p>
<h3 id='score'>score</h3>
<p>Score is also returned by all query methods, and it used to check a specified IP or domain-name for anti-spam abuse via SMTP, useful for MTA and spam-filters. This score takes into consideration email abuse, and uses a different algorithm from the 'webscore' key.</p>
<h2 id='test-cases'>Test Cases</h2><h3 id='ip-addresses'>IP Addresses</h3>
<p>We provide four IPv4 and four IPv6 addresses, which will always return the same answers. Use these for testing and development:</p>
<ul>
<li><code>127.9.9.1</code> - returning as if found in SBL, XBL & CBL</li>
<li><code>127.9.9.2</code> - returning as if in PBL</li>
<li><code>127.9.9.3</code> - returning as if in SBL subnet</li>
<li><code>127.9.9.4</code> - good IP, found in Return Path White List and DNSWL, also contains DNSWL White List data</li>
<li><code>::1, ::2, ::3, ::4</code> - returning as above for IPv6, except for ::2, which is found both in PBL and DNSWL (example of a false positive)</li>
</ul>
<h3 id='domains'>Domains</h3>
<p>We provide two testing domains:</p>
<ul>
<li><p><code>baddomain.org</code> - returns as if found in all domain DB's: DBL and all URIBL</p></li>
<li><p><code>okdomain.org</code> - returns as if found in White List(s).</p></li>
</ul>
<h2 id='error-handling'>Error handling</h2>
<p>When querying ZQS, the following error-codes will be returned if the query or authentication failed. Each query format (Text, HTTP, JSON/JSONx) will embed any error messages in the returned data. Examples on handling errors will be provided for each query format example.</p>
<h3 id='error-codes'>Error codes</h3>
<p><code>1</code> - HTTP 404 - Invalid request - the REST path was wrong, e.g. /v2/check/gson/domain.com (gson instead of json). It appears in the message body and in the
x-zetascan-error header. This is the only error that appears like that,
others appears in the specified format as per the documentation.</p>
<p><code>2</code> - HTTP 404 - Missing IP/Domain argument</p>
<p><code>3</code> - HTTP 404 - Failed to parse query's item</p>
<p><code>4</code> - HTTP 403 - HTTPS required to supply API key</p>
<p><code>5</code> - HTTP 403 - Not authorized (request to invalid host, route, port or method, or API method not supported)</p>
<p><code>6</code> - HTTP 403 - Not authorized (request from invalid IP address or with invalid key)</p>
<p><code>7</code> - HTTP 403 - Wrong API Key supplied</p>
<p><code>8</code> - HTTP 404 - HTTP GET request required for queries</p>
<p><code>9</code> - HTTP 403 - Query limit exceeded</p>
<h1 id='data-sources'>Data Sources</h1>
<p>Currently we derive our results from several providers, including:</p>
<ul>
<li>Spamhaus</li>
<li>Spamhaus real time stream - DBL, SBL and ZRD </li>
<li>URIBL - different levels of Domain Black Lists and a Domain White List</li>
<li>DNSWL - IP addresses White List</li>
<li>Return Path - IP addresses and Domains White Lists (black list coming soon)</li>
<li>Seclytics - Threat lists for IP addresses with categorization</li>
<li>Vade Secure - Domains black list</li>
</ul>
<aside class="notice">
URIBL data can be also used for spam detection, based on URLs (links) inside message body.
</aside>
<p>We also apply internal algorithms for de-duplicating, normalizing and scoring each item in our database, providing a seamless and reliable API end-point for your application.</p>
<p>ZQS queries are answered in less than 1 millisecond, and expect no longer then 10 milliseconds for a query reply.</p>
<p>All our sources are updated at very frequent intervals. We are also using real-time streams, so you may rest assured that you get the latest information from ZQS.</p>
<aside class="notice">
An ZQS virtual appliance is also available for on-premises installation for super-fast access. Please contact us for details about that option.
</aside>
<h2 id='ip-addresses-sources'>IP Addresses sources</h2>
<p>We aggregate data from several data streams: </p>
<ul>
<li>Spamhaus PBL</li>
<li>SBL</li>
<li>XBL</li>
<li>CBL</li>
<li>Spamhaus Real-time stream.</li>
<li>DNSWL IP addresses White List</li>
<li>Return Path IP addresses White List</li>
<li>Seclytics Black Lists</li>
</ul>
<p>On the other hand, we have also information about White Lists presence of IP address, for example DNSWL.</p>
<p>Unlike other lists, ZQS analyzes the data about each IP address and provides normalized, de-duplicated, and pre-processed information about each IP address, containing internally calculated score (reputation), last modified timestamp, list of BL / WL where the item appears, etc.</p>
<h2 id='domains-sources'>Domains sources</h2>
<p>At this stage we aggregate data from two main Domain providers:</p>
<ul>
<li>Spamhaus DBL Black List</li>
<li>Real-time Spamhaus ZRD (Zero Reputation Domains) list</li>
<li>URIBL Black Lists</li>
<li>Vade Secure Black List</li>
<li>URIBL White List</li>
<li>Return Path White List</li>
</ul>
<p>More providers will be added in the near future. Stay tuned!</p>
<h1 id='http-format'>HTTP Format</h1><pre class="highlight shell tab-shell"><code>curl -i https://api.zetascan.com/v2/check/http/baddomain.org?key<span class="o">=</span>YOURAPIKEY
HTTP/1.1 200 OK
Content-Type: text/plain; <span class="nv">charset</span><span class="o">=</span>utf-8
x-zetascan-items: baddomain.org
x-zetascan-status: success
x-zetascan-score: 1
x-zetascan-sources: DBL;RED;GREY;GOLD;BLACK
x-zetascan-wl: null
x-zetascan-time: 1500970900
x-zetascan-webscore: 0.6
x-zetascan-fromParent: null
</code></pre><pre class="highlight php tab-php"><code><span class="cp"><?</span>
<span class="nv">$ch</span> <span class="o">=</span> <span class="nb">curl_init</span><span class="p">();</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_URL</span><span class="p">,</span> <span class="s1">'https://api.zetascan.com/v2/check/http/baddomain.org?key=YOURAPIKEY'</span><span class="p">);</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_RETURNTRANSFER</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="c1">// Request headers only
</span><span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_HEADER</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_NOBODY</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="nv">$response</span> <span class="o">=</span> <span class="nb">curl_exec</span><span class="p">(</span><span class="nv">$ch</span><span class="p">);</span>
<span class="c1">// Lookup the HTTP status code
</span><span class="nv">$status</span> <span class="o">=</span> <span class="nb">curl_getinfo</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLINFO_HTTP_CODE</span><span class="p">);</span>
<span class="c1">// Check status codes for a match
</span><span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">204</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"No match in Zetascan blacklist or white-list"</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">403</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Request forbidden, check API-key or IP registered"</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">200</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$headers</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$data</span> <span class="o">=</span> <span class="nb">explode</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span><span class="nv">$response</span><span class="p">);</span>
<span class="nv">$headers</span><span class="p">[</span><span class="s1">'status'</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$data</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="c1">// Take the HTTP response out, first element
</span> <span class="nb">array_shift</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
<span class="c1">// Build an array for our headers
</span> <span class="k">foreach</span><span class="p">(</span><span class="nv">$data</span> <span class="k">as</span> <span class="nv">$part</span><span class="p">){</span>
<span class="nv">$middle</span><span class="o">=</span><span class="nb">explode</span><span class="p">(</span><span class="s2">":"</span><span class="p">,</span><span class="nv">$part</span><span class="p">);</span>
<span class="nv">$headers</span><span class="p">[</span><span class="nb">trim</span><span class="p">(</span><span class="nv">$middle</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span> <span class="o">=</span> <span class="nb">trim</span><span class="p">(</span><span class="nv">$middle</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span>
<span class="p">}</span>
<span class="c1">// Display the score if blacklisted, otherwise if a whitelist
</span> <span class="k">if</span><span class="p">(</span> <span class="nv">$headers</span><span class="p">[</span><span class="nx">x</span><span class="o">-</span><span class="nx">zetascan</span><span class="o">-</span><span class="nx">score</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span> <span class="o">||</span> <span class="nv">$headers</span><span class="p">[</span><span class="nx">x</span><span class="o">-</span><span class="nx">zetascan</span><span class="o">-</span><span class="nx">webscore</span><span class="p">]</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Item blacklisted, score "</span> <span class="o">.</span> <span class="nv">$headers</span><span class="p">[</span><span class="nx">x</span><span class="o">-</span><span class="nx">zetascan</span><span class="o">-</span><span class="nx">score</span><span class="p">]</span> <span class="o">.</span> <span class="s2">" webscore "</span> <span class="o">.</span> <span class="nv">$headers</span><span class="p">[</span><span class="nx">x</span><span class="o">-</span><span class="nx">zetascan</span><span class="o">-</span><span class="nx">webscore</span><span class="p">];</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Item white-listed"</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="cp">?></span>
</code></pre>
<p>HTTP returns a very simple response - found or not, via HTTP response code. If found, the response will be 200 (OK).</p>
<p>If the item is not present in any black-list/white-list, then the answer will be 204 (No Content).</p>
<p>Additional information about the item is found in the response headers. </p>
<h3 id='response-headers'>Response headers</h3>
<p>If the query matches, the following HTTP headers will be supplied for additional information.</p>
<blockquote>
<p>Example HTTP header response:</p>
</blockquote>
<pre class="highlight plaintext"><code>x-zetascan-items:querydomain.org
x-zetascan-score:1
x-zetascan-webscore:0.6
x-zetascan-sources:DBL;RED;GREY;GOLD;BLACK
x-zetascan-time:1500970900
x-zetascan-wl:null
x-zetascan-status:success
</code></pre>
<table><thead>
<tr>
<th>HTTP Header</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>x-zetascan-items</td>
<td>The argument used to query ZQS</td>
</tr>
<tr>
<td>x-zetascan-score</td>
<td>The score returned for the query, used for MTA and SMTP anti-spam measures</td>
</tr>
<tr>
<td>x-zetascan-webscore</td>
<td>The score returned for the query, used for Web and application anti-abuse. Note the differences between web-score and score, see the score calculation for more information.</td>
</tr>
<tr>
<td>x-zetascan-sources</td>
<td>A list of sources the query is obtained from, delimitated by a semicolon. See the <a href="#domains-sources">source references</a> for more information.</td>
</tr>
<tr>
<td>x-zetascan-time</td>
<td>EPOCH time of response for the query</td>
</tr>
<tr>
<td>x-zetascan-wl</td>
<td>A list of sources matched if the query is listed in a white-list.</td>
</tr>
<tr>
<td>x-zetascan-status</td>
<td>Returns "success", otherwise "forbidden" or "error"</td>
</tr>
</tbody></table>
<h3 id='error-handling-2'>Error handling</h3>
<blockquote>
<p>Example HTTP error response:</p>
</blockquote>
<pre class="highlight plaintext"><code>x-zetascan-errorCode:7
x-zetascan-errorMessage:Wrong API Key
x-zetascan-status:forbidden
</code></pre>
<table><thead>
<tr>
<th>HTTP Header</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>x-zetascan-errorCode</td>
<td>The returned error-code. If present, the query has failed.</td>
</tr>
<tr>
<td>x-zetascan-errorMessage</td>
<td>A detailed explanation of the failure</td>
</tr>
<tr>
<td>x-zetascan-status</td>
<td>Returns "forbidden" if authentication denied, or "error" for all other error codes.</td>
</tr>
</tbody></table>
<h2 id='multiple-items'>Multiple items</h2>
<blockquote>
<p>http://api.zetascan.com/v2/check/http/127.9.9.1,127.9.9.2</p>
</blockquote>
<pre class="highlight plaintext"><code>x-zetascan-items: 127.9.9.1,127.9.9.2
x-zetascan-status: success,success
x-zetascan-score: 0.95,0.2
x-zetascan-sources: XBL;SBL,PBL
x-zetascan-wl: null,null
x-zetascan-time: 1500970900,1500970900
x-zetascan-webscore: 0.6,null
x-zetascan-fromParent: null,null
</code></pre>
<p>You can send multiple items in a single request by sedning a comma-separated list of IP's or domains. This will speed up the overall time for answering your query.</p>
<p>The HTTP headers will contain a response for each query, as a comma-separated list in the same sequence as in the query.</p>
<h1 id='text-format'>Text Format</h1><pre class="highlight shell tab-shell"><code>curl https://api.zetascan.com/v2/check/text/baddomain.org?key<span class="o">=</span>YOURAPIKEY
</code></pre><pre class="highlight php tab-php"><code><span class="cp"><?</span>
<span class="c1">// Text method
</span><span class="nv">$ch</span> <span class="o">=</span> <span class="nb">curl_init</span><span class="p">();</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_URL</span><span class="p">,</span> <span class="s1">'https://api.zetascan.com/v2/check/text/baddomain.org?key=YOURAPIKEY'</span><span class="p">);</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_RETURNTRANSFER</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="nv">$response</span> <span class="o">=</span> <span class="nb">curl_exec</span><span class="p">(</span><span class="nv">$ch</span><span class="p">);</span>
<span class="c1">// Lookup the HTTP status code
</span><span class="nv">$status</span> <span class="o">=</span> <span class="nb">curl_getinfo</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLINFO_HTTP_CODE</span><span class="p">);</span>
<span class="c1">// Check status codes for a match
</span><span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">204</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"No match in Zetascan blacklist or white-list"</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">403</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Request forbidden, check API-key or IP registered"</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">200</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Read the body and split from the specified API formatting
</span> <span class="nv">$head</span> <span class="o">=</span> <span class="nb">explode</span><span class="p">(</span><span class="s2">":"</span><span class="p">,</span> <span class="nv">$response</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$head</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"error"</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"An error occurred "</span> <span class="o">.</span> <span class="nv">$head</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nv">$str</span> <span class="o">=</span> <span class="nb">explode</span><span class="p">(</span><span class="s2">","</span><span class="p">,</span> <span class="nv">$head</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span>
<span class="c1">// $str will contain each field as specified below
</span> <span class="k">echo</span> <span class="s2">"Blacklist hit => "</span> <span class="o">.</span> <span class="nv">$str</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">.</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span>
<span class="k">echo</span> <span class="s2">"Whitelist hit => "</span> <span class="o">.</span> <span class="nv">$str</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">.</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span>
<span class="k">echo</span> <span class="s2">"Whitelist data => "</span> <span class="o">.</span> <span class="nv">$str</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">.</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span>
<span class="k">echo</span> <span class="s2">"Score => "</span> <span class="o">.</span> <span class="nv">$str</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">.</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span>
<span class="k">echo</span> <span class="s2">"WebScore => "</span> <span class="o">.</span> <span class="nv">$str</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">.</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span>
<span class="k">echo</span> <span class="s2">"Sources => "</span><span class="p">;</span>
<span class="c1">// List all sources, comma separated
</span> <span class="k">for</span><span class="p">(</span><span class="nv">$i</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span> <span class="nv">$i</span> <span class="o"><</span> <span class="nb">count</span><span class="p">(</span><span class="nv">$str</span><span class="p">);</span> <span class="nv">$i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="nv">$str</span><span class="p">[</span><span class="nv">$i</span><span class="p">]</span> <span class="o">.</span> <span class="s2">","</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="cp">?></span>
</code></pre>
<blockquote>
<p>The above example returns text in the format:</p>
</blockquote>
<pre class="highlight plaintext"><code>baddomain.org:true,false,,1,0.6,dbl,red,gold,grey,black
</code></pre>
<p>TEXT returns space separated blocks of information about the lists where the item is found.</p>
<p>Text example - replace 'baddomain.com' with your query - IP or domain:</p>
<h3 id='format'>Format</h3>
<p>Items are separated by space. The format for each item is:</p>
<p><code>item;parent:bool,bool,wldata,score,webscore,source</code></p>
<p>Where:</p>
<ul>
<li>item or item;parent is the item from the request, or the item and its parent domain (<a href="#fqdn-queries">see FQDN below</a>).</li>
<li>the first bool is true, if found in any black or white list.</li>
<li>the second bool is true, if found in any white list.</li>
<li>wldata contains the data from the white list (if preent)</li>
<li>score, returns the score used for MTA/anti-spam abuse.</li>
<li>webscore, the returned score for web/application abuse.</li>
<li>sources, a comma-separated list of sources where the item was found.</li>
</ul>
<h3 id='error-handling-3'>Error handling</h3>
<p>If an error occurs using the text query, the data returned will contain the item, the string 'error', an error message and a specific error-code.</p>
<p>Example authentication error:</p>
<p><code>127.9.9.1:error:Wrong_API_Key;7</code></p>
<p>Malformed query:</p>
<p><code>127.a.b.4:error:Failed_to_parse_query's_item;3</code></p>
<h2 id='multiple-items-2'>Multiple items</h2>
<blockquote>
<p>http://api.zetascan.com/v2/check/text/127.9.9.1,127.9.9.2</p>
</blockquote>
<pre class="highlight plaintext"><code>127.9.9.1:true,false,,0.95,0.6,xbl,sbl 127.9.9.2:true,false,,0.2,0,pbl
</code></pre>
<p>You can send multiple items in a comma-separated list of IP's or domains. This will speed up the overall time for answering your query.</p>
<p>The text format will contain a response for each query, delimited by <code>space</code>.</p>
<h1 id='json-format'>JSON Format</h1><pre class="highlight shell tab-shell"><code>curl https://api.zetascan.com/v2/check/json/baddomain.org?key<span class="o">=</span> YOURAPIKEY
</code></pre><pre class="highlight php tab-php"><code><span class="cp"><?</span>
<span class="c1">// PHP example with multi-query support, error checking, and JSON data presented
</span><span class="nv">$ch</span> <span class="o">=</span> <span class="nb">curl_init</span><span class="p">();</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_URL</span><span class="p">,</span> <span class="s1">'https://api.zetascan.com/v2/check/json/baddomain.org,okdomain.org,badquery?key=YOURAPIKEY'</span><span class="p">);</span>
<span class="nb">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_RETURNTRANSFER</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="nv">$response</span> <span class="o">=</span> <span class="nb">curl_exec</span><span class="p">(</span><span class="nv">$ch</span><span class="p">);</span>
<span class="c1">// Lookup the HTTP status code
</span><span class="nv">$status</span> <span class="o">=</span> <span class="nb">curl_getinfo</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLINFO_HTTP_CODE</span><span class="p">);</span>
<span class="c1">// Check status codes for a match
</span><span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">403</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Request forbidden, check API-key or IP registered"</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="mi">200</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$json</span> <span class="o">=</span> <span class="nb">json_decode</span><span class="p">(</span><span class="nv">$response</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="c1">// Check for any error messages, auth failure, API-key incorrect, etc.
</span> <span class="k">if</span><span class="p">(</span> <span class="o">!</span><span class="k">empty</span><span class="p">(</span><span class="nv">$json</span><span class="p">[</span><span class="s2">"error"</span><span class="p">][</span><span class="s2">"message"</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"An error occurred "</span> <span class="o">.</span> <span class="nv">$json</span><span class="p">[</span><span class="s2">"error"</span><span class="p">][</span><span class="s2">"message"</span><span class="p">];</span>
<span class="p">}</span>
<span class="c1">// Loop through each response ( multiple queries can be delimitated by a comma)
</span> <span class="k">for</span><span class="p">(</span><span class="nv">$i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nv">$i</span> <span class="o"><</span> <span class="nb">count</span><span class="p">(</span><span class="nv">$json</span><span class="p">[</span><span class="s2">"results"</span><span class="p">]);</span> <span class="nv">$i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Query => "</span> <span class="o">.</span> <span class="nv">$json</span><span class="p">[</span><span class="s2">"results"</span><span class="p">][</span><span class="nv">$i</span><span class="p">][</span><span class="s2">"item"</span><span class="p">]</span> <span class="o">.</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span>
<span class="c1">// Check for an error message
</span> <span class="k">if</span><span class="p">(</span><span class="nv">$json</span><span class="p">[</span><span class="s2">"results"</span><span class="p">][</span><span class="nv">$i</span><span class="p">][</span><span class="s2">"error"</span><span class="p">])</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">"An error occurred "</span> <span class="o">.</span> <span class="nv">$json</span><span class="p">[</span><span class="s2">"results"</span><span class="p">][</span><span class="nv">$i</span><span class="p">][</span><span class="s2">"error"</span><span class="p">][</span><span class="s2">"message"</span><span class="p">]</span> <span class="o">.</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span>
<span class="k">continue</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// Display the results
</span> <span class="nb">print_r</span><span class="p">(</span><span class="nv">$json</span><span class="p">[</span><span class="s2">"results"</span><span class="p">][</span><span class="nv">$i</span><span class="p">]);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="cp">?></span>
</code></pre>
<blockquote>
<p>Example JSON return string:</p>
</blockquote>
<pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
</span><span class="s2">"results"</span><span class="p">:[{</span><span class="w">
</span><span class="s2">"item"</span><span class="p">:</span><span class="s2">"baddomain.org"</span><span class="p">,</span><span class="w">
</span><span class="s2">"found"</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="s2">"score"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
</span><span class="s2">"webscore"</span><span class="p">:</span><span class="mf">0.6</span><span class="p">,</span><span class="w">
</span><span class="s2">"fromSubnet"</span><span class="p">:</span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="s2">"sources"</span><span class="p">:</span><span class="w">
</span><span class="p">[</span><span class="s2">"shDBL"</span><span class="p">,</span><span class="s2">"ubGrey"</span><span class="p">,</span><span class="s2">"ubGold"</span><span class="p">,</span><span class="s2">"ubRed"</span><span class="p">,</span><span class="s2">"ubBlack"</span><span class="p">],</span><span class="w">
</span><span class="s2">"wl"</span><span class="p">:</span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="s2">"wldata"</span><span class="p">:</span><span class="s2">""</span><span class="p">,</span><span class="w">
</span><span class="s2">"lastModified"</span><span class="p">:</span><span class="mi">1500972200</span><span class="w">
</span><span class="p">}],</span><span class="w">
</span><span class="s2">"executionTime"</span><span class="p">:</span><span class="mi">2</span><span class="p">,</span><span class="w">
</span><span class="s2">"status"</span><span class="p">:</span><span class="s2">"success"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>The query will return a JSON response including if the item is found on a black-list/white-list, score, sources, etc. Refer to the table below for each field explanation.</p>
<aside class="notice">
The `found` key will be true, if the item is hit in a black-list or white-list. Test the `wl` condition if the item is contained within a white-list. If the score or webscore value is > 0 and `wl` false, the item is contained in a black-list.
</aside>
<h3 id='json-response'>JSON response</h3>
<table><thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>Item</td>
<td>Query value (IP or domain)</td>
</tr>
<tr>
<td>Found</td>
<td>True/False if matched in a white-list/black-list.</td>
</tr>
<tr>
<td>Score</td>
<td>Score between a negative decimal number like -0.2 to 1.0 for MTA/Anti-spam abuse. See <a href="#score-calculation">score information</a></td>
</tr>
<tr>
<td>WebScore</td>
<td>Score between a negative decimal number to 1.0 for Web/application abuse.</td>
</tr>
<tr>
<td>FromSubnet</td>
<td>Will be true, if the IP address was found in a subnet (PBL, SBL)</td>
</tr>
<tr>
<td>Sources</td>
<td>Black-Lists matched from ZQS. <a href="#data-sources">See list</a> information.</td>
</tr>
<tr>
<td>Wl</td>
<td>If the item matches a white-list.</td>
</tr>
<tr>
<td>Wldata</td>
<td>White-Lists matched from ZQS. <a href="#data-sources">See list</a> information.</td>
</tr>
<tr>
<td>ExecutionTime</td>
<td>Time in ms for server response</td>
</tr>
<tr>
<td>Status</td>
<td>Success or failure</td>
</tr>
</tbody></table>
<h3 id='error-handling-4'>Error handling</h3>
<blockquote>
<p>Example authentication error:</p>
</blockquote>
<pre class="highlight json tab-json"><code><span class="p">{</span><span class="s2">"error"</span><span class="p">:{</span><span class="s2">"message"</span><span class="p">:</span><span class="s2">"Wrong API Key"</span><span class="p">,</span><span class="s2">"errorCode"</span><span class="p">:</span><span class="mi">7</span><span class="p">}}</span><span class="w">
</span></code></pre>
<blockquote>
<p>Malformed query:</p>
</blockquote>
<pre class="highlight json tab-json"><code><span class="p">{</span><span class="s2">"results"</span><span class="p">:</span><span class="w">
</span><span class="p">[{</span><span class="s2">"item"</span><span class="p">:</span><span class="s2">"malformedquery"</span><span class="p">,</span><span class="w">
</span><span class="s2">"error"</span><span class="p">:{</span><span class="w">
</span><span class="s2">"message"</span><span class="p">:</span><span class="s2">"Failed to parse query's item"</span><span class="p">,</span><span class="w">
</span><span class="s2">"errorCode"</span><span class="p">:</span><span class="mi">3</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}],</span><span class="w">
</span><span class="err">...</span><span class="w">
</span><span class="p">}</span><span class="w">