Skip to main content

a thin wrapper around getziptastic's API v2

Project description

PyPI version License Python Versions Build Status Requirements Status

Author:

Tasdik Rahman

1 What is it?

Extract meta data like

  • city

  • state

  • county

  • location

    • latitude

    • longitude

  • Appropriate boundaries for that area

by just using the ZIPCODE and Country code

2 Features

  • Written in uncomplicated python

  • Supports all the Country codes specified in the ISO specification i.e all 264 countries where they have a pin code.

    You can find a list of all the country codes at the Wiki page

  • Gives ouput in a dict form or a JSON format

  • Fast and easy to use

3 Installation

3.1 Option 1: installing through pip (Suggested way)

pypi package link

$ pip install pyzipcode-cli

If you are behind a proxy

$ pip --proxy [username:password@]domain_name:port install pyzipcode-cli

Note: If you get command not found then $ sudo apt-get install python-pip should fix that

3.2 Option 2: Installing from source

$ git clone https://github.com/prodicus/pyzipcode-cli.git
$ cd pyzipcode-cli/
$ pip install -r requirements.txt
$ python setup.py install

4 Usage

4.1 query_ziptastic_api()

>>> from pyzipcode import Pyzipcode as pz
>>> pz.query_ziptastic_api(603203, "IN")
{
  "state_short": "25",
  "state": "Tamil Nadu",
  "county": "Kanchipuram",
  "postal_code": "603203",
  "city": "Kavanur",
  "country": "IN"
}
>>>

4.2 query_google_api()

>>> pz.query_google_api(603203, "IN")
{
  "location_type": "APPROXIMATE",
  "location": {
    "lng": 80.0199562,
    "lat": 12.8336666
  },
  "bounds": {
    "northeast": {
      "lng": 80.0572497,
      "lat": 12.8769479
    },
    "southwest": {
      "lng": 79.9504465,
      "lat": 12.7997355
    }
  }
}

4.3 get_data()

>>> pz.get_data(94305, "US")
{
  "google_maps": {
    "location_type": "APPROXIMATE",
    "location": {
      "lng": -122.1689284,
      "lat": 37.4135757
    },
    "bounds": {
      "northeast": {
        "lng": -122.1494501,
        "lat": 37.44363
      },
      "southwest": {
        "lng": -122.194849,
        "lat": 37.382743
      }
    }
  },
  "ziptastic": {
    "city": "Stanford",
    "state": "California",
    "postal_code": "94305",
    "state_short": "CA",
    "county": "Santa Clara",
    "country": "US"
  }
}

5 To-do

  • [ ] Support timezone extraction

  • [ ] Add cli-support

6 Contributing

Feel free to make a pull request. For that, please refer the Contributing page

7 Bugs

Please report the bugs at the issue tracker

8 Known Issues

  • The zipcodes for Argentina are not working for the release 0.1.3 as reported by DavidVentura on issue #1

9 License :

MIT License © Tasdik Rahman

You can find a copy of the License at http://prodicus.mit-license.org/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyzipcode-cli-0.1.3.tar.gz (3.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page