MongoDB REST Interface

MongoDB provides rest interface for basic observation of server status. The URL for rest interface is "port+1000".

For example, if you specify the mongodb port with 10000, the rest interface URL will be http://localhost:11000.



Remember, if you want to use rest interface, you have to specify "--rest" parameter when start up a mongodb instance.

(Image Source : http://www.mongodb.org/display/DOCS/Http+Interface)

There are several useful REST method for get useful information:

1. Get the content of a collection

  • http://localhost:11000/dbName/collecitonName/
  • ex:http://localhost:11000/blog/post/ (Show all post content)


2. Get limited number of content

  • http://localhost:11000/dbName/collecitonName/?limit=number
  • ex:http://localhost:11000/blog/post/?limit=10 (Show top 10 post content)


3. Skip numbers of content

  • http://localhost:11000/dbName/collectionName/?skip=number
  • ex:http://localhost:11000/blog/post/?skip=100 (Show post content from 100)


4. Combine limit and skip parameters

  • http://localhost:11000/dbName/collectionName/?skip=number1&limit=number2
  • ex:http://localhost:11000/blog/post/?skip=100&limit=10 (Show post from 100 to 109)


5. Get data in specify condition

  • http://localhost:11000/dbName/collectionName/?filter_key op parameter
  • ex : http://localhost:11000/dbName/collectionName/?filter_username=kevingo (Show kevingo's post)


【Reference】
http://www.mongodb.org/display/DOCS/Http+Interface

Share this post!

Bookmark and Share

0 意見: