You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+83-42Lines changed: 83 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,23 @@ The First Street Foundation API Access (Python) is a wrapper used to bulk extrac
4
4
## Installation
5
5
**NOTE**: This project requires [Python](https://www.python.org/downloads/) 3.6+ to run.
6
6
1. Install the source code manager [Git]
7
-
2. Create a new project directory
8
-
3. Open a shell and navigate to the new project directory
9
-
```sh
10
-
cd /path/to/project
11
-
```
12
-
4. Clone the [project repository](https://github.com/FirstStreet/fsf_api_access_python.git) to the new directory
7
+
2. Open `git bash` and create then navigate to a new project directory
8
+
9
+

10
+
11
+

12
+
13
+
3. Clone the project repository (https://github.com/FirstStreet/fsf_api_access_python.git) to the new directory
13
14
```sh
14
15
Example File Structure:
15
16
16
17
.
17
18
├── fsf_api_access_python
19
+
```
20
+
21
+

18
22
19
-
20
-
5. [Optional] Create and activate a new virtual environment through cmd/terminal to keep clean environments:
23
+
4. [Optional] Open a console and create and activate a new virtual environment in the project directory:
21
24
```sh
22
25
python -m venv /path/to/new/virtual/environment
23
26
@@ -26,11 +29,18 @@ The First Street Foundation API Access (Python) is a wrapper used to bulk extrac
26
29
.\venv\Scripts\activate
27
30
```
28
31
29
-
6. Run the setup script to install the project requirements
32
+

33
+
34
+

35
+
36
+
5. Run the setup script to install the project requirements
30
37
```sh
31
38
pip install .\fsf_api_access_python\.
32
39
```
33
-
7. The project is now setup and can be ran through one of the two methods below. See `Products`for details on how to extract flood data products from the API.
40
+
41
+

42
+
43
+
6. The project is now setup and can be ran through one of the two methods below. See `Products`for additional details on how to extract flood data products from the API.
34
44
```sh
35
45
Example File Structure:
36
46
@@ -42,36 +52,62 @@ The First Street Foundation API Access (Python) is a wrapper used to bulk extrac
42
52
## Method 1: Through the Client
43
53
**[Reminder] Keep your API key safe, and do not share it with others!**
44
54
45
-
1. Create a new First Street Foundation API Clientin a Python Script.
55
+
1. Create a new Python script and initialize a First Street Foundation API Client.
46
56
```python
47
57
# Contents of my_script.py
48
58
import firststreet
49
59
fs = firststreet.FirstStreet("api-key")
50
60
```
51
-
52
-
2. Call one of the methods described below in the `Products` section. See the `Examples` section for examples.
61
+
62
+
2. Call one of the methods described below in the `Products` section with the required arguments. See the `Examples` section for more examples.
**[Reminder] Keep your API key safe, and do not share it with others!**
59
75
60
76
1. [Required] Set an Environmental Variable with the variable_name as `FSF_API_KEY` and the variable_value with the API_KEY.
77
+
78
+

79
+
80
+

81
+
82
+

61
83
62
-
2. In the project directory, call one of the methods described below in the `Products` section through the command line. See the `Examples` section for examples.
84
+
2. Open a new console and navigate to the project directory. Next, call one of the methods described below in the `Products` section through the command line. See the `Examples` section for more examples.
- `-p/--product PRODUCT`: [REQUIRED] The product to call from the API
96
+
97
+
Example: ```-p location.get_detail```
98
+
71
99
- `[-i/--fsids FSIDS]`: [OPTIONAL] The FSIDs to search for with the product
100
+
101
+
Example: ```-i 541114211,541229206```
102
+
72
103
- `[-l/--location LOOKUP_TYPE]`: [OPTIONAL] The lookup location type (property, neighborhood, city, zcta, tract, county, cd, state)
104
+
105
+
Example: ```-l property```
106
+
73
107
- `[-f/--file FILE]`: [OPTIONAL] A file of FSIDs (one per line) to search for with the product
74
108
109
+
Example: ```-f sample.txt```
110
+
75
111
Content of a sample text file:
76
112
```text
77
113
541114211
@@ -81,6 +117,38 @@ The First Street Foundation API Access (Python) is a wrapper used to bulk extrac
81
117
541262690
82
118
540651172
83
119
```
120
+
121
+

122
+
123
+
## CSV File Output:
124
+
Any product above can be additionally exported to a CSV file forfurther usage if the csv boolean is set during the product call, or any call using the command line. The extracted can be foundin the `data_csv` directory of the project folder (if at least one CSV has been extracted).
125
+
126
+
127
+
### CSV File Name:
128
+
The file name will be in the format of `YYYY_MM_DD_HH_mm_SS_product_subtype_lookup.csv`.
The contents of the CSV file will follow similar formats as the `First Street Foundation API - V1.0 Overview and Dictionary`, but all lists will be expanded to a flat file. For any values that are null or not available, `<NA>` will be used.
136
+
137
+
Ex:
138
+
```csv
139
+
fsid,year,returnPeriod,bin,low,mid,high
140
+
7935,2020,20,20,<NA>,2,<NA>
141
+
7935,2020,20,50,<NA>,1,<NA>
142
+
7935,2020,20,55,<NA>,2,<NA>
143
+
7935,2020,20,65,<NA>,2,<NA>
144
+
7935,2020,20,75,<NA>,2,<NA>
145
+
7935,2020,20,95,<NA>,1,<NA>
146
+
7935,2020,20,100,<NA>,1,<NA>
147
+
...
148
+
```
149
+

150
+
151
+

84
152
85
153
## Products
86
154
### Location
@@ -149,33 +217,6 @@ environmental.<method>
149
217
```
150
218
151
219
*`get_precipitation`(fsids `list`, csv `bool`) - Returns an array of `Environmental Precipitation` product for the given county IDs, and optionally creates a csv file
152
-
153
-
## CSV File Output:
154
-
Any product above can be additionally exported to a CSV file forfurther usage if the csv boolean is set during the product call. The extracted can be foundin the `data_csv` directory of the project folder (if at least one CSV has been extracted).
155
-
156
-
157
-
### CSV File Name:
158
-
The file name will be in the format of `YYYY_MM_DD_HH_mm_SS_product_subtype_lookup.csv`.
The contents of the CSV file will follow similar formats as the `First Street Foundation API - V1.0 Overview and Dictionary`, but all lists will be expanded to a flat file. For any values that are null or not available, <NA> will be used.
0 commit comments