Forum Discussion

luk's avatar
luk
Boss
10 years ago

APIv2 directly from browser.

(In response to this article) I'm not quite sure if this is related to the issue I'm facing, but could be:

 

With API v1 it was always possible to access the api directly from the browser, e.g. with

 

http://community.lithium.com/restapi/vc

 

already this basic call (you can then put whatever api call you want behind the "vc", e.g. http://community.lithium.com/restapi/vc/<your_api_call>) gives back a response that contains all categories and some other stuff about the community...this is very helpful when debugging things as the actual response can be analyzed.

 

I thought it should be possible the same way with API v2 with a base url like

 

http://community.lithium.com/restapi/v2

 

but there is nothing coming back than a error 500 (sometimes a 403), tried various things like adding a query (urlencoded for sure) like http://community.lithium.com/restapi/v2/?q=SELECT%20count(*)%20FROM%20messages%20WHERE%20depth%20%3D%200

 

but no luck...am I maybe trying to use the wrong url or this this not possible at all with API v2 without implementing the oAuth flow described above??

 

PS: I'm aware of the API Browser in the backend, but it's about accessing the API v2 via browser address bar directly

 

EDIT: I guess/hope I found the "problem", it's described here: http://community.lithium.com/t5/Community-API-v2/Getting-started/ta-p/113193 in the section "Make a LiQL query over HTTP", looks like 1) the URL to call is different, e.g.

 

http://<eu (depending if your community is hosted in Amsterdam or in the US)>.api.lithium.com/community/2.0/search?q=<query>&client_id=<this_is_the_problem>&api.pretty_print=true

 

and we need to request that client_id from Lithium support...did that but no response yet, so can't tell if this is really the issue, but most likely =)

    • JeffY's avatar
      JeffY
      Lithium Alumni (Retired)

      Hi dhiraj_gophane -- While that approach may work temporarily, it is not officially supported and will likely be turned off in the future.   The officially supported path is to use OAuth via the API proxy. 

    • luk's avatar
      luk
      Boss
      Yes, but it's not very intuitive/consistent =)
      • JeffY's avatar
        JeffY
        Lithium Alumni (Retired)

        Hi Luk -- Sorry for the confusion.  You are correct that to access API v2 over HTTP you need to use OAuth and a different base URL than v1.  The reason is actually to simplify the developer experience.  All Lithium APIs whether from community, LSW,  LSI, or any other product will, going forward, use the same base URL (which points to an API proxy on our end) and use the same authentication mechanism.  This should make it easier for developers to leverage the full suite of Lithium APIs.  Further, by creating a proxy, we're able to scale easier and monitor better which means improved uptime and reliability.   Thanks for bearing with us during the transition.