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

@jingbof/rets-client

v0.3.13

Published

RETS (Real Estate Transaction Standards) Client in Typescript

Downloads

222

Readme

Typescript RETS Client

A RETS (Real Estate Transaction Standards) Client written in TypeScript, providing seamless access to real estate data. This repo is forked from aeq/rets-client and extended to support REBGV (Real Estate Board of Greater Vancouver) along with additional features like object location retrieval and handling multiple objects in a single request.

Installation

Install via Yarn:

yarn add jingbof/rets-client

Or install via NPM:

npm i jingbof/rets-client

New Features

1. REBGV Compatibility

Extended support for Real Estate Board of Greater Vancouver (REBGV), ensuring seamless integration for this region's data.

2. Thumbnail Object Support

Added support for the Thumbnail object, enabling the retrieval and display of smaller, optimized versions of images for faster loading and preview purposes.

3. Location Support for Objects

The getObject method now includes location support, allowing for direct retrieval of location data when available.

4. Multiple Objects in Single Request

You can now request multiple objects (e.g., multiple images) in a single request for better performance and easier handling.

Usage

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

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

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

  // Retrieve Metadata
  const resources = await getMetadata({ type: RetsMetadataType.Resource });
  console.log('Metadata - Resources:', resources);

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

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

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

  // Stream data for large searches
  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();
      },
    }));

  await new Promise((resolve) => searchStream.on('close', resolve));
  console.log('Total Count:', count);

  // Retrieve photos or objects, with location support and handling multiple objects
  const objects = await getObject({
    resource: 'Property',
    type: 'Photo',
    contentId: '262937723',
    withLocation: true,
  });

  const dir = 'tests';
  fs.mkdirSync(dir, { recursive: true });
  objects.forEach((obj) => {
    if (obj.contentType === 'image/jpeg') {
      fs.writeFileSync(`${dir}/${obj.objectId}.jpg`, obj.data);
    } else if (obj.contentType === 'text/xml') {
      console.log('Object Location:', obj.location);
    }
  });
});

Development/Configuration

For development, you can test the client by configuring the environment variables in your .env file:

RETS_TEST_URL=http://example-rets-url.com
RETS_TEST_USERNAME=your-username
RETS_TEST_PASSWORD=your-password

Run the test file with:

yarn start

Acknowledgements

Forked from: aeq/rets-client