hurl2 icon indicating copy to clipboard operation
hurl2 copied to clipboard

API/URL Templates

Open jerryasher opened this issue 13 years ago • 3 comments

I'd like to create a template for an API that I will be visiting/debugging quite a bit. Every request in that API requires basic auth as well as an api_token. In my case, this would be the posterous api at http://posterous.com/api/2 and described/explored at http://posterous.com/api

It would be nice to be able to create a template for the entire API, perhaps consisting of a base url (posterous.com/api/2, default / mandatory parameters (api_token=urlencoded_token).

Then it would be nice to be able to create templates for each of the APIs themselves.

One value of this is that it would help keep authorization information or other private information out of your database.

jerryasher avatar Jan 08 '12 21:01 jerryasher

This was just recently added. If you include URL parameters that match the name of the input fields they will be pre-populated with that data. Example: http://hurl.it/?auth=basic&username=foo&password=bar

Does that satisfy your requirement?

johnsheehan avatar Jan 09 '12 21:01 johnsheehan

That's certainly a nice addition, and goes along ways, but not quite what I was thinking of.

api_token is a typical ugly thing "hoadyCIrgXXXXXXXXXXXXXXbDjcawnA", it would be nice to set it once, as some sort of api variable/constant and then just have it filled in the rest of the time.

Other apis use site_ids, and user_ids, and post_ids, and I can imagine that for testing an API, most of the time these are constant as well. (And long and ugly.)

It might be nice just to lay out a basic template for the api like

http://posterous.com/api/2?api_token=$api&site_id=$site_id&

Or maybe have the ability to add other input fields to the forms whose values are urlencoded and added in the GET or POST appropriately.

That way these things could be just supplied automatically, while the developers concentrate on the non-static elements of the request.

Does that make it a bit clearer?

jerryasher avatar Jan 09 '12 21:01 jerryasher

would be willing to consider accepting a pull request on this if someone wants to build it.

johnsheehan avatar Jan 09 '12 23:01 johnsheehan