Skip to content

Web Service API

herestomwiththeweather edited this page Sep 13, 2010 · 22 revisions

Web Service API

Person

Returns information about the person including name, description, account balances, created_at, identity_url, icon. Although an array of accounts are returned, currently it is safe to assume that the array will contain exactly one account.

URL: http://demo.opensourcecurrency.org/people/%{color:red}person_id%

Formats: xml, json

Method: GET

Category

Returns information about the category including the name and the people (and their icons) who associate themselves with the skill category.

URL: http://demo.opensourcecurrency.org/categories/%{color:red}category_id%

Formats: xml, json

Method: GET

Exchange

Return the person’s earned credits sorted by most recent. Fields in each record include amount, customer_id, created_at, req_id. A new exchange (payment) can be created with a POST and the amount must be specified in the body. Optionally, to describe the nature of the exchange, a request object may be posted with the exchange object. See examples.

URL: http://demo.opensoucecurrency.org/people/%{color:red}person_id%/exchanges

Formats: xml, json

Method: GET, POST

Parent Resource:

  • person_id. Required. The numerical id of the person you are trying to retrieve (or the person you are paying if this is a POST)

GET Examples:

  • Get a person’s earned exchanges: http://demo.opensoucecurrency.org/people/%{color:red}person_id%/exchanges
  • Get an exchange: http://demo.opensoucecurrency.org/people/%{color:red}person_id%/exchanges/%{color:red}exchange_id%

POST Parameters:

  • amount. Required. Decimal amount of payment. Up to two places after the decimal accepted

JSON Examples:

  • Make a payment:
    {"exchange":{"amount":"33"},"req":{"name":"guitar lessons"}}
  • Make a payment. no details:
    {"exchange":{"amount":"33"}}

Req

Returns information about the request including name, description, due_date, estimated_hours, person_id, active (boolean), created_at

URL: http://demo.opensoucecurrency.org/reqs/%{color:red}req_id%

Formats: xml, json

Method: GET, POST

POST Parameters:

  • name
  • description
  • due_date
  • estimated_hours

New Protocol Ideas

Transaction

Accepts a list of transactions, an OAuth secret for the service, and an OAuth authentication token for the user. It attempts to perform the transactions and returns the results.

URL: http://demo.opensoucecurrency.org/transaction

Formats: json

Method: POST

POST Parameters:

  • service_secret – The OAuth secret obtained when the service was registered.
  • user_token – An OAuth token to be used in authenticating the user
  • transactions – A list of transactions

Transaction types:

Withdraw [amount] – Transfer [amount] from user account to service account
Returns success status, new balance
Deposit [amount] – Transfer [amount] from service account to user account
Returns success status, new balance
CheckBalance – Obtain the user’s current balance
Returns success status, current balance

Clone this wiki locally