Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Url and http
1. URL and HTTP
• URL
– http://www.nyc.gov/html/doh/html/rii/index.shtml
– Is limited in what characters can be used – a black space “ “ is
represented by %20 in a URL
• HTTP - how resources are “fetched” on the web
• HTTP Request
– Request line (method = GET or PUT; path)
– Header (primarily referencing the host)
– Body (passing variables/selections; used in PUT)
2. HTTP Response
• This is the response that our http request
receives back from the web server (or host)
• Status – a numeric status (“404 code”)
• Headers – indication of what kind of content
• Body – the web page that is displayed
– HTML content, javascript, etc.
3. HTML / XML
• Encoding information on a webpage
• <b>This is bolded</b>
• <a href=“www.uky.edu”>A link to UK’s
webpage</a>
– Open and close tags
– Sets up patterns that can be parsed
5. Get vs. Put
• GET encodes the data entered by a user from
a webform in the URL
• POST passes the data entered by a user as a
set of variables.
– Much hard to see
8. A note about libraries
• Libraries are bits of pre-written code that
make common tasks easier
• But you have to load them before you run you
code
– gem install nokigiri (useful for parsing XML docs)
• Alternatively one could use regular expressions
– gem install httparty (useful for building http
queries)