Seeing an API in a different format than the tutorial

Hi Alex, I am trying to apply the API method I saw in the craigslist tutorial to this: http://www.ersatzlabs.com/documentation/api/ (scroll down to very bottom under CNN) It gave me this POST example that uses "curl". Do you know how curl is plays into all of this? I'm unfamiliar with it. Below is the "POST" example, but unsure which subdirectory this should go in the rails framework: curl -H "Content-Type: multipart/form-data" \ --form file-0=@catpic.jpg --form iterations="[16523]" \ "http://api.ersatzlabs.com/api/predict/?key=d3ece19addabd7b9c6a7d8d8b89e31ae41eda8e4"

Posted over 4 years ago by Jeremy Molayem
Posted over 4 years ago by Alex Yang

cUrl is just another way to submit requests to URLs. That's exactly what you do when interacting with an API, which is why you'll frequently see it as one of the many options in API documentation (e.g. cUrl, Ruby, Python, etc). It looks like the API you're using only has examples using cUrl unfortunately.

Here's a quick example: if you type 'curl www.google.com' in your command line, you'll be submitting a GET request to the Google homepage and you should be able to see the code for the page in your terminal. Similarly, you can use cUrl to make POST requests to submit a variety of data along with your request to a specific URL. You'll want to read up more on cUrl so you can better understand the documentation for the API you're trying to use. Here are a couple helpful links:
http://en.wikipedia.org/wiki/CURL
http://curl.haxx.se/docs/httpscripting.html

Hope that helps!

1