Rest api » History » Revision 5
Revision 4 (Jean-Philippe Lang, 2010-01-14 20:55) → Revision 5/102 (Jean-Philippe Lang, 2010-01-17 20:47)
h1. Redmine API Redmine exposes some of its data through a REST API. This API provides access and basic CRUD operations (create, update, delete) for the resources described below. Most of the time, the API requires authentication. This is done via HTTP Basic authentication using the regular Redmine accounts. To enable this API-style authentication, check *Enable REST API* in Administration -> Settings -> Authentication. _At the time of writing, the API is only available in trunk (see r3310, r3313)._ h2. API Description * [[Rest_Issues|Issues]] * [[Rest_Projects|Projects]] h2. API Usage * [[Rest_api_with_ruby|Ruby]] h3. Ruby Redmine REST API follows the Rails's RESTful conventions, so using it with "ActiveResource":http://api.rubyonrails.org/classes/ActiveResource/Base.html is pretty straightforward. Here is a simple ruby script that demonstrates how to use the Redmine REST API: <pre> * [[Rest_api_with_php|PHP]] <code class="ruby"> require 'rubygems' require 'active_resource' # Issue model on the client side class Issue < ActiveResource::Base self.site = 'http://redmine.server/' self.user = 'foo' self.password = 'bar' end # Retrieving issues issues = Issue.find(:all) puts issues.first.subject # Retrieving an issue issue = Issue.find(1) puts issue.description puts issue.author.name # Creating an issue issue = Issue.new(:subject => 'REST API', :assigned_to_id => 1, :project_id => 1) if issue.save puts issue.id else puts issue.errors.full_messages end # Updating an issue issue = Issue.find(1) issue.subject = 'REST API' issue.save # Deleting an issue issue = Issue.find(1) issue.destroy </code> </pre>