Skip to content

How to use API

Pierre Bellon edited this page Oct 29, 2013 · 52 revisions

Supported format

Spending Stories API supports HTML & JSON format as output.

Checkout http://<your server host>/api/ on your server to browse and use the API.

Authentification

Some of the operation (flagged with *) require to be authenficated. This part explains how to use the auth.

Spending Stories authentifcation system is based on a simple token auth.

Entities

Stories

/api/stories/

GET, POST, HEAD, OPTIONS

Returns the list of all stories (see this wiki page for more information about stories).

  • GET /api/stories/ Will list every stories

  • GET /api/stories/?revelevance_for=30000 Will list every stories sorted by relevance.

  • POST /api/stories/

    Accepted format: JSON, x-form-encoded

    Will create a new story.

How to filter results ?

Results can be filtered using the following fields:

Name Type Description Possible values
sticky Boolean Will filter stories based on their sticky attribute. True,False,''
country String Will filter stories based on the given country The iso code of the wanted country, see /api/countries/ for more details.
currency String Will filter stories based on the given currency The iso code of the wanted currency, see /api/currencies/ for more details.
type String Will filter stories based on their type. over_one_year, discrete, see the wiki page for more details.
title String Will filter stories based on their title Title of an existing story
themes String Will filter stories based on their theme(s).

/api/stories/:id/

GET, PUT, DELETE, HEAD, OPTIONS, PATCH

Operation a single story.

Stories attributes
Name Type Description Example Writable ?
id Integer The story identifier 210
value Float The spending amount 360000.0
tite String The story's title "Shropshire council on iPads"
description String The story description 10e6
country String The story description 10e6
year Integer The story description 10e6
themes Array The story description 10e6
type String The story description 10e6
created_at Float The story description 10e6
current_value Float The story description 10e6
current_value_usd Float The story description 10e6
inflation_last_year Integer The story description 10e6

/api/stories-nested/

GET, PUT, DELETE, HEAD, OPTIONS, PATCH

Themes

/api/themes/

GET, HEAD, OPTIONS

/api/themes/:slug/

GET, HEAD, OPTIONS

Currencies

/api/currencies/

GET, HEAD, OPTIONS

/api/currencies/:id/

GET, HEAD, OPTIONS

Countries

/api/countries/

GET, HEAD, OPTIONS

Filters

/api/filters/

GET, HEAD, OPTIONS

Clone this wiki locally