The VKHS package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.



Provides access to Vkontakte API methods. Library requires no interaction with the user during Implicit-flow authentication.

[Skip to ReadMe]


Versions0.0.1, 0.0.2, 0.0.3, 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.5.7, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.7.0, 1.7.1, 1.7.1, 1.7.2
Dependenciesaeson, aeson-pretty, base (>=4.6 && <5), bytestring, case-insensitive, clock, containers, data-default-class, directory, filepath, http-client, http-client-tls, http-types, mtl, network-uri, optparse-applicative, parsec, pipes, pipes-http, pretty-show, regexpr, split, taglib, tagsoup, text, time, utf8-string, vector [details]
CopyrightCopyright (c) 2012, Sergey Mironov
AuthorSergey Mironov
Home page
UploadedMon Aug 8 20:51:09 UTC 2016 by SergeyMironov



Maintainers' corner

For package maintainers and hackage trustees

Readme for VKHS-1.7.1


VKHS provides access to Vkontakte social network, popular mainly in Russia. Library can be used to login into the network as a standalone application (OAuth implicit flow as they call it). Having the access token, it is possible to call various API methods to query audio files or retrieve wall messages. For now, vkhs offers limited error detection and no captcha support.


In order to install VKHS, type:

$ cabal update
$ cabal install VKHS

Note, that VKHS uses curlhs and should be linked with Normally, cabal handles it without problems.


VKQ is a command line tool which demonstrates API usage. It can be used for logging in, downloading music and reading wall messages.

Log in

Here is an example session: Login first

]$ vkq login pass123

VKQ returns three values. First is a access token which is required to execute future API requests. VKQ reads it from VKQ_ACCESS_TOKEN environment variable so we have to set it up

$ export VKQ_ACCESS_TOKEN=d785932b871f096bd73aac6a35d7a7c469dd788d796463a871e5beb5c61bc6c96788ec2

Download audio

Now, lets list first 10 audio files I have:

$ vkq music -l | head -n 10
910727_456939044 Алёнушка 1989 муз Никиты Богословского - ст Александра Коваленкова
910727_456939043 Первое апреля
910727_456939042 Травы травы травы не успели от росы серебрянной согнуться и такие нежные напевы почему-то прямо в сердце льются
910727_456939041 Moving On
910727_456939038  Не для меня придёт весна
910727_456939037 Каждый выбирает для себя
910727_456939034 Black Fortress Kings Bounty Dark Side OST
910727_456939031 Вокализ минус пример
910727_456939040  Без названия
910727_456939028 The Extasy of Gold

Ok, the link can be used to download the file using wget, but vkq offers some renaming options, so lets use the latter instead:

$ vkq music -o . 910727_456939043 910727_456939031
Polite Dance Song
./The Bird And The Bee - Polite Dance Song.mp3
L'estasi Dell'oro (The Ecstasy Of Gold)
./Ennio Morricone - Lestasi Delloro The Ecstasy Of Gold.mp3

Polite dance song and Ecstasy of gold mp3s will appear in the current folder.

Custom API calls

vkq allows user to call arbitrary API method. The format is as follows:

Usage: vkq call [--verbose] [--req-per-sec N] [--interactive] [--appid APPID]
                [--user USER] [--pass PASS] [-a ACCESS_TOKEN] METHOD PARAMS

For example, lets call method to get some Beatles records:

$ vkq call q=Beatles --pretty

  { "response": [
        "lyrics_id": "6604412",
        "url": "",
        "aid": 85031440,
        "title": "Twist and Shout  ",
        "genre": 1,
        "owner_id": 9559206,
        "duration": 156,
        "artist": "The Beatles"

VKHS library

Please, consult the source code of the vkq application.

Note: Outdated content below

Following example illustrates basic usage (please fill client_id, email and password with correct values):

import Web.VKHS.Login
import Web.VKHS.API

main = do
    let client_id = "111111"
    let e = env client_id "" "password" [Photos,Audio,Groups]
    (Right at) <- login e

    let user_of_interest = "222222"
    (Right ans) <- api e at "users.get" [
        , ("fields","first_name,last_name,nickname,screen_name")
        , ("name_case","nom")
    putStrLn ans

client_id is an application identifier, provided by Users receive it after registering their applications after SMS confirmation. Registration form is located here.

Internally, library uses small curl-based HTTP automata and tagsoup for jumping over relocations and submitting various 'Yes I agree' forms. Curl .so library is required for vkhs to work. I am using curl-7.26.0 on my system.


RepatedForm message means that VKHS tries to fill the web form with available data, but the form appears again. Typically, that means that the password wa invalid or captcha is required.

Note: Outdated content below

To authenticate the user, vkhs acts like a browser: it analyzes html but fills all forms by itself instead of displaying pages. Of cause, would change html design, things stop working.

To deal with that potential problem, Ive included some debugging facilities: changing:


(Right at) <- login e { verbose = Debug }

will trigger curl output plus html dumping to the current directory. Please, mail those .html to me if problem appears.



BSD3 license

Copyright (c) 2014, Sergey Mironov