Difference between revisions of "API Accounts List"
Tommy.leung (Talk | contribs) (→Examples) |
(→Limit 1 account and set the fields returned) |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 38: | Line 38: | ||
|- | |- | ||
| limit | | limit | ||
− | | | + | | 100 |
| | | | ||
| | | | ||
| The maximum number of accounts to return. | | The maximum number of accounts to return. | ||
+ | |- | ||
+ | | page | ||
+ | | 1 | ||
+ | | Depends on query | ||
+ | | Integer | ||
+ | | The current pages to display based on the limit. | ||
|- | |- | ||
| fields | | fields | ||
Line 68: | Line 74: | ||
| array of [[API Account Fields]] | | array of [[API Account Fields]] | ||
| List of accounts | | List of accounts | ||
+ | |- | ||
+ | | page | ||
+ | | integer | ||
+ | | The current viewed page of results. | ||
+ | |- | ||
+ | | per-page | ||
+ | | integer | ||
+ | | The maximum number of results to return per page. | ||
+ | |- | ||
+ | | total-pages | ||
+ | | integer | ||
+ | | The total number of pages that exist. | ||
+ | |- | ||
+ | | total-entries | ||
+ | | integer | ||
+ | | The total number of entries found from all pages. | ||
|- | |- | ||
| result_length | | result_length | ||
| integer | | integer | ||
− | | Total number of results that | + | | Total number of results that have been returned on this page. This may differ from the per-page/limit value on the last page. |
|} | |} | ||
− | |||
− | |||
== Examples == | == Examples == | ||
Line 96: | Line 116: | ||
|- | |- | ||
| <blockquote> | | <blockquote> | ||
− | { | + | { "accounts" : [ |
− | + | ||
{"id" : 1, | {"id" : 1, | ||
"logo_url" : <nowiki>"https://cdn-unroole-dev.s3.amazonaws.com/system/accounts/logos/1/original/heic0206c.jpg"</nowiki>, | "logo_url" : <nowiki>"https://cdn-unroole-dev.s3.amazonaws.com/system/accounts/logos/1/original/heic0206c.jpg"</nowiki>, | ||
Line 120: | Line 139: | ||
], | ], | ||
"http_status" : 200, | "http_status" : 200, | ||
− | + | “page” : 1, | |
+ | “per-page” : 100, | ||
+ | “total-pages” : 1 | ||
+ | “total-entries” : 4, | ||
+ | “result_length” : 4 | ||
} | } | ||
</blockquote> | </blockquote> | ||
Line 159: | Line 182: | ||
</account> | </account> | ||
</accounts> | </accounts> | ||
+ | <page type="integer">1</page> | ||
+ | <per-page” type="integer">100</per-page”> | ||
+ | <total-pages type="integer">1</total-pages> | ||
+ | <total-entries type="integer">4</total-entries> | ||
<result-length type="integer">4</result-length> | <result-length type="integer">4</result-length> | ||
<http-status type="integer">200</http-status> | <http-status type="integer">200</http-status> | ||
Line 166: | Line 193: | ||
=== Limit 1 account and set the fields returned === | === Limit 1 account and set the fields returned === | ||
+ | |||
+ | ''result_length is 4 because there are 4 accounts that can be returned, but the user requested only for 1'' | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 189: | Line 218: | ||
|- | |- | ||
| <blockquote> | | <blockquote> | ||
− | { | + | { "accounts" : [ |
− | + | ||
{ "id" : 1, | { "id" : 1, | ||
"updated_at" : "2012-06-14T17:46:10Z", | "updated_at" : "2012-06-14T17:46:10Z", | ||
Line 196: | Line 224: | ||
} ], | } ], | ||
"http_status" : 200, | "http_status" : 200, | ||
− | + | “page” : 1, | |
+ | “per-page” : 1, | ||
+ | “total-pages” : 5 | ||
+ | “total-entries” : 5, | ||
+ | “result_length” : 1 | ||
} | } | ||
</blockquote> | </blockquote> | ||
Line 216: | Line 248: | ||
</account> | </account> | ||
</accounts> | </accounts> | ||
− | <result-length type="integer"> | + | <page type="integer">1</page> |
+ | <per-page” type="integer">1</per-page”> | ||
+ | <total-pages type="integer">5</total-pages> | ||
+ | <total-entries type="integer">5</total-entries> | ||
+ | <result-length type="integer">1</result-length> | ||
<http-status type="integer">200</http-status> | <http-status type="integer">200</http-status> | ||
</hash> | </hash> | ||
Line 223: | Line 259: | ||
=== Search for "test account" === | === Search for "test account" === | ||
+ | |||
+ | ''remember to encode the query string parameters'' | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 256: | Line 294: | ||
], | ], | ||
"http_status" : 200, | "http_status" : 200, | ||
+ | “page” : 1, | ||
+ | “per-page” : 100, | ||
+ | “total-pages” : 1 | ||
+ | “total-entries” : 2, | ||
"result_length" : 2 | "result_length" : 2 | ||
} | } | ||
Line 283: | Line 325: | ||
</account> | </account> | ||
</accounts> | </accounts> | ||
+ | <page type="integer">1</page> | ||
+ | <per-page” type="integer">100</per-page”> | ||
+ | <total-pages type="integer">1</total-pages> | ||
+ | <total-entries type="integer">2</total-entries> | ||
<result-length type="integer">2</result-length> | <result-length type="integer">2</result-length> | ||
<http-status type="integer">200</http-status> | <http-status type="integer">200</http-status> |
Latest revision as of 10:01, 29 November 2013
Contents
Summary
Allows querying for a list of accounts belonging to the user. The query is a wildcard search on:
- name
URI
https://api.unroole.com/accounts
HTTP Method
GET
Required Paramaters
Paramater | Default | Maximum Length | Accepted Values | Description |
---|---|---|---|---|
token | API Persistence Token that identifies this user and its permissions. |
Optional Paramaters
Paramater | Default | Maximum Length | Accepted Values | Description |
---|---|---|---|---|
search | string | The search terms to be used in the query. | ||
limit | 100 | The maximum number of accounts to return. | ||
page | 1 | Depends on query | Integer | The current pages to display based on the limit. |
fields | id, name, url, logo_url | API Account Fields | List of comma separated fields to be returned in the response. | |
url_time_limit | 60 | The length of time (in seconds) that the logo url will be accessible for. This only applies to the response. |
Response
Field | Type | Description |
---|---|---|
http_status | integer | API Status Code http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html |
error | Rails default | |
accounts | array of API Account Fields | List of accounts |
page | integer | The current viewed page of results. |
per-page | integer | The maximum number of results to return per page. |
total-pages | integer | The total number of pages that exist. |
total-entries | integer | The total number of entries found from all pages. |
result_length | integer | Total number of results that have been returned on this page. This may differ from the per-page/limit value on the last page. |
Examples
All accounts accessible by the user
Parameters | Values |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
JSON |
---|
http://api.unroole.com/accounts.json?token=1f0qpLwoV5oIcfnU2yvO |
|
XML |
---|
http://api.unroole.com/accounts.xml?token=1f0qpLwoV5oIcfnU2yvO |
|
Limit 1 account and set the fields returned
result_length is 4 because there are 4 accounts that can be returned, but the user requested only for 1
Parameters | Values |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
limit | 1 |
fields | id,url,updated_at |
JSON |
---|
http://api.unroole.com:3000/accounts.json?token=1f0qpLwoV5oIcfnU2yvO&limit=1&fields=id,url,updated_at |
|
XML |
---|
http://api.unroole.com:3000/accounts.xml?token=1f0qpLwoV5oIcfnU2yvO&limit=1&fields=id,url,updated_at |
|
Search for "test account"
remember to encode the query string parameters
Parameters | Values |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
search | test%20account |
JSON |
---|
http://api.unroole.com:3000/accounts.json?token=1f0qpLwoV5oIcfnU2yvO&search=test%20account |
|
XML |
---|
http://api.unroole.com:3000/accounts.xml?token=1f0qpLwoV5oIcfnU2yvO&search=test%20account |
|