1.0.0 • Published 3 years ago

firststreet-js v1.0.0

Weekly downloads
47
License
MIT
Repository
github
Last release
3 years ago

First Street JavaScript Client

CircleCI codecov

This is the official implementation of the First Street Foundation API in JavaScript.

For more in-depth guides, usage and API access, please see the documentation at docs.firststreet.dev.

Installation

First install firststreet-js:

npm install firststreet-js

Next, import it into your project

import FirstStreet from 'firststreet-js';

// Or commonjs
const FirstStreet = require('firststreet-js');

Documentation

In order to use the First Street Foundation API, you must register for an API key at https://firststreet.dev.

Intializing Client

// Create a new First Street Foundation API Client
const fs = new FirstStreet("api-key");

Using the client

The client supports querying Firststreet API endpoints corresponding to documentation, extensive examples can be found in ./tests directory.

Generally, for endpoints that require location and fsid, first need to initialize lookup object as in below example, and then use it for querying the data:

    const fs = new FirstStreet(apiKey);
    const lookup = fs.lookup('city', { fsid: 4808860 });
    const probability = await lookup.probability('count');

For endpoints that do not use fsid, please pass the parameter(s) directly to the endpoint call, as in this example:

    const fs = new FirstStreet(apiKey);
    const historic = await fs.historic('event', { id: 12 });

Similarly, if endpoint accepts other parameters in addition to location lookup, then these can be passed to the endpoint call directly:

    const fs = new FirstStreet(apiKey);
    const lookup = fs.lookup('property', { fsid: 4801470191 });
    const aal = await lookup.economic('aal', { basement: true, floorElevation: 122, depth: 100 });

Errors

Errors from the API and network errors are propagated to caller.

1.0.0

3 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago