Giter VIP home page Giter VIP logo

zoopla's Introduction

zoopla

Build Status codecov

A python wrapper for the Zoopla API.

Zoopla has launched an open API to allow developers to create applications using hyper local data on 27m homes, over 1m sale and rental listings, and 15 years of sold price data.

Register for a user account and apply for an instant API key.

Browse the documentation to understand how to use the API and the specifications for the individual APIs.

Installation

$ pip install zoopla

Tests

Install the dev requirements:

$ pip install -r requirements.txt
Run py.test with your developer key (otherwise you won’t be able to hit the live
API upon which these tests depend).
$ py.test --api_key=<your-api-key> tests/ # pytest under Python 3+

Examples

Retrieve property listings for a given area.

from zoopla import Zoopla

zoopla = Zoopla(api_key='your_api_key')

search = zoopla.property_listings({
    'maximum_beds': 2,
    'page_size': 100,
    'listing_status': 'sale',
    'area': 'Blackley, Greater Manchester'
})

for result in search.listing:
    print(result.price)
    print(result.description)
    print(result.image_url)

Retrieve a list of house price estimates for the requested area.

zed_indices = zoopla.area_zed_indices({
    'area': 'Blackley, Greater Manchester',
    'output_type': 'area',
    'area_type': 'streets',
    'order': 'ascending',
    'page_number': 1,
    'page_size': 10
})

print(zed_indices.town)
print(zed_indices.results_url)

Generate a graph of values for an outcode over the previous 3 months and return the URL to the generated image.

area_graphs = zoopla.area_value_graphs({'area': 'SW11'})

print(area_graphs.average_values_graph_url)
print(area_graphs.value_trend_graph_url)

Retrieve the average sale price for houses in a particular area.

average = zoopla.average_area_sold_price({'area': 'SW11'})

print(average.average_sold_price_7year)
print(average.average_sold_price_5year)

Submit a viewing request to an agent regarding a particular listing.

session_id = zoopla.get_session_id()

arrange_viewing = zoopla.arrange_viewing({
    'session_id': session_id,
    'listing_id': 44863256,
    'name': 'Tester',
    'email': "[email protected]",
    'phone': '01010101',
    'phone_type': 'work',
    'best_time_to_call': 'anytime',
    'message': 'Hi, I seen your listing on zoopla.co.uk and I would love to arrange a viewing!'

})

Contributing

  • Fork the project and clone locally.
  • Create a new branch for what you're going to work on.
  • Push to your origin repository.
  • Include tests and update documentation if necessary.
  • Create a new pull request in GitHub.

zoopla's People

Contributors

anthonybloomer avatar dependabot[bot] avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

zoopla's Issues

Unable to run the first example


ZooplaAPIException Traceback (most recent call last)
in ()
----> 1 rl = zoopla.property_rich_list({'area': 'SW11'})

G:\GitHub\zoopla-master\zoopla\api.py in property_rich_list(self, params)
105 request_schema=BaseRequestSchema,
106 result_schema=RichlistResultSchema,
--> 107 parameters=params
108 )
109

G:\GitHub\zoopla-master\zoopla\api.py in _base_call(self, action, request_schema, result_schema, parameters)
58 raise RequestFormatException(request_errors)
59
---> 60 response = self._api_call(action, parameters)
61 result, errors = result_schema().load(response)
62

G:\GitHub\zoopla-master\zoopla\api.py in _api_call(self, action, params)
49 return response.json()
50 else:
---> 51 raise ZooplaAPIException(response.reason)
52
53 def _base_call(self, action, request_schema, result_schema, parameters):

ZooplaAPIException: Zoopla returned an error: Forbidden

Simple query raises zoopla.exceptions.ResponseFormatException

This looks like a really great library, thanks for making it!

I'm just struggling to get it working correctly, I've got the following code which is raising an exception for me.

from zoopla import Zoopla

zoopla = Zoopla(api_key='...')

search = zoopla.property_listings({
    'area': "London",
    'listing_status': "rent",
    'page_size': 100,
})

I'm getting a zoopla.exceptions.ResponseFormatException exception on some fields being null.

Prices not visible

Hello,
It seems that the example in the readme does not give price in the output dictionary.

from zoopla import Zoopla

zoopla = Zoopla(api_key='***************')`

search = zoopla.property_listings({
'maximum_beds': 2,
'page_size': 100,
'listing_status': 'sale',
'area': 'Blackley, Greater Manchester'
})

'price' in result
False

AttributeError: 'NoneType' object has no attribute 'strip'`

osx 10.13.3. Anaconda Python3.6 with zoopla installed from pip.

average = zoopla.average_area_sold_price({'area': 'SW11'}) print(average.average_sold_price_7year) print(average.average_sold_price_5year)

Returns:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-8d12e09572f3> in <module>()
----> 1 average = zoopla.average_area_sold_price({'area': 'SW11'})
      2 
      3 print(average.average_sold_price_7year)
      4 print(average.average_sold_price_5year)

~/anaconda3/lib/python3.6/site-packages/zoopla/api.py in average_area_sold_price(self, params)
     97             request_schema=BaseRequestSchema,
     98             result_schema=AverageAreaSoldPriceResultSchema,
---> 99             parameters=params
    100         )
    101 

~/anaconda3/lib/python3.6/site-packages/zoopla/api.py in _base_call(self, action, request_schema, result_schema, parameters)
     50 
     51         response = self._api_call(action, parameters)
---> 52         result, errors = result_schema().load(response)
     53 
     54         if errors:

~/anaconda3/lib/python3.6/site-packages/marshmallow/schema.py in load(self, data, many, partial)
    578         .. versionadded:: 1.0.0
    579         """
--> 580         result, errors = self._do_load(data, many, partial=partial, postprocess=True)
    581         return UnmarshalResult(data=result, errors=errors)
    582 

~/anaconda3/lib/python3.6/site-packages/marshmallow/schema.py in _do_load(self, data, many, partial, postprocess)
    658                     partial=partial,
    659                     dict_class=self.dict_class,
--> 660                     index_errors=self.opts.index_errors,
    661                 )
    662             except ValidationError as error:

~/anaconda3/lib/python3.6/site-packages/marshmallow/marshalling.py in deserialize(self, data, fields_dict, many, partial, dict_class, index_errors, index)
    293                     field_name=field_name,
    294                     field_obj=field_obj,
--> 295                     index=(index if index_errors else None)
    296                 )
    297                 if value is not missing:

~/anaconda3/lib/python3.6/site-packages/marshmallow/marshalling.py in call_and_store(self, getter_func, data, field_name, field_obj, index)
     66         """
     67         try:
---> 68             value = getter_func(data)
     69         except ValidationError as err:  # Store validation errors
     70             self.error_kwargs.update(err.kwargs)

~/anaconda3/lib/python3.6/site-packages/marshmallow/marshalling.py in <lambda>(val)
    286                     val,
    287                     field_obj.load_from or attr_name,
--> 288                     data
    289                 )
    290                 value = self.call_and_store(

~/anaconda3/lib/python3.6/site-packages/zoopla/fields.py in deserialize(self, value, attr, data)
      5     def deserialize(self, value, attr=None, data=None):
      6         result = super(StrippedString, self).deserialize(value, attr, data)
----> 7         return result.strip()

AttributeError: 'NoneType' object has no attribute 'strip'

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.