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.
# First Street Foundation API Access Documentation (Python)
2
2
The First Street Foundation API Access (Python) is a wrapper used to bulk extract flood data from the First Street Foundation API
3
3
4
-
##Installation
4
+
# Installation
5
5
**NOTE**: This project requires [Python](https://www.python.org/downloads/) 3.6+ to run.
6
6
1. Go to the Python page (https://www.python.org/downloads/) and download then install Python version 3. **Make sure that the checkbox is checked for Python to be added to the PATH**
7
7
@@ -33,7 +33,7 @@ The First Street Foundation API Access (Python) is a wrapper used to bulk extrac
33
33
34
34

35
35
36
-
5. [Optional] Open or close and re-open a new console and create and activate a new virtual environment in the project directory:
36
+
5. [Optional] Open a new console or close and re-open a console and create and activate a new virtual environment in the project directory:
37
37
```sh
38
38
python -m venv /path/to/new/virtual/environment
39
39
@@ -66,7 +66,7 @@ The First Street Foundation API Access (Python) is a wrapper used to bulk extrac
66
66
├── venv
67
67
├── my_script.py
68
68
69
-
## Method 1: Through the Command Line
69
+
# Method 1: Through the Command Line
70
70
**[Reminder] Keep your API key safe, and do not share it with others!**
71
71
72
72
1. [Required] Set an Environmental Variable with the `variable_name` as `FSF_API_KEY` and the `variable_value` with the `API_KEY`.
@@ -85,40 +85,19 @@ The First Street Foundation API Access (Python) is a wrapper used to bulk extrac
85
85
86
86

87
87
88
+
##### Command Line Argument Details:
88
89
89
-
## Method 2: Through the Client
90
-
**[Reminder] Keep your API key safe, and do not share it with others!**
90
+
- `-p/--product PRODUCT`: [REQUIRED] The product to call from the API
91
91
92
-
1. Create a new Python script (by using notepad or any other text editor) and initialize a First Street Foundation API Client.
93
-
```python
94
-
# Contents of my_script.py
95
-
import firststreet
96
-
fs = firststreet.FirstStreet("api-key")
97
-
```
98
-
99
-
2. Call one of the methods described below in the `Products` section with the required arguments. See the `Examples` section for more examples.
* api_key `string`: The assigned API key to access the API.
153
+
* version `string= v1`: The version of the API to access. Defaults to the current version.
154
+
* log `bool= True`: Setting for whether to log info or not. Defaults to True.
171
155
172
-

173
-
174
-
3. The project should now be updated to the newest version.
175
-
176
-
## CSV File Output:
177
-
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).
178
-
179
-
180
-
### CSV File Name:
181
-
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.
189
-
190
-
Ex:
191
-
```csv
192
-
fsid,year,returnPeriod,bin,low,mid,high
193
-
7935,2020,20,20,<NA>,2,<NA>
194
-
7935,2020,20,50,<NA>,1,<NA>
195
-
7935,2020,20,55,<NA>,2,<NA>
196
-
7935,2020,20,65,<NA>,2,<NA>
197
-
7935,2020,20,75,<NA>,2,<NA>
198
-
7935,2020,20,95,<NA>,1,<NA>
199
-
7935,2020,20,100,<NA>,1,<NA>
200
-
...
201
-
```
202
-

156
+
2. Call one of the methods described below in the `Products` section with the required arguments. See the `Examples` section for more examples.
The Location API provides `Detail` and `Summary` data for the given FSIDs.
210
177
211
178
```python
212
179
location.<method>
213
180
```
214
181
215
-
*`get_detail`(fsids `list`, location_type `string`, csv `bool`) - Returns an array of `Location Detail` product for the given IDs, location_type, and optionally creates a csv file
216
-
*`get_summary`(fsids `list`, location_type `string`, csv `bool`) - Returns an array of `Location Summary` product for the given IDs, location_type, and optionally creates a csv file
182
+
*`get_detail`(fsids `list`, location_type `string`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Location Detail` product for the given IDs, location_type, and optionally creates a csv file
183
+
*`get_summary`(fsids `list`, location_type `string`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Location Summary` product for the given IDs, location_type, and optionally creates a csv file
217
184
218
-
### Probability
185
+
#### Probability
219
186
220
187
The Probability API provides `Depth`, `Chance`, `Cumulative`, `Count` data for the given FSIDs.
221
188
222
189
```python
223
190
probability.<method>
224
191
```
225
192
226
-
*`get_depth`(fsids `list`, csv `bool`) - Returns an array of `Probability Depth` product for the given IDs, and optionally creates a csv file
227
-
*`get_chance`(fsids `list`, csv `bool`) - Returns an array of `Probability Chance` product for the given IDs, and optionally creates a csv file
228
-
*`get_count_summary`(fsids `list`, csv `bool`) - Returns an array of `Probability Count-Summary` product for the given IDs, and optionally creates a csv file
229
-
*`get_cumulative`(fsids `list`, csv `bool`) - Returns an array of `Probability Cumulative` product for the given IDs, and optionally creates a csv file
230
-
*`get_count`(fsids `list`, location_type `string`, csv `bool`) - Returns an array of `Probability Count` product for the given IDs, location_type, and optionally creates a csv file
193
+
*`get_depth`(fsids `list`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Probability Depth` product for the given IDs, and optionally creates a csv file
194
+
*`get_chance`(fsids `list`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Probability Chance` product for the given IDs, and optionally creates a csv file
195
+
*`get_count_summary`(fsids `list`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Probability Count-Summary` product for the given IDs, and optionally creates a csv file
196
+
*`get_cumulative`(fsids `list`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Probability Cumulative` product for the given IDs, and optionally creates a csv file
197
+
*`get_count`(fsids `list`, location_type `string`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Probability Count` product for the given IDs, location_type, and optionally creates a csv file
231
198
232
-
### Historic
199
+
#### Historic
233
200
234
201
The Historic API provides `Summary` and `Event` data for the given FSIDs.
235
202
236
203
```python
237
204
historic.<method>
238
205
```
239
206
240
-
*`get_event`(fsids `list`, csv `bool`) - Returns an array of `Historic Event` product for the given historic IDs, and optionally creates a csv file
241
-
*`get_summary`(fsids `list`, location_type `string`, csv `bool`) - Returns an array of `Historic Summary` product for the given IDs, location_type, and optionally creates a csv file
207
+
*`get_event`(fsids `list`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Historic Event` product for the given historic IDs, and optionally creates a csv file
208
+
*`get_summary`(fsids `list`, location_type `string`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Historic Summary` product for the given IDs, location_type, and optionally creates a csv file
242
209
243
-
### Adaptation
210
+
#### Adaptation
244
211
245
212
The Adaptation API provides `Summary` and `Project` data for the given FSIDs.
246
213
247
214
```python
248
215
adaptation.<method>
249
216
```
250
217
251
-
*`get_project`(fsids `list`, csv `bool`) - Returns an array of `Adaptation Project` product for the given adaptation IDs, and optionally creates a csv file
252
-
*`get_summary`(fsids `list`, location_type `string`, csv `bool`) - Returns an array of `Adaptation Summary` product for the given IDs, location_type, and optionally creates a csv file
218
+
*`get_project`(fsids `list`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Adaptation Project` product for the given adaptation IDs, and optionally creates a csv file
219
+
*`get_summary`(fsids `list`, location_type `string`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Adaptation Summary` product for the given IDs, location_type, and optionally creates a csv file
253
220
254
-
### Fema
221
+
#### Fema
255
222
256
223
The Fema API provides `NFIP` data for the given FSIDs.
257
224
258
225
```python
259
226
fema.<method>
260
227
```
261
228
262
-
*`get_nfip`(fsids `list`, location_type `string`, csv `bool`) - Returns an array of `Fema NFIP` product for the given IDs, location_type, and optionally creates a csv file
229
+
*`get_nfip`(fsids `list`, location_type `string`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Fema NFIP` product for the given IDs, location_type, and optionally creates a csv file
263
230
264
-
### Environmental
231
+
#### Environmental
265
232
266
233
The Environmental API provides `Precipitation` data for the given FSIDs.
267
234
268
235
```python
269
236
environmental.<method>
270
237
```
271
238
272
-
*`get_precipitation`(fsids `list`, csv `bool`) - Returns an array of `Environmental Precipitation` product for the given county IDs, and optionally creates a csv file
273
-
239
+
*`get_precipitation`(fsids `list`, csv `bool`, [core_limit `int=100`]) - Returns an array of `Environmental Precipitation` product for the given county IDs, and optionally creates a csv file
274
240
275
-
## Examples
241
+
# Examples
276
242
**[Reminder] Keep your API key safe, and do not share it with others!**
277
243
1. Single FSID Extraction Through the Client:
278
244
```python
@@ -373,5 +339,65 @@ environmental.<method>
373
339
541262690,1,0,1,0,0
374
340
540651172,1,0,1,0,0
375
341
```
342
+
343
+
344
+
# CSV File Output:
345
+
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).
346
+
347
+
348
+
#### CSV File Name:
349
+
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.
357
+
358
+
Ex:
359
+
```csv
360
+
fsid,year,returnPeriod,bin,low,mid,high
361
+
7935,2020,20,20,<NA>,2,<NA>
362
+
7935,2020,20,50,<NA>,1,<NA>
363
+
7935,2020,20,55,<NA>,2,<NA>
364
+
7935,2020,20,65,<NA>,2,<NA>
365
+
7935,2020,20,75,<NA>,2,<NA>
366
+
7935,2020,20,95,<NA>,1,<NA>
367
+
7935,2020,20,100,<NA>,1,<NA>
368
+
...
369
+
```
370
+

371
+
372
+

373
+
374
+
# Updating the Project to the Newest Version:
375
+
If an update is made to this project, you will need to pull the changes from github and reinstall this project.
376
+
377
+
1. Open `git bash` and create then navigate to the existing project directory. Then navigate into the project directory, and run:
378
+
379
+
```git
380
+
git pull
381
+
```
382
+
383
+
If the response is `Already up to date.`, then you have the latest version of the project already.
384
+
385
+

386
+
387
+
2. Open a new console, navigate to the project, and re-run the setup script to re-install the project:
388
+
389
+
```shell script
390
+
cd /path/to/project
376
391
392
+
.\venv\Scripts\activate
393
+
394
+
pip install .\fsf_api_access_python\.
395
+
```
396
+
397
+

398
+
399
+
3. The project should now be updated to the newest version
0 commit comments