npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pe-sdk

v2.3.0

Published

The official Typescript/Javascript SDK for the Price Engine API

Downloads

90

Readme

This SDK provides convenient access to the Price Engine REST API from TypeScript or JavaScript.

Stable v1

license npm latest package npm downloads conventional Commits nodejs code style: prettier

📲 Installation

npm install pe-sdk
yarn add pe-sdk
pnpm i pe-sdk

Usage

Importing the SDK

To use the SDK, import the Appraisal and Metric classes from the SDK:

import { Appraisal, Metric } from 'pe-sdk'

Configuration

import { Appraisal, Metric } from 'pe-sdk'

const clientOptions = {
  apiKey: 'your_api_key', // Or via env variable PRICE_ENGINE_API_KEY
  baseURL: 'https://api.dd360.mx', // Or via env variable PRICE_ENGINE_BASE_URL
  version: 'v9',
  timeout: 5000,
  maxRetries: 2
}

const appraisalClient = new Appraisal(clientOptions)
const metricClient = new Metric(clientOptions)

Appraisal API

Getting Appraisal Coverage

Input:

import { CommonRequestInput } from 'pe-sdk'

const request: CommonRequestInput = { latitude: 19.4326, longitude: -99.1332 }

Usage:

const appraisal = new Appraisal()
const coverage: AppraisalOutputCoverage =
  await appraisal.getAppraisalCoverage(request)

Output:

{
  hasCoverage: true,
  cvegeo: "090010001"
}

Getting Appraisal

Input:

import { AppraisalRequestInput } from 'pe-sdk'

const request: AppraisalRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332,
  lotSurface: 200,
  constructionArea: 150
}

Usage:

const appraisal = new Appraisal()
const appraisalResult: AppraisalRequestOutput =
  await appraisal.getAppraisal(request)

Output:

{
  value: 5000000,
  valuePerSqm: 25000,
  upperValueRangePerSqm: 27000,
  lowerValueRangePerSqm: 23000,
  upperValueRange: 5400000,
  lowerValueRange: 4600000,
  comparables: [
    {
      id: "123",
      urlAd: "http://example.com",
      surfaceTotal: 200,
      terrainSurface: 150,
      builtYear: 2015,
      numBedrooms: 3,
      numBathrooms: 2,
      numParkingLots: 1,
      isNewPropertyProb: 0.8,
      pricePerSquareMeter: 26000,
      dissimilarityToTarget: 0.1
    }
  ]
}

Getting Appraisal for Apartment Rent

Input:

import { AppraisalRequestInputVariable } from 'pe-sdk'

const request: AppraisalRequestInputVariable = {
  latitude: 19.4326,
  longitude: -99.1332,
  lotSurface: 200,
  constructionArea: 150
}

Usage:

const appraisal = new Appraisal()
const rentResult: AppraisalRequestOutput =
  await appraisal.getAppraisalApartmentRent(request)

Output:

{
  value: 20000,
  valuePerSqm: 100,
  upperValueRangePerSqm: 110,
  lowerValueRangePerSqm: 90,
  upperValueRange: 22000,
  lowerValueRange: 18000,
  comparables: [
    {
      id: "124",
      urlAd: "http://example.com",
      surfaceTotal: 200,
      terrainSurface: 150,
      builtYear: 2018,
      numBedrooms: 2,
      numBathrooms: 1,
      numParkingLots: 1,
      isNewPropertyProb: 0.9,
      pricePerSquareMeter: 105,
      dissimilarityToTarget: 0.05
    }
  ]
}

Getting Appraisal for Apartment Sale

Input:

import { AppraisalRequestInputVariable } from 'pe-sdk'

const request: AppraisalRequestInputVariable = {
  latitude: 19.4326,
  longitude: -99.1332,
  lotSurface: 200,
  constructionArea: 150
}

Usage:

const appraisal = new Appraisal()
const saleResult: AppraisalRequestOutput =
  await appraisal.getAppraisalApartmentSale(request)

Output:

