Project

General

Profile

Rest api » History » Version 25

Jean-Philippe Lang, 2010-12-23 15:20

1 1 Jean-Philippe Lang
h1. Redmine API
2
3
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.
4
5
h2. API Description
6
7 24 Jean-Philippe Lang
|_.Resource                     |_.Status     |_.Notes  |_.Availability|
8
|[[Rest_Issues|Issues]]         | Beta        | Usable with some bugs and rough edges.  | 1.0 |
9
|[[Rest_Projects|Projects]]     | Beta        | Usable with some bugs and rough edges.  | 1.0 |
10
|[[Rest_Users|Users]]           | Planned | | 1.1 |
11
|[[Rest_TimeEntries|TimeEntries]]           | Planned | | 1.1 |
12
|[[Rest_News|News]]             | Prototype, Planned | Prototype implementation for @index@ only | 1.1 |
13
|[[Rest_WikiPages|Wiki Pages]]  | Planned | | 1.2 |
14
15 15 Eric Davis
Status legend:
16 1 Jean-Philippe Lang
17
* Stable - feature complete, no major changes planned
18
* Beta - usable for integrations with some bugs or missing minor functionality
19
* Alpha - major functionality in place, needs feedback from API users and integrators
20
* Prototype - very rough implementation, possible major breaking changes mid-version. *Not recommended for integration*
21
* Planned - planned in a future version, depending on developer availability
22
23 24 Jean-Philippe Lang
h2. General topics
24 1 Jean-Philippe Lang
25 24 Jean-Philippe Lang
h3. Authentication
26
27
Most of the time, the API requires authentication. To enable the API-style authentication, you have to check *Enable REST API* in Administration -> Settings -> Authentication. Then, authentication can be done in 2 different ways:
28
* using your regular login/password via HTTP Basic authentication.
29
* using your API key which is a handy way to avoid putting a password in a script. The API key may be attached to each request as a "key" parameter or it may be passed in as a username with a random password. You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the default layout.
30
31
h3. Collection resources and pagination
32
33
The response to a GET request on a collection ressources (eg. @/issues.xml@, @/users.xml@) generally won't return all the objets available in your database. Redmine version:1.1.0 introduces a common way to query such ressources using the following parameters:
34
35
* @offset@: the offset of the first object to retrieve
36
* @limit@: the number of items to be present in the response (default is 25, maximum is 100)
37
38 25 Jean-Philippe Lang
Alternatively, you can use the @page@ parameter, instead of @offset@, in conjunction with @limit@.
39 24 Jean-Philippe Lang
40
Examples:
41
42
<pre>
43
GET /issues.xml
44
=> returns the 25 first issues
45
46
GET /issues.xml?limit=100
47
=> returns the 100 first issues
48
49
GET /issues.xml?offset=30&limit=10
50
=> returns 10 issues from the 30th
51
52
GET /issues.xml?page=3&limit=10
53
=> same as above
54
</pre>
55
56
Responses to GET requests on collection ressources provide information about the total object count available in Redmine and the offset/limit used for the response. Examples:
57
58
<pre>
59
GET /issues.xml
60
61
<issues type="array" total_count="2595" limit="25" offset="0">
62
  ...
63
</issues>
64
</pre>
65
66
<pre>
67
GET /issues.json
68
69
{ "issues":[...], "total_count":2595, "limit":25, "offset":0 }
70
</pre>
71
72
Note: if you're using a REST client that does not support such top level attributes (total_count, limit, offset), you can set the @nometa@ parameter or @X-Redmine-Nometa@ HTTP header to 1 to get responses without them. Example:
73
74
<pre>
75
GET /issues.xml?nometa=1
76
77
<issues type="array">
78
  ...
79
</issues>
80
</pre>
81 23 Jean-Philippe Lang
82 1 Jean-Philippe Lang
h2. API Usage in various languages/tools
83 5 Jean-Philippe Lang
84 1 Jean-Philippe Lang
* [[Rest_api_with_ruby|Ruby]]
85
* [[Rest_api_with_php|PHP]]
86 23 Jean-Philippe Lang
* [[Rest_api_with_python|Python]]
87 1 Jean-Philippe Lang
* [[Rest_api_with_curl|cURL]]