Update Index API

For partners using Gooru Search Index, this API allows for periodic update of the same by identifying content items deleted / dropped from Gooru Search index. Gooru maintains the deleted items index for a period of one year.

1. Authentication

All Gooru API calls must be authenticated using access tokens. To acquire an access token you need an Client Id and Client Secret key. Contact [email protected] for the necessary detail.

Authenticating with a Client Id and Client Key

Once you have a ClientId and Client Key, making API calls is very easy and simple. Please follow the below steps:

  • Call to obtain access token API with header “Authorization”.
  • Header name “Authorization” and header value “Basic [access_token]”
  • Header value is “Basic base64encode(username:password)” - meaning have to encode(base64) “username:password” string and pass it to header.
  • From the the response, extract the “access_token” field that will be needed for subsequent API
curl -i -H "Content-Type: application/json" -H "Authorization: Basic b2liZ2FuZzlAZ29vcnUub3JnOmRvbjEyMzQ=" -d '{ "client_key": "c2hlZWJhbkBnb29ydWxlYXJuaW5nLm9yZw==", "client_id": "ba956a97-ae15-11e5-a302-f8a963065976", "grant_type": "credential" }' -X POST http://gooru.org/api/nucleus-auth/v1/token
{"user_id":"e1ed49eb-35a0-489b-8dda-b4f7459a1d1d","username":"david","client_id":"ba956a97-ae15-11e5-a302-f8a963065976","provided_at":1466412833174,"prefs":{"email_id":"[email protected]"},"cdn_urls":{"user_cdn_url":"//usercdn.gooru.org/","content_cdn_url":"//cdn.gooru.org/"},"access_token":"MTQ2NjQxMjgzMzE3NDplMWVkNDllYi0zNWEwLTQ4OWItOGRkYS1iNGY3NDU5YTFkMWQ6YmE5NTZhOTctYWUxNS0xMWU1LWEzMDItZjhhOTYzMDY1OTc2","firstname":"David","lastname":"B","user_category":"student"}

2. Get Deleted Items

Given a content type and timestamp, get the list of deleted content.

Method Type
GET

API
{REST_END_POINT}/api/nucleus-track-index/v1/deleted-items/{type}

Request Headers

Header

Value

Description

Authorization

Token {TOKEN}

Replace the {TOKEN} with actual value of access token obtained from authentication.

Content-Type

application/json

Path Variables

Name

Data Type

Mandatory

Accepted Values

type

String

Yes

"resource" / "collection"

Request Parameters

Name

Data Type

Mandatory

Default Value

Comment

deletedSince

Long

Yes

--

This timestamp should be in milliseconds and cannot go back more than a year from current time

pageNum

Integer

No

1

Page to fetch

pageSize

Integer

No

30

Limit to fetch, only 30 records will be given in single call. Increment pageNum to get next set of results.

Response Header

Header

Description

Index-Type

Will be index type name of the documents returned. (resource / collection)

Content-Length

Will be included if the API response has a body

Content-Type

Will be included if the API response has a body (JSON)

curl -i  -H "Content-Type: application/json" -H "Authorization: Token MTQ2OTAwNzcwNTgyMjphbm9ueW1vdXM6YmE5NTZhOTctYWUxNS0xMWU1LWEzMDItZjhhOTYzMDY1OTc2" -X GET 'http://nucleus-qa.gooru.org/api/nucleus-track-index/v1/deleted-items/resource?pageNum=1&pageSize=3&deletedSince=1469007773000'
{
  "meta":{
    "totalCount":2,
    "requestedPageSize":50,
    "returnedPageSize":2,
    "pageNum":1
  },
  "content":[{
    "id":"23a9a0fc-2d29-11e3-9ab2-12314001917b",
    "deletedAt":"2014-09-18T02:42:16Z"
  }, {
    "id":"e450aa64-2d27-11e3-9ab2-12314001917b",
    "deletedAt":"2015-02-28T07:02:35Z"
  }]
}

HTTP Response Codes

Status Code

Response Body

Description

200 : Success

Detail for entity requested

Operation successful without error

400 : Bad Request

Specific error message

Malformed, invalid or incorrect request or request parameters noted

401 : Unauthorized

No Content

Action requires authentication or session token may have expired. Note that we don’t return www-authenticate headers as we do not want browser to participate in the auth flow.

404 : Not Found

No Content

Entity not found

500 : Internal Server Error

Ideally, users should not see this. This indicates server unknown errors while processing the request. The message may be technical and may not be suitable for end user consumption.