Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Content API layer for GOV.UK
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
config Add airbrake support.
lib Completed Transaction has optional content
test Completed Transaction has optional content
.gitignore Configure Rack::Cache from a YAML file.
.ruby-version
.travis.yml
CONTRIBUTING.md Define contributing guide
Gemfile Use content models with presentation toggles
Gemfile.lock Use content models with presentation toggles
README.md Fix "placed" typo
Rakefile
config.rb Merge pull request #184 from alphagov/remove_exception_mailer
config.ru Don't worry if there's no cache config
console Add a `console` script for interactive hackery.
env.rb
govuk_content_api.rb
jenkins.sh Drop test database before running tests.
jenkins_branches.sh
mongoid.yml Drop test database before running tests.
rack-cache.heap.yml
rack-cache.memcached.yml Add example memcached configuration for Rack::Cache
startup.sh Remove reference to Rabl

README.md

GOV.UK Content API

The content API provides a read-only API layer to access information about any content on GOV.UK; it is how front-end applications (such as frontend and Smart Answers) access content, metadata and search.

Testing

Run the following to ensure your environment is set up correctly:

bundle install && bundle exec rake

Caching

To enable caching in development, you'll need to pick a caching backend by symlinking one of the Rack::Cache config files. For instance, to set up a memory-backed cache:

ln -s rack-cache.heap.yml rack-cache.yml

Then, to run the server:

API_CACHE=1 bundle exec rackup -p 3022

If you have access to the development repository, run

API_CACHE=1 bowl contentapi

or

API_CACHE=1 foreman start contentapi

Asset Manager

If your models include media assets such as images and video, you will need to run the asset-manager app alongside the content api.

See the asset-manager project for app-specific setup instructions.

Content API needs an OAuth bearer token in order to authenticate with Asset Manager. By default, this is loaded from the CONTENTAPI_ASSET_MANAGER_BEARER_TOKEN environment variable in config/initializers/gds_api.rb.

To obtain this bearer token, you will first need to generate OAuth keys for the content API application. In the signonotron2 directory, run:

rake applications:create name=contentapi description="content api" home_uri="http://contentapi.dev" redirect_uri="http://contentapi.dev/auth/gds/callback"

The provided OAuth tokens should be placed into the CONTENTAPI_OAUTH_ID and CONTENTAPI_OAUTH_SECRET environment variables

You can then create an API user in the signonotron2 application.

rake api_clients:create[contentapi,contentapi@example.com,asset-manager,signin]

This will generate the bearer token you need.

Something went wrong with that request. Please try again.