hsreadability-1.0.0.0: Access to the Readability API.

Safe HaskellNone
LanguageHaskell2010

Network.Readability.Reader

Contents

Description

This module is an interface to the Readability's Reader API.

To get more info, visit https://www.readability.com/developers/api/reader.

Before performing any request, you should receive OAuth credentials. To do that, this module provides newOAuth as well as xauth for XAuth authorizations.

The full XAuth authorization process will be like:

let auth = newAuth
        { oauthConsumerKey = "consumer key" -- usually, your username
        , oauthConsumerSecret = "consumer token"
        }
credential <- xauth auth "username" "password"

Then you should pass auth and credential to any function in this module.

It's preferable not doing authentication every single time. The best way is to store received credential, so you can use it later.

If you don't have Reader Keys, visit https://www.readability.com/settings/account.

Synopsis

Authentication

OAuth

data OAuth :: *

Data type for OAuth client (consumer).

The constructor for this data type is not exposed. Instead, you should use the def method or newOAuth function to retrieve a default instance, and then use the records below to make modifications. This approach allows us to add configuration options without breaking backwards compatibility.

newOAuth :: OAuth Source

Default value for OAuth datatype. You must specify at least consumer key and secret.

Example usage:

myAuth = newOAuth
    { oauthConsumerKey = "consumer key"
    , oauthConsumerSecret = "consumer secret"
    }

oauthConsumerKey :: OAuth -> ByteString

Consumer key (You MUST specify)

oauthConsumerSecret :: OAuth -> ByteString

Consumer Secret (You MUST specify)

xauth Source

Arguments

:: OAuth

OAuth client

-> ByteString

Owner username

-> ByteString

Owner password

-> IO (Maybe Credential)

Token and secret

XAuth is used to receive OAuth token using owner's username and password directly.

In most cases, you should do your best to support OAuth proper.

OAuth Endoints

Article

Types

data Article Source

Constructors

Article 

Fields

content :: Maybe Text

The main content of the article (in HTML)

domain :: Maybe Text

Domain name of article host

author :: Maybe Text
 
url :: Text

URL of the article

short_url :: Maybe Text

Shortened URL provided by Readability Shortener

title :: Maybe Text
 
excerpt :: Maybe Text
 
direction :: Maybe Text

Text direction of article

word_count :: Integer
 
total_pages :: Maybe Integer

Total number of pages in article

date_published :: Maybe Text
 
dek :: Maybe Text
 
lead_image_url :: Maybe Text
 
next_page_id :: Maybe Text
 
rendered_pages :: Maybe Int
 

Requests

getArticle Source

Arguments

:: OAuth

Client OAuth

-> Credential

Access token and secret

-> ByteString

Article id

-> IO (Either String Article) 

Gets article by id.

This is a GET request to /articles/{articleId} endpoint.

Bookmarks

Types

defaultBookmarksFilters :: BookmarksFilters Source

This is a default value for BookmarksFilters. All fields are set to Nothing.

data Order Source

Constructors

DateAddedAsc

Sort by date added, asceding

DateAddedDesc

Sort by date added, desceding (this is default)

DateUpdatedAsc

Sort by date updated, asceding

DateUpdatedDesc

Sort by date updated, desceding

Requests

getBookmarks Source

Arguments

:: OAuth 
-> Credential 
-> BookmarksFilters 
-> Maybe Order 
-> Maybe Integer

Page

-> Maybe Integer

Per page

-> Maybe Bool

Only deleted

-> [String]

Tags

-> IO (Either String BookmarksResponse) 

Get all user bookmarks.

This is a GET request to /bookmarks.

addBookmark Source

Arguments

:: OAuth 
-> Credential 
-> ByteString

Article URL

-> Maybe Bool

Favorite

-> Maybe Bool

Archive

-> Maybe Bool

Allow duplicates

-> IO BookmarkLocation 

Add bookmark.

This is a POST request to /bookmarks.

getBookmark Source

Arguments

:: OAuth 
-> Credential 
-> Integer

Bookmark id

-> IO (Either String Bookmark) 

Get bookmark by id.

This is a GET request to /bookmarks/{bookmarkId}.

updateBookmark Source

Arguments

:: OAuth 
-> Credential 
-> Integer

Bookmark id

-> Maybe Bool

Favorite

-> Maybe Bool

Archive

-> Maybe Double

Read percent

-> IO (Either String Bookmark) 

Update bookmark.

This a POST request to /bookmarks/{bookmarkId}.

deleteBookmark Source

Arguments

:: OAuth 
-> Credential 
-> Integer

Bookmark id

-> IO (Response ByteString) 

Delete bookmark by id.

This is a DELETE request to /bookmarks/{bookmarkId}.

getBookmarkTags Source

Arguments

:: OAuth 
-> Credential 
-> Integer

Bookmark id

-> IO (Either String TagsResponse) 

Get bookmark tags

This is a GET request to /bookmarks/{bookmarkId}/tags.

addBookmarkTags Source

Arguments

:: OAuth 
-> Credential 
-> Integer

Bookmark id

-> [Text]

Tags

-> IO (Either String TagsResponse) 

Add tags to bookmark.

This is a POST request to /bookmarks/{bookmarkId}/tags.

deleteBookmarkTag Source

Arguments

:: OAuth 
-> Credential 
-> Integer

Bookmark id

-> Integer

Tag id

-> IO (Response ByteString) 

Delete given tag from bookmark.

This is a DELETE request to /bookmark/{bookmarkId}/tags/{tagId}.

Tags

Types

Requests

getTags :: OAuth -> Credential -> IO (Either String TagsResponse) Source

Retrieve all user tags.

This is a GET request to /tags.

getTag :: OAuth -> Credential -> Integer -> IO (Either String Tag) Source

Retrieve tag by id.

This is a GET request to /tags/{tagId}.

deleteTag :: OAuth -> Credential -> Integer -> IO (Response ByteString) Source

Delete tag by id.

This is a DELETE request to /tags/{tagId}.

User

Types

Requests

getUser :: OAuth -> Credential -> IO (Either String User) Source

Retrieve current user info.

This is a GET request to /user/_current.