1.1.5 • Published 5 years ago
sizeup-api v1.1.5
SizeUp data service: Node SDK and CLI
Please note: Software versions prior to 1.1.3 are not supported by any of the SizeUp services. (The 1.x series is considered experimental. Backwards compatibility will be observed starting with version 2.0.)
API usage
Installation
yarn add sizeup-apior
npm install sizeup-apiBe sure to set $SIZEUP_KEY in your environment to use the examples below.
Modern ES6 style, using Promises
const sizeup = require('sizeup-api')({ key:process.env.SIZEUP_KEY });
const logj = r => console.log(JSON.stringify(r,0,2)) || r;
Promise
.all([
sizeup.data.findIndustry({ term:"grocery" }),
sizeup.data.findPlace({ term:"fresno", maxResults:2 }),
])
// .then(logj) // for debugging
.then(([ [industry], [place] ]) =>
sizeup.data.getAverageRevenue({
industryId: industry.Id,
geographicLocationId: place.City.Id
})
)
.then(logj) // final output
.catch(console.error)Old style
var sizeup = require('sizeup-api')({ key:process.env.SIZEUP_KEY });
// Old style: callbacks
sizeup.data.findPlace({ term:"fresno", maxResults:2 },
console.log, console.error );
sizeup.data.findIndustry({ term:"grocery" }),
console.log, console.error );See also the ES6 example and the old-style example.
CLI usage
(After npm install -g sizeup-api)
export SIZEUP_KEY=...
sizeup findPlace '{"term":"fresno"}'
sizeup findIndustry '{"term":"tech"}'
sizeup getAverageSalaryBands '{
"boundingGeographicLocationId": 130073,
"industryId": 8589,
"granularity": "County",
"bands": 7
}'Each sizeup subcommand (e.g., findPlace) is a function in sizeup.data in the The API Documentation.
The granularity and attributes values as used in the Documentation can be provided directly as CamelCase strings, as in the last example (getAverageSalaryBands: "granularity": "County"), above.
granularity
ZIP_CODE: 'ZipCode',
CITY: 'City',
COUNTY: 'County',
PLACE: 'Place',
METRO: 'Metro',
STATE: 'State',
NATION: 'Nation'attributes
TOTAL_REVENUE: 'TotalRevenue',
AVERAGE_REVENUE: 'AverageRevenue',
REVENUE_PER_CAPITA: 'RevenuePerCapita',
TOTAL_EMPLOYEES: 'TotalEmployees',
AVERAGE_EMPLOYEES: 'AverageEmployees',
EMPLOYEES_PER_CAPITA: 'EmployeesPerCapita'