An api wrapper for http://tldr.io/
This repository has been archived on 2026-09-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2013-04-10 23:53:51 -05:00
tldr added getLatestTldrsByCategory alias 2013-04-10 22:56:03 -05:00
.gitignore added getCategories w/ test and docs 2013-04-10 22:37:14 -05:00
AUTHORS init 2013-04-05 05:45:02 -05:00
LICENSE added license 2013-04-06 01:28:05 -05:00
MANIFEST.in restructure 2013-04-10 06:23:37 -05:00
readme.md updated readme 2013-04-10 23:53:51 -05:00
requirements.txt requirements 2013-04-06 01:21:56 -05:00
setup.py set real version number 2013-04-06 19:18:34 -05:00

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")