0

I'm currently starting a project with this API, guitarparty. The problem is I don't how to use it.

for example, this line

curl -H 'Guitarparty-Api-Key: {API_KEY}' http://api.guitarparty.com/v2/songbooks/

I don't even know where I'm suppose to place it. Could someone show an example how to use it? Like, just to request a song.

The API seems really simple. The problem is I don't know how to start. Thanks.

The api docs are really short, but I don't understand where to start.

http://www.guitarparty.com/developers/api-docs/api-resources/songs/#available-song-methods

user1869558
  • 697
  • 3
  • 11
  • 21
  • 1
    Pray there are API docs, and read them. [`httpie`](https://github.com/jkbr/httpie) is your friend for command-line HTTP requests. – Matt Ball Mar 15 '13 at 22:05

1 Answers1

1

curl is a command line tool for working with HTTP and similar protocols. You can download it here: http://curl.haxx.se

The line is meant to be entered into a command-line on a system that has curl installed, perhaps on a Linux-like system. You may want to download curl and try just to follow along with the example.

However, the beauty of an API like this is that you don't need to use any particular tool -- you can use any tool you want, as long as you can set HTTP header values. Lots of different tools and modules can make HTTP requests.

The first thing you must do is to acquire an API key at the GuitarParty site. This is a key that will identify your application, and likely put some restrictions on e.g. how many queries you can run. Without one, you won't be allowed to use the API. You're meant to replace "{API_KEY}" in the above with an actual API key.

An example of a query (from the documentation) is:

curl -H 'Guitarparty-Api-Key: {API_KEY}' http://api.guitarparty.com/v2/songs/?query=Jolene

What's going on here is that curl is being used to make a normal GET request via HTTP. This is the sort of request your browser normally makes for you when you click on a link. The URL is "http://api.guitarparty.com/v2/songs/?query=Jolene" -- this is what you'd modify to search for songs other than 'Jolene'. The only weird thing that's happening is that a custom HTTP header value is being set: "Guitarparty-Api-Key", to the API key. -H is the curl syntax to do set a custom header.

In response, from the server, you will return a JSON-encoded structure with the result of the search. You will need to parse this structure and extract the parts you're interested in.

For getting into any sort of specifics -- how to make a HTTP request with special headers, how to parse JSON -- I'd have to know what sort of language or environment you're planning to work in. For Python, for instance, I'd advise you to look at the modules "urllib2" and "json".

svk
  • 5,854
  • 17
  • 22
  • JSON is a notation for data, not a programming language. It uses syntax like the programming language Javascript, thus the name (JavaScript Object Notation). Are you making a program that will run in Javascript? If so, you might start out with these links: http://www.json.org/js.html, http://eloquentjavascript.net/chapter14.html, http://stackoverflow.com/questions/581383/adding-custom-http-headers-using-javascript – svk Mar 15 '13 at 23:15
  • thanks for the links! the learning curve on http requests is pretty high. I've worked with GET, POST before, but it was some pretty basic stuff compared. https://github.com/stuycs-ml7/pd7-miniproject1/blob/master/Smirnov_Wu/app.py – user1869558 Mar 15 '13 at 23:30