-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathurl_api_documentation.txt
70 lines (49 loc) · 5.13 KB
/
url_api_documentation.txt
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
A quick guide on how to filter in the map and table interface by Tung:
I. TABLE FILTERING
For the table interface, which is filtering the results and displaying them in the format of a table, we use the following URL structure:
.../table/<table_name>/<param_names>/<excluded_values>/<keyword>
The "<table_name>" should be replaced by the table which you want to display. This is a required part of the URL.
The "<param_names>" is, however, optional, meaning you can leave it as empty if you want to see the entire table without any additional filter.
In case you want to do further filtering on a given table, the structure of the <param_names> is as follows:
col1=value1&col2=value2&col3=value3 <etc, add as many column-value pair as you need>
You will replace <col> by the column name you want to filter by. And the <value> is simply the value of the specified column that you want your rows to have.
One thing to keep in mind is, you can add as many column-value pairs as you want. There is no limit to that as long as the columns actually exist in the table.
If you want to use autocorrect and/or autofill, then just add those at the end of the URL:
(a) Only autocorrect: col1=value1&col2=value2&col3=value3&autocorrect=True
(b) Only autofill: col1=value1&col2=value2&col3=value3&autofill=True
(c) Both autocorrect and autofill: col1=value1&col2=value2&col3=value3&autofill=True&autocorrect=True
NOTE: If you do both autocorrect and autofill, autocorrect is always done before autofill. That is, the values will be corrected first, and then we autofill the corrected values to look for the appropriate rows.
The "<excluded_values>" is the NOT filter, and is optional. If you want to use NOT filter without using normal filter: you can specify param_names to None,
In other words, you should create your URL of this format: http://127.0.0.1:8000/table/<table_name>/None/tele=True, which will get all the rows with tele is not True.
If you want to combine NOT filter with the normal filter, try URL of this format:
http://127.0.0.1:8000/table/<table_name>/col1=value1&col2=value2&col3=value3/col4=value4&col5=value5, which will return all the rows with col1=value1, col2=value2,col3=value3, col4 NOT = value 4, col5 NOT value 5.
The "<keyword>" is the filter of a keyword that applies to all fields. For example, setting keyword to "Casa" will look for all locations with any field containing the word "Casa".
We can break down some example URLs here:
Example1: https://matchmapper-philly.herokuapp.com/table/sites_all/
Explanation: We see table as the second part of the URL, which means we want our data to be in tabular format.
Next, we set the table_name to sites_all, so our results will be the rows in this table.
Because we did not specify any further filtering, the result displayed is all rows in sites_all.
Example 2: https://matchmapper-philly.herokuapp.com/table/siterecs_samhsa_ftloc/state_usa=PA&bu=True/
Explanation: We see table as the second part of the URL, which means we want our data to be in tabular format.
Next, we set the table_name to siterecs_samhsa_ftloc, so our results will be the rows in this table.
Next, we set the param_values to state_usa=PA&bu=True, which means:
- state_usa=PA, which means that we only want the rows with state_USA being Pennsylvania (PA).
- bu=True, which means we only want the rows with bu being True.
Now, this means that we will pick all the rows in siterecs_samhsa_Ftloc that has its state as PA and its bu as True.
Example 3: https://matchmapper-philly.herokuapp.com/table/siterecs_samhsa_ftloc/name1=behavor&autocorrect=True&autofill=True/
Explanation: We see table as the second part of the URL, which means we want our data to be in tabular format.
Next, we set the table_name to siterecs_samhsa_ftloc, so our results will be the rows in this table.
Next, we set the param_values to name1 = behavor and we allow autocorrect and autofill, which means:
We will autocorrect "behavor" to "behavior" (most likely), and then we look for any rows with its name1 value CONTAINS the word "behavior" (this is what autofill does!).
Example 4: http://127.0.0.1:8000/table/siterecs_samhsa_ftloc/state_usa%3DPA&bu%3DTrue/tele=True :
Based on param_values, we choose all sites in PA, bu = True
Based on excluded values, we further choose those with tele not equal to True.
Example 5: http://127.0.0.1:8000/table/siterecs_samhsa_ftloc/None/tele=True/Casa/
Looks for all locations with tele not True and with any field containing the word "Casa".
------------------------------------------
II. MAP/GEODATA API FILTERING
For the map/geodata interface, which is filtering the results and displaying them in the format of a map/ raw locations (lat/long), we use the following URL structure:
.../map/<table_name>/<param_names>/<excluded_values>/<keyword>/ (for map interface)
.../api/geodata/<table_name>/<param_names>/<excluded_values>/<keyword> (for geodata API)
The way table_name, param_names, and excluded_values, and keyword work are exactly the same as for table filtering, so I will refer to the section above.
Map filtering/geodata filtering is only a different way of illustration of data, but the way the data are processed is the exact same.