nookedbeta

API - Accounts

March 27th, 2008

Account APIs

Creating an account

New user accounts can be created by sending a HTTP POST request to the platform with details for the new user.

URL

https://api.nooked.com/v1/users.xml

Authentication

No authentication data is needed.

Request

Send a POST request to this URL with the following parameters:

  • user[login]=<LOGIN> - where '<LOGIN>' is the requested user login name (string)
    '<LOGIN>' must be at least 2 characters long
    '<LOGIN>' must be unique
  • user[:password]=<PASSWORD> - where '<PASSWORD>' is the requested user password (string)
    '<PASSWORD>' must be at least 5 characters long
  • user[email]=<EMAIL> - where '<EMAIL>' is the requested user email address (string)
    '<EMAIL>' must be a correctly formatted e-mail address

Response

Platform responds with a HTTP Status code indicating the success of the request:

  • 201 Created - The account was successfully created. The body of the response message will contain the API Key generated for this account (for use as an alternative to HTTP Basic Authentication).
  • 400 Bad Request - Account creation failed. The login or email strings may already be in use by another account or some other data is not valid. The body of the response will be an XML message indicating the error condition.

Example: Correct account creation request

Request:

Http method: POST
URL: https://api.nooked.com/v1/users.xml

Request data:

user[login]=new_login&user[password]=password1234&user[email]=correct.email@nooked.com

Response Header:

Status: 201 Created

Response Body:

empty

Example: Incorrect account creation request

Request:

Http method: POST
URL: https://api.nooked.com/v1/users.xml

Request data:

user[login]=new_login&user[password]=password1234&user[email]=wrong@email@address

Response Header:

Status: 400 Bad Request

Response Body:

<?xml version="1.0" encoding="UTF-8"?>
<errors> 
  <error>Password is too short (minimum is 5 characters)</error>
</errors>

Discovering feeds/collections

Each nooked account can own many Feeds (or Collections in AtomPub terminology). Each account has a public AtomPub Service document that can be used to browse the list of feeds (collections) associated with that account. When developing a client that needs to dynamically discover the feeds the client should send a HTTP GET request to the appropriate Service document URL. The Feed Platform will return an AtomPub Service Document

URL

The URL of your Service document is available from your My Feeds page. The Service document URL contains this path and also an additional path segment consisting of an ID (an integer), a dash ('-') and your login. For example, a Service document URL might look like 'http://api.nooked.com/v1/services/78-RetailerX'

Authentication

No authentication is needed. Document is available in public.

Request

Send a GET request to this URL.

Responses

The platform responds with a 200 OK status code with the body containing something like the following content:

<?xml version="1.0" encoding="UTF-8"?>
<service xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://www.w3.org/2007/app">
  <workspace>
    <atom:title>Retailer X's Service Workspace</atom:title>
    <collection href="http://api.nooked.com/v1/feeds/1-Our-Product-Listing.app">
      <atom:title>Our Product Listing</atom:title>
      <accept>application/atom+xml;type=entry</accept>
    </collection>
  </workspace>
</service>

NOTE: The 'Content-Type' header of the HTTP response to GET requests to Service document URLs are 'application/atomsvc+xml' as prescribed in the AtomPub specification. Most internet browsers don't yet have built in support for this content type so you will prompted to download the file if you try to visit it in your browser. The contents of the file are simple XML and can be viewed in any text editor and of course, parsed by client applications!

This is a standard AtomPub API. See the section 5.1 of the AtomPub specification for full details.

Example: Correct feed discovery request

Request:

Http method: GET
URL: http://api.nooked.com/v1/services/<SERVICE_ID> - where <SERVICE_ID> consists of an ID (an integer), a dash ('-') and your login. For example, a Service document URL might look like http://api.nooked.com/v1/services/78-RetailerX

Request data:

no data is needed

Response Header:

Status: 200 OK

Response Body:

<?xml version="1.0" encoding="UTF-8"?>
<service xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://www.w3.org/2007/app">
  <workspace>
    <atom:title>xiazek's Service Workspace</atom:title>
    <collection href="http://api.nooked.com/v1/feeds/1-demo.app">
      <atom:title>Demo</atom:title>
      <accept>application/atom+xml;type=entry</accept>
    </collection>
  </workspace>
</service>

Example: Incorrect feed discovery request

Request:

Http method: GET
URL: http://api.nooked.com/v1/services/99999

Request data:

empty

Response Header:

Status: 400 Bad Request

Response Body:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
  <error>Wrong SERVICE_ID</error>
</errors>