Skip to main content

Python wrapper for using Apitalks API.

Project description

Apitalker

Upload Python Package Documentation Status

Table of Contents

About

Python3 library. Wrapper for Apitalks API calls. Enables simple calls for api resources with optional use of available parameters, as specified in Apitalks documentation.

Returned data (when method apitalker.api.API.get_data() is used) are handled by apitalker.data.Data class, which provides some convenient methods for working with data.

Documentation

Documentation is HERE.

Getting Started

These instructions will get you up and running.

Prerequisites

What things you need to install the software.

- Python 3+

Installing

To install this package, simply use standard pip install apitalker or clone this repo and run python setup.py install.

Usage

apitalker is used as any other library.

from apitalker.api import API

api = API("yourAPIkeygoeshere")
r = api.query([resource], [...params])

Returned data are treated as instance of a class ApiResponse.

Error messages in case there are some problems with api call, are handled by class ApiError.

Examples

apitalker.api module

apitalker.api.API.query()

Calls given API resource and returns one "page" of the data.

Call resource only, with no query parameters

As is specified in API documentation, without any query parameters provided, API call will return one "page" of results, which equals of maximum of 30 data entries and 0 "pages" will be skipped.

from apitalker.api import API

api = API("yourAPIkeygoeshere")
r = api.query("/czso.cz/lide-domy-byty")

Call resource with limited page size and skipped one page of the same size

from apitalker.api import API

api = API("yourAPIkeygoeshere")
r = api.query("/czso.cz/lide-domy-byty", limit=10, skip=10)

Returned data can be ordered

Pay attention to the quotes usage in the order parameter values!

from apitalker.api import API

api = API("yourAPIkeygoeshere")
r = api.query("/czso.cz/lide-domy-byty", limit=10, skip=10, order='"nazev ASC, u01 DESC"')

Other filtering is possible using where parameter

This is dependent on the data source.

from apitalker.api import API

api = API("yourAPIkeygoeshere")
r = api.query("/czso.cz/lide-domy-byty", where='"uzkod":568741, "year":1999')
apitalker.api.API.get_data()

Calls given API resource utilizing api.API.query() repeatedly and returns all data of given resource.

from apitalker.api import API

api = API("yourAPIkeygoeshere")
data, error = api.get_data("/czso.cz/lide-domy-byty")

apitalker.data module

apitalker.api.data.Data

Get all data from given resource

from pprint import PrettyPrinter
from apitalker.api import API

printer = PrettyPrinter(indent=2)
api = API("yourAPIkeygoeshere")

data, error = api.get_data(
    "/czso.cz/lide-domy-byty", where='"typuz_naz":"okres"', sleep=0.1
)

if error is None:
    printer.pprint(data.as_list)
    print(data.as_dataframe.head)

else:
    printer.pprint(error.response)

Save data in various file formats

from apitalker.api import API


api = API("yourAPIkeygoeshere")

data, error = api.get_data(
    "/czso.cz/lide-domy-byty", where='"typuz_naz":"okres"', sleep=0.1
)

if error is None:
    data.as_dataframe.to_json("filepath")
    data.as_dataframe.to_csv("filepath)

else:
    printer.pprint(error.response)

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

apitalker-0.6.2.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

apitalker-0.6.2-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

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