Code Monkey home page Code Monkey logo

domain's Introduction

Build Status Docs

Python client for the Domain property API

It does what it says on the tin.

Installation

Using pip:

pip install domain

Or installing from source:

git clone [email protected]:andycasey/domain.git
cd domain/
python setup.py install

Authentication

You will first need to sign up for a Domain developer account. Then you will be able to create a project.

Now you will need to create some credentials. I suggest to create an OAuth 2.0 Client. To do this correctly you will be given a Client ID and Client Secret. Copy those down; you'll need these later.

The Domain API has changed since this code was written. That means some of the way this code works to find out which credentials are required for a given API end point, are no longer needed. This README just tells you what you need to do to make everything work. In practice, the abstraction of plan <-> scope needs to be updated to reflect the new API end points.

Next you'll need to add API Access to your project. Sign up for everything that is free, and then create a credentials file (called client_credentials.yaml) in the following format:

- client_id: <CLIENT_ID>
  client_secret: <CLIENT_SECRET>
  package_and_plan: AgentsAndListingsInnovationPlan 
- client_id: <CLIENT_ID>
  client_secret: <CLIENT_SECRET>
  package_and_plan: PropertyAndLocationInnovationPlan

Now you can use those credentials (or any number of Client ID/Client Secret pairs) to authenticate and use the API from Python:

from domain.client import DomainClient

dc = DomainClient("client_credentials.yaml")

That's it!

The DomainClient will work out which scope is required for each API end point, and will create authentication tokens (Oauth2) as needed. New tokens will be generated when the old ones expire, and the token handling (domain.authorisations.token.Token) will automatically throttle your requests so that you your queries don't fail due to the Domain API rate limits.

You can override this behaviour by supplying your own token=Token keyword argument to any API method in the DomainClient class.

API Example Usage

# Suggest properties based on search terms
results = dc.properties_suggest("Mockingbird lane")

print(results[0])
>>> {u'id': u'PB-5682-MC',
 u'relativeScore': 100,
 u'addressComponents': {u'streetTypeLong': u'Road',
 u'streetType': u'Rd',
 u'suburb': u'Pheasants Nest',
 u'state': u'NSW',
 u'unitNumber': u'',
 u'postcode': u'2574',
 u'streetNumber': u'145',
 u'streetName': u'Mockingbird'},
 u'address': u'145 Mockingbird Road, Pheasants Nest NSW 2574'}


# General sales metadata.
print(dc.sales_results_metadata())
>>> {u'auctionedDate': u'2017-08-12',
 u'lastModifiedDateTime': u'2017-08-12T08:45:37.576Z'}


# Check recent sales results in the best city ever.
print(dc.sales_results("Melbourne"))
>>> {u'adjClearanceRate': 0.717219589257504,
 u'median': 898000,
 u'numberAuctioned': 623,
 u'numberListedForAuction': 823,
 u'numberSold': 454,
 u'numberUnreported': 8,
 u'numberWithdrawn': 10,
 u'totalSales': 412839650.0}

domain's People

Contributors

andycasey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

domain's Issues

Api has two endpoint with same name listings_statistics(Gave this error when I try to find with just listing id)

File "/app/load/urls.py", line 8, in
celery-worker_1 | from domain_client.api_client import get_property_info
celery-worker_1 | File "/app/domain_client/api_client.py", line 19, in
celery-worker_1 | results = dc.listings_statistics(portal_public_id)
celery-worker_1 | File "/usr/local/lib/python3.8/site-packages/domain/authorisation/init.py", line 33, in wrapped
celery-worker_1 | return method(self, *args, **kwds)
celery-worker_1 | TypeError: listings_statistics() missing 2 required positional arguments: 'time_period' and 'status_filter'

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.