Anyone working on developing an R package for KiteConnect API ?

shankarpandala
shankarpandala edited August 2017 in General
R is one of the mostly widely used programming language for Statistics and Data science.
I would like to know if anyone working on developing a R package for KiteConnect API ?

Anyone there at least help me get authenticated using R ?
Tagged:
  • Vivek
    We are not working on it but if there is a interest we will come up with a official client. For now I will leave it to the community.
  • shankarpandala
    Below is the sample code with which I am trying to authenticate,

    library(digest)
    require("httr")

    my_api <- "xxx"
    my_req_token <- 'yyy'
    my_secret <- 'zzz'

    check<-hmac(my_req_token,paste0(paste0(my_api,my_req_token),my_secret),algo=c('sha256'))

    url <- 'https://api.kite.trade/session/token'
    login <- list(api_key=my_api,
    request_token = my_req_token,
    checksum = check)

    response<- POST(url,body= login)
    This is the response I am receiving.
    > response
    Response [https://api.kite.trade/session/token]
    Date: 2017-08-27 12:34
    Status: 400
    Content-Type: application/json
    Size: 81 B

    > content(response, "parsed", "application/json")
    $status
    [1] "error"

    $message
    [1] "Missing api_key"

    $error_type
    [1] "InputException"
    Any help with this ?
  • tonystark
    tonystark edited August 2017
    Hi @shankarpandala,

    Try this:
    library(digest)
    require("httr")

    my_api <- "xxx"
    my_req_token <- 'yyy'
    my_secret <- 'zzz'

    #use digest insted of hmac; digest serializes argument first, use serialize arg to disable that
    check<-digest(paste0(my_api, my_req_token, my_secret), algo='sha256', serialize=FALSE)

    url <- 'https://api.kite.trade/session/token'
    login <- list(api_key=my_api,
    request_token = my_req_token,
    checksum = check)

    #post data should be sent as 'application/x-www-form-urlencoded', setting encode arg to form does this
    response<- POST(url,body= login, encode='form')

    content(response, "parsed", "application/json")
  • shankarpandala
    @ajinasokan Perfect!!

    This worked as it should be. Thanks for the help :smile:
This discussion has been closed.