File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed
functions/technologies/libs Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,40 @@ APIs for the HTTP Archive Technology Report
17
17
18
18
### Endpoitns
19
19
20
+ ` GET /technologies `
21
+
22
+ #### Parameters
23
+
24
+ The following parameters can be used to filter the data:
25
+
26
+ - ` technology ` (` required ` ): A comma-separated string representing the technology name(s).
27
+ - ` start ` (optional): A string representing the start date in the format ` YYYY-MM-DD ` .
28
+ - ` end ` (optional): A string representing the end date in the format ` YYYY-MM-DD ` .
29
+ - ` geo ` (optional): A string representing the geographic location.
30
+ - ` rank ` (optional): An string representing the rank.
31
+ - ` category ` (optional): A comma-separated string representing the category name(s).
32
+
33
+ #### Response
34
+
35
+ ``` bash
36
+ curl --request GET \
37
+ --url ' https://{HOST}/v1/technologies?start=2022-02-01&end=2022-04-01&technology=Smartsupp&client=mobile'
38
+ ```
39
+
40
+
41
+ Returns a JSON object with the following schema:
42
+
43
+ ``` json
44
+ [
45
+ {
46
+ "client" : " mobile" ,
47
+ "similar_technologies" : null ,
48
+ "date" : " 2022-02-01" ,
49
+ "description" : " Smartsupp is a live chat tool that offers visitor recording feature." ,
50
+ "technology" : " Smartsupp" ,
51
+ "category" : " Live chat" ,
52
+ "origins" : 16840
53
+ },
54
+ ...
55
+ ]
56
+ ```
Original file line number Diff line number Diff line change 2
2
import json
3
3
from google .cloud import firestore
4
4
from .result import Result
5
+ from .utils import convert_to_array
5
6
6
7
DB = firestore .Client (project = os .environ .get ('PROJECT' ))
7
8
@@ -10,19 +11,20 @@ def list_data(params):
10
11
11
12
query = ref
12
13
print ("params" , params )
14
+
13
15
if 'start' in params :
14
16
query = query .where ('date' , '>=' , params ['start' ])
15
17
if 'end' in params :
16
18
query = query .where ('date' , '<=' , params ['end' ])
17
19
if 'geo' in params :
18
20
query = query .where ('geo' , '==' , params ['geo' ])
19
21
if 'technology' in params :
20
- params_array = json . loads (params ['technology' ])
22
+ params_array = convert_to_array (params ['technology' ])
21
23
query = query .where ('technology' , 'in' , params_array )
22
24
if 'rank' in params :
23
25
query = query .where ('rank' , '==' , params ['rank' ])
24
26
if 'category' in params :
25
- params_array = json . loads (params ['category' ])
27
+ params_array = convert_to_array (params ['category' ])
26
28
query = query .where ('category' , 'in' , params_array )
27
29
28
30
documents = query .stream ()
Original file line number Diff line number Diff line change @@ -11,3 +11,7 @@ def convert_to_hashes(arr):
11
11
hash_dict = {inner_arr [0 ]: inner_arr [1 ]}
12
12
hashes_arr .append (hash_dict )
13
13
return hashes_arr
14
+
15
+ def convert_to_array (data_string ):
16
+ list = data_string .split (',' )
17
+ return list
You can’t perform that action at this time.
0 commit comments