{
  value: 3000000,
  valuePerSqm: 15000,
  upperValueRangePerSqm: 16000,
  lowerValueRangePerSqm: 14000,
  upperValueRange: 3200000,
  lowerValueRange: 2800000,
  comparables: [
    {
      id: "125",
      urlAd: "http://example.com",
      surfaceTotal: 200,
      terrainSurface: 150,
      builtYear: 2020,
      numBedrooms: 2,
      numBathrooms: 1,
      numParkingLots: 1,
      isNewPropertyProb: 0.95,
      pricePerSquareMeter: 15500,
      dissimilarityToTarget: 0.02
    }
  ]
}

Getting Appraisal for House Rent

Input:

import { AppraisalRequestInputVariable } from 'pe-sdk'

const request: AppraisalRequestInputVariable = {
  latitude: 19.4326,
  longitude: -99.1332,
  lotSurface: 200,
  constructionArea: 150
}

Usage:

const appraisal = new Appraisal()
const houseRentResult: AppraisalRequestOutput =
  await appraisal.getAppraisalHouseRent(request)

Output:

{
  value: 25000,
  valuePerSqm: 125,
  upperValueRangePerSqm: 135,
  lowerValueRangePerSqm: 115,
  upperValueRange: 27000,
  lowerValueRange: 23000,
  comparables: [
    {
      id: "126",
      urlAd: "http://example.com",
      surfaceTotal: 200,
      terrainSurface: 150,
      builtYear: 2017,
      numBedrooms: 3,
      numBathrooms: 2,
      numParkingLots: 1,
      isNewPropertyProb: 0.85,
      pricePerSquareMeter: 130,
      dissimilarityToTarget: 0.04
    }
  ]
}

Getting Appraisal for House Sale

Input:

import { AppraisalRequestInputVariable } from 'pe-sdk'

const request: AppraisalRequestInputVariable = {
  latitude: 19.4326,
  longitude: -99.1332,
  lotSurface: 200,
  constructionArea: 150
}

Usage:

const appraisal = new Appraisal()
const houseSaleResult: AppraisalRequestOutput =
  await appraisal.getAppraisalHouseSale(request)

Output:

{
  value: 3500000,
  valuePerSqm: 17500,
  upperValueRangePerSqm: 18500,
  lowerValueRangePerSqm: 16500,
  upperValueRange: 3700000,
  lowerValueRange: 3300000,
  comparables: [
    {
      id: "127",
      urlAd: "http://example.com",
      surfaceTotal: 200,
      terrainSurface: 150,
      builtYear: 2016,
      numBedrooms: 3,
      numBathrooms: 2,
      numParkingLots: 1,
      isNewPropertyProb: 0.8,
      pricePerSquareMeter: 18000,
      dissimilarityToTarget: 0.03
    }
  ]
}

Getting Appraisal Report

Input:

import { AppraisalReportRequestInput } from 'pe-sdk'

const request: AppraisalReportRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332,
  lotSurface: 200,
  constructionArea: 150
}

Usage:

const appraisal = new Appraisal()
const report: Appraisal

ReportRequestOutput = await appraisal.getAppraisalReport(request)

Output:

{
  appraisalRent: {
    value: 25000,
    valuePerSqm: 125,
    upperValueRangePerSqm: 135,
    lowerValueRangePerSqm: 115,
    upperValueRange: 27000,
    lowerValueRange: 23000,
    comparables: [
      {
        id: "126",
        urlAd: "http://example.com",
        surfaceTotal: 200,
        terrainSurface: 150,
        builtYear: 2017,
        numBedrooms: 3,
        numBathrooms: 2,
        numParkingLots: 1,
        isNewPropertyProb: 0.85,
        pricePerSquareMeter: 130,
        dissimilarityToTarget: 0.04
      }
    ]
  },
  appraisalSale: {
    value: 3500000,
    valuePerSqm: 17500,
    upperValueRangePerSqm: 18500,
    lowerValueRangePerSqm: 16500,
    upperValueRange: 3700000,
    lowerValueRange: 3300000,
    comparables: [
      {
        id: "127",
        urlAd: "http://example.com",
        surfaceTotal: 200,
        terrainSurface: 150,
        builtYear: 2016,
        numBedrooms: 3,
        numBathrooms: 2,
        numParkingLots: 1,
        isNewPropertyProb: 0.8,
        pricePerSquareMeter: 18000,
        dissimilarityToTarget: 0.03
      }
    ]
  },
  property: {
    latitude: 19.4326,
    longitude: -99.1332,
    lotSurface: 200,
    constructionArea: 150
  },
  capitalGain: {
    currentCapGain: 0.059994292088481505,
    capGainTimeSeries: {
      "2019-04": 0.766111483639908,,
      "2019-05": 0.7732951742516028,
      "2019-06": 0.776088687570223
    },
    currentPrice: 3500000,
    m2PricePerQuarter: {
      "2019 T2": 44676.65447976637,
      "2019-T3": 45095.57949290333,
      "2019-T4": 45258.4863700169,
    }
  }
}

