Parliament Data API Wrapper (Ruby)

parliament-ruby is a gem created by the Parliamentary Digital Service to allow easy communication with the internal parliament data api.

Gem Build Status Test Coverage License

NOTE: This gem is in active development and is likely to change at short notice. It is not recommended that you use this in any production environment.



parliament-ruby requires the following:


This gem is currently not available on RubyGems. To use it in an application, install it directly from GitHub via your Gemfile

gem 'parliament', git: '', branch: 'master'


This gem's main function is fetching an n-triple file from a remote server and converting it into linked ruby objects.

Setting up a connection

In order to connect to a remote server, we first need to set a base_url value, from which we will build an 'endpoint'. The base_url should be the beginning of a url without the trailing slash. For example instead of

parliament = '')

Setting a base URL 'globally'

Within code you can set a global base URL using the following snippet.

Parliament::Request.base_url = ''

# The base_url should be set for all new objects #=> ''

# You can still override the base_url on an instance by instance basis '').base_url #=> ''

Alternatively, you can set the environment variable PARLIAMENT_BASE_URL on your machine and we will automatically use that.


Parliament::Request.base_url #=> nil #=> ''

Building an 'endpoint'

Now that we have a base_url set, we will want to build an 'endpoint' such as:

An endpoint is effectively just a full URL to an n-triple file on a remote server.

Building an endpoint is simple, once you have a Parliament::Request object, you do something like this:

parliament = '') #=>  #<Parliament::Request>

# target endpoint: ''

# target endpoint: ''

# target endpoint: ''

What's #get?

Once you've built your endpoint (parliament.people.current), we use the #get method to tell us you're finished building and ready to get the data.

Getting Started with Development

To clone the repository and set up the dependencies, run the following:

git clone
cd parliament-ruby
bundle install

Running the tests

We use RSpec as our testing framework and tests can be run using:

bundle exec rake


If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review.

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Ensure your changes are tested using Rspec
  6. Create a new Pull Request


parliament-ruby is licensed under the Open Parliament Licence.