toddstavish / sdk-python

The Edmunds API Python SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Edmunds API Python Wrapper

This is an awesome Python 2 wrapper for the Edmunds.com API. The Edmunds.com API provides automative data including vehicle specs, pricing, media, reviews, and more. There are also Edmunds API endpoints for dealership information and Edmunds editorial content.

Usage

Enter your Edmunds API key:

from edmunds import Edmunds
api = Edmunds('YOUR API KEY') # use Edmunds('YOUR API KEY', True) for debug mode

Make API calls to any endpoint, get a JSON object returned. For example, get the style details for the 2011 Lexus RX 350:

>>> response = api.make_call('/api/vehicle/v2/lexus/rx350/2011/styles')
>>> response
{u'styles': [{u'id': 101353967,
   u'make': {u'id': 200001623, u'name': u'Lexus', u'niceName': u'lexus'},
   u'model': {u'id': u'Lexus_RX_350',
    u'name': u'RX 350',
    u'niceName': u'rx-350'},
   u'name': u'4dr SUV (3.5L 6cyl 6A)',
   u'submodel': {u'body': u'SUV', u'modelName': u'RX 350 SUV'},
   u'trim': u'Base',
   u'year': {u'id': 100533091, u'year': 2011}},
  {u'id': 101353968,
   u'make': {u'id': 200001623, u'name': u'Lexus', u'niceName': u'lexus'},
   u'model': {u'id': u'Lexus_RX_350',
    u'name': u'RX 350',
    u'niceName': u'rx-350'},
   u'name': u'4dr SUV AWD (3.5L 6cyl 6A)',
   u'submodel': {u'body': u'SUV', u'modelName': u'RX 350 SUV'},
   u'trim': u'Base',
   u'year': {u'id': 100533091, u'year': 2011}}],
 u'stylesCount': 2}

Get photos for the style ID 3883 (1990 Honda Civic 2dr Hatchback):

>>> response = api.make_call('/v1/api/vehiclephoto/service/findphotosbystyleid', comparator='simple', styleId='3883')
>>> response
[{u'authorNames': [u'American Honda Motor Company, Inc.'],
  u'captionTranscript': u'1991 Honda Civic 2 Dr Si Hatchback',
  u'photoSrcs': [u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_131.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_396.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_300.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_400.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_500.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_185.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_175.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_196.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_423.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_276.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_87.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_150.jpg',
   u'/honda/civic/1991/oem/1991_honda_civic_2dr-hatchback_si_fq_oem_1_98.jpg'],
  u'shotTypeAbbreviation': u'FQ',
  u'subType': u'exterior',
  u'type': u'PHOTOS'}]

Installation

The Edmunds API Python wrapper requires the amazing requests library. Here are the installation instructions and the source code.

To install using pip:

pip install edmunds or pip install git+https://github.com/EdmundsAPI/sdk-python

Then:

git clone https://github.com/EdmundsAPI/sdk-python.git or just click "Clone in Desktop" or "Download ZIP"

Install

Notes:

  • Using pip to install this package will atuomatically install the requests library
  • The files (edmunds.py and tests.py) will be installed to your Python site-packages folder
  • It is suggested you then clone the repository (using the second command) in order to download all of the files to your computer and so that you can insert your API Key into the edmunds.py code

Contents

sdk-python/
   .gitignore
   AUTHORS.md # Info about development and how to contribute
   HISTORY.md # Version history
   LICENSE
   MANIFEST
   MANIFEST.in
   README.md # You're looking at it!
   requirements.txt
   setup.py
   edmunds/
      examples/ # Examples of using the SDK
         README.md
         media_photos.py
         spec_make.py
      __init__.py
      edmunds.py # The source code for the SDK
      tests.py

Issues

Please submit any problems, requests, and comments here.

SDK Status

This is a beta release. We have opened sourced it at this stage to guide the development of the library and allow you to freely inspect and use the source.

Documentation

The Edmunds API documentation can be found here.

License

Licensed under the Apache v2 License.

About

The Edmunds API Python SDK

License:Apache License 2.0


Languages

Language:Python 100.0%