Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Running the Library Through the Command Line

Kelvin edited this page May 20, 2021 · 6 revisions

1. Set the environmental variable.

[Reminder] Keep your API key safe, and do not share it with others!
[NOTE] This method will always generate a CSV.

MacOS or Linux

[Required] Open a bash terminal and set an Environmental Variable with the variable_name as FSF_API_KEY and the variable_value with the API_KEY with the command

export FSF_API_KEY=your personal API key

Windows

[Required] Set an Environmental Variable with the variable_name as FSF_API_KEY and the variable_value with the API_KEY.

Screenshot

Screenshot

Screenshot

2. Open/Re-open a powershell console / bash terminal 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 in the individual products for more examples.

cd /path/to/project

python -m firststreet -p <product>.<product_subtype> -s <search_item>

Command Line Argument Details:

  • -p/--product PRODUCT: [REQUIRED] The product to call from the API

    Example: -p location.get_detail

  • [-api_key/--api_key API_KEY]: [OPTIONAL] If step 1 is skipped or unavailable, this argument can take the API_KEY instead.

    Example: -a XXXXXXXXXXXXXXXXXXX

  • [-v/--version VERSION]: [OPTIONAL] The version of the API to call. Defaults to the current version.

    Example: -v v1

  • [-log/--log LOG]: [OPTIONAL] To log info output to the console or not. Defaults to True

    Example: -l False

  • [-connection_limit/--connection_limit CONNECTION_LIMIT]: [OPTIONAL] The max number of concurrent connections to make to the API at the same time. This is does not affect the number of FSIDs that can be pulled. Defaults to 100 connections

    Example: -connection_limit 20000

  • [-rate_limit/--rate_limit RATE_LIMIT]: [OPTIONAL] The max number of requests during the rate limit period. Defaults to 20000 requests

    Example: -rate_limit 1

  • [-rate_period/--rate_period RATE_PERIOD]: [OPTIONAL] The period of time for the rate limit. Defaults to 1 second

    Example: -rate_period 20

  • [-o/--output_dir OUTPUT_DIR]: [OPTIONAL] The location to output the generated CSV or image. Defaults to output_data in the working directory.

    Example: -o new_output_location

  • [-s/--search_items SEARCH_ITEMS]: [OPTIONAL] The Search Items to search for with the product.

    NOTE The search_item list must be separated with a semicolon (;) instead of a comma

    Example: -s 541114211;541229206 Example: -s "247 Water Street, New York, New York";"485 Lexington Avenue New York, New York" Example: -s 40.754,-73.977;40.75682,-73.98037

  • [-l/--location_type LOCATION_TYPE]: [OPTIONAL] The lookup location type (property, neighborhood, city, zcta, tract, county, cd, state)

    Example: -l property

  • [-y/--year YEAR]: [OPTIONAL] The year to use for the Probability Depth Tile product

    Example: -y 2050

  • [-rp/--return_period RETURN_PERIOD]: [OPTIONAL] The return period to use for the Probability Depth Tile product

    Example: -rp 500

  • [-eid/--event_id EVENT_ID]: [OPTIONAL] The event id to use for the Historic Event Tile product

    Example: -eid 3

  • [-e/--extra_param EXTRA_PARAM]: [OPTIONAL] Extra parameters used for specific products. Ex: To adjust the AAL calculations in aal.get_summary Example: -eid 3

Clone this wiki locally