Metric API

Getting Traffic Metrics

Input:

import { CommonRequestInput } from 'pe-sdk'

const request: CommonRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332
}

Usage:

const metric = new Metric()
const trafficData: TrafficResponse = await metric.getTraffic(request)

Output:

{
  traffic: TrafficLevel,
  score: 75,
  trafficIndex: [
    {
      label: "9:00",
      score: 0.5704178149565791,
      level: TrafficLevel
    },
    {
      label: "13:30",
      score: 0.5704178149565791,
      level: TrafficLevel
    }
  ]
}

type TrafficLevel = "very_high" | "high" | "moderate" | "low"

Getting Capital Gain Metrics

Input:

import { CommonRequestInput } from 'pe-sdk'

const request: CommonRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332
}

Usage:

const metric = new Metric()
const capitalGainData: CapitalGainResponse =
  await metric.getCapitalGain(request)

Output:

{
  currentCapGain: 0.059994292088481505,
  capGainTimeSeries: {
    "2019-04": 0.059994292088481505,
    "2019-05": 0.059994292088481505,
    "2019-06": 0.059994292088481505
  },
  m2PricePerQuarter: {
    "2019-04": 0.059994292088481505,
    "2019-05": 0.059994292088481505,
    "2019-06": 0.059994292088481505
  }
}

Getting Cost of Living Metrics

Input:

import { CommonRequestInput } from 'pe-sdk'

const request: CommonRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332
}

Usage:

const metric = new Metric()
const costOfLivingData: CostOfLivingResponse =
  await metric.getCostOfLiving(request)

Output:

{
  costOfLiving: CostLevel,
  score: 77
}

type CostLevel = "very_high" | "high" | "moderate" | "low"

Getting Walkability Metrics

Input:

import { CommonRequestInput } from 'pe-sdk'

const request: CommonRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332
}

Usage:

const metric = new Metric()
const walkabilityData: WalkabilityResponse =
  await metric.getWalkability(request)

Output:

{
  walkability: WalkabilityLevel,
  score: 85
}

type WalkabilityLevel = "walkers_paradise" | "walkable" | "somewhat_walkable" | "car_dependent"

Getting Current Price Metrics

Input:

import { CommonRequestInput } from 'pe-sdk'

const request: CommonRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332
}

Usage:

const metric = new Metric()
const currentPriceData: CurrentPriceResponse =
  await metric.getCurrentPrice(request)

Output:

{
  currentPrice: 3500000
}

Getting Proximity to Work Metrics

Input:

import { CommonRequestInput } from 'pe-sdk'

const request: CommonRequestInput = {
  latitude: 19.4326,
  longitude: -99.1332
}

Usage:

const metric = new Metric()
const proximityToWorkData: ProximityToWorkResponse =
  await metric.getProximityToWork(request)

Output:

{
  proximityToWork: ProximityLevel,
  score: 90
}

type ProximityLevel = "high" | "low" | "medium"

Types

The SDK uses the following types for request and response objects:

Appraisal Types

  • AppraisalReportRequestInput
  • AppraisalReportRequestOutput
  • AppraisalRequestInput
  • AppraisalRequestInputVariable
  • AppraisalRequestOutput
  • AppraisalOutputCoverage
  • CommonRequestInput

Metric Types

  • CapitalGainResponse
  • CostOfLivingResponse
  • CurrentPriceResponse
  • ProximityToWorkResponse
  • TrafficResponse
  • WalkabilityResponse
  • CommonRequestInput

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.