Giter VIP home page Giter VIP logo

aqicn-sdk's Introduction

aqicn Python SDK

PyPI version

This library is implementation of Aqicn JSON API.

It also includes utility methods for scraping aqicn website (See: Utility methods).

Usage

You first need to create API token.

import aqicn

# API

api = aqicn.AqicnApi(secret="YOUR_KEY")

ip_based_data = api.get_feed()

# Utils

aqicn.utils.scrap_data_from_website()

Installation

With pip:

$ pip install aqicn

Manual:

$ pip install -e git+https://github.com/miczal/aqicn-sdk#egg=aqicn

Implemented API methods

API SDK
city/station feed get_feed
geo-localized feed (IP based) get_feed(station_name_or_station_id)
stations on the map (geo feed) get_location_feed(coord)
stations on the map (map query) get_stations_in_area(lower_left, upper_right)
search by name search(keyword)

Utility methods

Methods for scraping website. Useful to get e.g. available station names to JSON API.

Method Description
get_aqi_world_data() Scrapes current data directly from aqicn website and returns string with string in JSON format
scrap_data_from_website(adapter) Returns adapted data in JSON format from aqicn website. If no adapter is provided, default will be used in json.loads as object_hook argument
get_stations_data(key, fields_to_include, adapter) Returns dictionary of data for online stations with stations names as keys. Data to process is taken from scrap_data_from_website and includes only fields listed in fields_to_include. key argument is taken from JSON and serves as key to the resulting dictionary
get_stations_id_data Returns only dictionary with data for identification of all stations. ID is the dictionary's key.

TODO:

  • request method and status codes in readme
  • coordinates

aqicn-sdk's People

Contributors

miczal avatar

Watchers

Xilin Sun avatar James Cloos avatar

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.