Giter VIP home page Giter VIP logo

rets-client's Introduction

Typescript RETS Client

A RETS (Real Estate Transaction Standard) Client written in Typescript.

Install

if using yarn: yarn add @aequilibrium/rets-client

if using npm: npm i @aequilibrium/rets-client

Usage

import { getClient, RetsMetadataType, ReturnType } from '@aequilibrium/rets-client';

const config = {
  url: 'my-rets-url',
  username: 'my-rets-username',
  password: 'my-rets-password',
}

await getClient(config, async ({ search, getMetadata, getDataMap }) => {

  // Figure out the data structure
  const resources = await getMetadata({
    type: RetsMetadataType.Resource,
  })
  console.log('getMetadata.Resource', resources)

  const classes = await getMetadata({
    type: RetsMetadataType.Class,
  })
  console.log('getMetadata.Class', classes)

  // Build a Datamap of the RETS Data Structure
  const dataMap = await getDataMap()
  console.log('getDataMap', dataMap)


  // Search for data 
  const listings = await search({
    query: '(Status=A)',
    limit: 5,
    searchType: 'Property',
    className: 'ResidentialProperty',
    culture: DdfCulture.EN_CA,
  })
  console.log('listing', listings)

  // search for data using streams
  let count = 0
  const searchStream = (
    (await search({
      query: '(Status=A)',
      limit: 5,
      searchType: 'Property',
      className: 'ResidentialProperty',
      culture: DdfCulture.EN_CA,
      returnType: ReturnType.Stream,
    })) as Readable
  )
    .pipe(
      new Writable({
        objectMode: true,
        write: (data, _, done) => {
          count += 1
          done()
        },
      }),
    )
  // wait for the stream to finish
  await new Promise((fulfill) => searchStream.on('close', fulfill))
  console.log('final Count', count)

  // retrieve some objects/images
})

Development/Configuration

If you're developing this app you can use the test file by setting up the user configuration by adding the following ot your .env file.

RETS_TEST_URL=http://www...
RETS_TEST_USERNAME=...
RETS_TEST_PASSWORD=...

and then run the test file by running: yarn start

Acknowledgements

Inspired by:

rets-client's People

Contributors

akowalczewski avatar

Stargazers

Jingbo avatar Chris Morris avatar Kevin Colten avatar Aseem Kishore avatar Danilo Castro avatar Kehuan Wang avatar

Watchers

Kehuan Wang avatar Danilo Castro avatar Nick Maietta avatar

rets-client's Issues

401 Unauthorized when trying to get Client (credentials work / have worked for ~~10 months with rets-client)

I am facing a 401 Unauthorized when trying to migrate my existing RETS client implementation to your package (I currently use https://www.npmjs.com/package/rets-client). Using the same credentials that work with that package, I get an Auth error - do you have any suggestions for what I may be missing? I noticed that package uses RETS 1.7.x and a different node engine, but I tried to bring your code down locally and change those values and got the same auth failure.

Thanks for any tips you might have!

loginUrl = https://pt.rets.crmls.org/contact/rets/login

const retsConfig: IRetsClientOptions = {
    username: clientSettings.username,
    password: clientSettings.password,
    url: loginUrl,
    format: RetsFormat.CompactDecoded,
};

try {
    console.log("Fetching Latest CRMLS Properties");
    await getClient(retsConfig, async ({ search }) => {
        console.log('connected!') // never reaches this log
    });
} catch (error) {
    console.log(error)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.