Giter Site home page Giter Site logo

tldrio-python-client's Introduction

Python client for tldr.io's public API

Python client for tldr.io's public API (whose doc you can find here).

Installation

Via pip

pip install git+https://github.com/jhgaylor/tldrio-python-client.git

OR

Clone the repo

git clone https://github.com/jhgaylor/tldrio-python-client.git

Creating a client

from tldr.tldr import TLDRClient

client = TLDRClient("name", "key")

Getting the latest tldrs

The syntax is client.getLatestTldrs(number, params), where number is the number of tldrs you want to get (maximum 50) and params (optional) is a dictionary representing a query string. For example:

Returns a list of tldrs or error object

#latest 5 tldrs
tldrs = client.getLatestTldrs(5)
#latest 5 tldrs for category "tech-news"
tldrs = client.getLatestTldrs(5, parms={'category':"tech-news"})

Searching tldrs by url

The syntax is client.searchByUrl(url) where url is the url (figures ...) For example:

Returns a tldr or error object

tldr = client.searchByUrl('http://tldr.io')

Searching the tldrs for a batch of urls

The syntax is client.searchBatch(urls) where urls is an array of urls. You can't search for more than 50 tldrs at once. For example:

Returns a list of tldrs or error object

tldrs = client.searchBatch(['http://tldr.io', 'http://news.ycombinator.com/'])

Getting user data

The syntax is client.getUser(username) where username is the username of the target user. For example:

Returns a user or error object

user_data = client.getUser('jhgaylor')

Searching tldrs by user

The syntax is client.getUserTldrs(username) where username is the username of the author of the tldrs For example:

Returns a list of tldrs or error object

tldrs = client.getUserTldrs('jhgaylor')

Getting tldr categories

The syntax is client.getCategories() For example:

Returns a list of tldrs or error object

categories = client.getCategories()

The data format is:

[
    {
        "_id": "5150639a43aac5ab0b000001",
        "type": "category",
        "name": "Tech News",
        "slug": "tech-news"
    },
    ...
]

Getting tldr categories

The syntax is client.getLatestTldrsByCategory(number, category_slug) where number is the number of tldrs you want to get (maximum 50) and category_slug is the slug returned from /categories/ For example:

Returns a list of tldrs or error object

#alias for client.getLatestTldrs(5, params={'category':"tech-news"})
tldrs = client.getLatestTldrsByCategory(5, "tech-news")

tldrio-python-client's People

Contributors

jhgaylor avatar

Stargazers

Amit Singh Sethi avatar Darlin Alberto avatar victor felder avatar Jeff Triplett avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

tldrio-python-client's Issues

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.