summary refs log tree commit diff
path: root/spec/spore_description.pod
blob: 5d921a9cc0dfaac899a252da80fa4b875b834858 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
=encoding utf-8

=head1 NAME

Spore (Specifications to a POrtable Rest Environment) Description Implementation

=head1 ABSTRACT

Spore is a specification for describing ReST API that can be parsed and used
automatically by client implementations to communicate with the descibed API.

This document describes how to write the description for a ReST API in
order to be used with a SPORE Client Implementation.

=head1 TERMINOLOGY

=over 4

=item API

An I<API> is a ReST application that can exchange data with client
applications over http/https. It presents one or more method endpoints which
accept http requests with varying headers, parameters and body content to
perform specific operations.

=item Client implementation

A I<Client implementation> is a library targeting a specific system or
language. It can use I<Descriptions files> to create programmatic interfaces
usable in applications.

=item Description file

A I<Description file> is a file in JSON format describing an I<API> (see
specification). It can directly be used by a  I<Client implementation> to
create a programmatic interface in the target system.

=back

=head1 API DESCRIPTION

An API should provide a description file. The description should be in JSON
format.

XXX all the example should be changes to use valid json fragments instead of yaml.
I've noted the obvious cases (lists) but the others also need changing to add double quotes etc.

=head2 GENERIC DESCRIPTION

This part describes the API itself:

=over 4

=item B<name> (optional)

A simple name to describe the specification

    name: CouchDB

=item B<author> (optional)

A list of authors for this specification

    author:
      - franck cuny <franck@lumberjaph.net>

XXX yaml remnant. should it be an json array? can it be a simple string?

=item B<api_base_url> (optional)

If the API has a fixed URL

    api_base_url: http://api.twitter.com/1/

XXX should it end with "/"? twitter.json doesn't.

=item B<api_format> (optional)

A list of supported format

    api_format:
      - json
      - xml

XXX what does "supported format" actually mean? What's the effect? Is it really a list?

=item B<version> (optinal)

The version number of the current description

    version: 0.1

XXX clarify type (string/numeric). twitter.json has a string. Any semantics or just for documentation?

=item B<authentication> (optional)

A boolean to specify if this API requires authentication for all the methods

    authentication: 1

=item B<methods> (required)

A list of methods

XXX list? twitter.json has a hash

=back

The desciption B<MUST> contain a list of at least one method

=head2 METHOD DESCRIPTION

A method must have a name, which is the key of the C<methods> hash described above:

    public_timeline

=over 4

=item B<method> (required)

An HTTP method

    method: GET

=item B<path> (required)

Path for the given method. The path can contain I<placeholders>. A placeholder
B<MUST> begin with a <:>:

    path: /statuses/public_timeline.:format

XXX How can non-placeholder :foo's be included in the path? ie is there an escape mechanism?
What happens in this example if 'format' isn't listed in params?

=item B<params> (optional)

A list of optional parameters (also see C<required> below).
This list will be used to replace value in placeholders,
and if not used in the path, will be added to the query

    params:
      - trim_user
      - include_entities

XXX yaml

=item B<required> (optional)

A list of required parameters. Parameters that are required B<MUST NOT> be
repeated in the B<params> field

    required:
      - format

XXX yaml

=item B<expected> (optional)

A list of accepted HTTP status for this method

    expected:
      - 200

XXX what are the semantics of this? ie does it mean that an exception will be
thrown if some other status is returned?

=item B<description> (optional)

A simple description for the method. This should not be considered as
documentation.

    description: Returns the 20 most recent statuses, including retweets if they exist, from non-protected users

=item B<authentication> (optional)

A boolean to specify if this method requires authentication

    authentication: 0

=item B<base_url> (optional)

Specify an url if this method requires a different api_base_url

    base_url: http://api.twitter.com/1/

XXX trailing slash?

=item B<format> (optional)

A list of supported formats for this method, if different to C<api_format>:

    format:
      - json
      - xml

=item B<documentation> (optional)

A complete documentation for the given method

    documentation: The public timeline is cached for 60 seconds. Requesting more frequently than that will not return any more data, and will count against your rate limit usage.

=back

=head3 SAMPLE

A description for the twitter API (only the API description part and the first method):

    {
        "api_base_url" : "http://api.twitter.com/1",
        "version" : "0.1",
        "methods" : {
            "public_timeline" : {
                "params" : [
                    "trim_user",
                    "include_entities"
                ],
                "required" : [
                    "format"
                ],
                "path" : "/statuses/public_timeline.:format",
                "method" : "GET"
            },
        }
    }

=head3 CALLS

=head1 CHANGELOGS

0.1: 2010.10.xx

=over 4

=item *

Initial version.

=back

=head1 ACKNOWLEDGEMENTS

Some parts of this specification are adopted from the following specifications.

=over 4

=item *

PSGI Specification L<PSGI|http://search.cpan.org/perldoc?PSGI>

=item *

PEP333 Python Web Server Gateway Interface L<http://www.python.org/dev/peps/pep-0333>

=item *

Rack L<http://rack.rubyforge.org/doc/SPEC.html>

=item *

JSGI Specification L<http://jackjs.org/jsgi-spec.html>

=back

I'd like to thank authors of these great documents.

=head1 AUTHOR

=over 4

=item franck cuny

=item nils grunwald

=back

=head1 CONTRIBUTORS

=over 4

=item damien "bl0b" leroux

=back

=head1 COPYRIGHT AND LICENSE

Copyright XXX, 2010.

This document is licensed under the Creative Commons license by-sa.

=cut