Daiwik Daarun Daiwik Daarun - 24 days ago 6
reST (reStructuredText) Question

How to make basic REST API calls using a browser

I am trying to get started with REST API calls by seeing how to format the API calls using a browser. Most examples I have found online use SDKs or just return all fields for a request.

For example, I am trying to use the Soundcloud API to view track information.

To start, I've made a simple request in the browser as follows

http://api.soundcloud.com/tracks/13158665.json?client_id=31a9f4a3314c219bd5c79393a8a569ec
which returns a bunch of info about the track in JSON format

(e.g.
{"kind":"track","id":13158665,"created_at":"2011/04/06 15:37:43 ...}
)

Is it possible to only to get returned the "created_at" value using the browser? I apologize if this question is basic, but I don't know what keywords to search online. Links to basic guides would be nice, although I would prefer to stay out of using a specific SDK for the time being.

Answer

In fact, it's really hard to answer such question since it depends on the Web APIs. I mean if the API supports to return only a subset of fields, you could but if not, you will receive all the content. From what I saw on the documentation, it's not possible. The filters only allow you to get a subset of elements and not control the list of returned fields within elements.

Notice that you have a great application to execute HTTP requests (and also REST) in Chrome: Postman. This allows to execute all HTTP methods and not only GET ones and controls the headers and sent content and also see what is received back.

If you use Firefox, Firebug provides a similar thing.

To finish, you could have a look at this link to find out hints about the way Web APIs work and are designed: https://templth.wordpress.com/2014/12/15/designing-a-web-api/.

Hope it helps you and I answered you question, Thierry