GithubHelp home page GithubHelp logo

isabella232 / httparty Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shopify/httparty

0.0 0.0 0.0 1.35 MB

:tada: Makes http fun again!

License: MIT License

Ruby 92.64% Shell 0.32% HTML 0.95% CSS 0.83% Gherkin 5.27%

httparty's Introduction

httparty

Makes http fun again! Ain't no party like a httparty, because a httparty don't stop.

Install

gem install httparty

Requirements

  • Ruby 2.0.0 or higher
  • multi_xml
  • You like to party!

Examples

# Use the class methods to get down to business quickly
response = HTTParty.get('http://api.stackexchange.com/2.2/questions?site=stackoverflow')

puts response.body, response.code, response.message, response.headers.inspect

# Or wrap things up in your own class
class StackExchange
  include HTTParty
  base_uri 'api.stackexchange.com'

  def initialize(service, page)
    @options = { query: { site: service, page: page } }
  end

  def questions
    self.class.get("/2.2/questions", @options)
  end

  def users
    self.class.get("/2.2/users", @options)
  end
end

stack_exchange = StackExchange.new("stackoverflow", 1)
puts stack_exchange.questions
puts stack_exchange.users

See the examples directory for even more goodies.

Command Line Interface

httparty also includes the executable httparty which can be used to query web services and examine the resulting output. By default it will output the response as a pretty-printed Ruby object (useful for grokking the structure of output). This can also be overridden to output formatted XML or JSON. Execute httparty --help for all the options. Below is an example of how easy it is.

httparty "https://api.stackexchange.com/2.2/questions?site=stackoverflow"

Help and Docs

Contributing

  • Fork the project.
  • Run bundle
  • Run bundle exec rake
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Run bundle exec rake (No, REALLY :))
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

httparty's People

Contributors

ajitsing avatar barberj avatar bmuller avatar caselas avatar davidgg avatar dpetersen avatar emiliocristalli avatar gareth avatar greatuserongithub avatar greggersh avatar hydrogen18 avatar jbgutierrez avatar jnunemaker avatar jonmidhir avatar jqr avatar kalmanh avatar kurenn avatar lucasuyezu avatar mikeastock avatar mkroman avatar nysthee avatar olivere avatar plusplus avatar rsullivan00 avatar rubygeek avatar sandro avatar springerigor avatar supremebeing7 avatar theflow avatar thesmartnik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.