{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Searching with Gooru API","type":"basic","slug":"searching-with-gooru-api","excerpt":"How to use Gooru's Search API","body":"There are 2 steps to sending a request:\n\n1) Signing in and obtaining an access token\n2) The actual search request (which uses the received access token)\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Signing in\"\n}\n[/block]\nHere is an example of an request that you can try out to sign in (it will not work because you need to change the \"Authorization header\"). \n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"POST /api/nucleus-auth/v1/token HTTP/1.1\\nHost: gooru.org\\nAuthorization: Basic c3pnb29ydTpnb28ydTEyMw==\\nContent-Type: application/json\\nCache-Control: no-cache\\n\\n{\\\"client_key\\\" : \\\"c2hlZWJhbkBnb293dWxlYXJuaW5nLm8yZw==\\\", \\n\\\"client_id\\\" : \\\"ba956a87-ae15-11e6-a302-f8a963065976\\\", \\n\\\"grant_type\\\" : \\\"credential\\\"}\",\n \"language\": \"curl\"\n }\n ]\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Encoding username and password\",\n \"body\": \"The string that goes after \\\"Basic\\\" in the authorization header must be substituted by a gooru username and password in the following format using base64 encoding:\\n\\nencode(username:password)\\n\\nFor example, username: john, password: 12345, encodes to:\\n\\nencode64(john:12345) = \\\"am9objoxMjM0NQ==\\\"\\n\\nSo your final Authorization header will look like this:\\n\\nAuthorization: Basic am9objoxMjM0NQ==\\n\\nThis request will return a json containing an \\\"access_token\\\" which will be used to perform the actual search request.\"\n}\n[/block]\nHere is a sample response that would be received after successfully signing in. Please pay special attention to the \"access_token\" as it will be needed for running subsequent requests.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"user_id\\\": \\\"a0273f89-95fc-440b-8a0c-47255a6c7272\\\",\\n \\\"username\\\": \\\"dlama\\\",\\n \\\"client_id\\\": \\\"ba953a97-ae15-11e5-a302-f0a963065976\\\",\\n \\\"provided_at\\\": 1466592075495,\\n \\\"prefs\\\": {\\n \\\"email_id\\\": \\\"dalai:::at:::email.com\\\"\\n },\\n \\\"cdn_urls\\\": {\\n \\\"user_cdn_url\\\": \\\"//usercdn.gooru.org/\\\",\\n \\\"content_cdn_url\\\": \\\"//cdn.gooru.org/\\\"\\n },\\n \\\"access_token\\\": \\\"MTQ2NjU5MjA3NTQ5NTphMDI3M2Y2OS05NWZjLTQ0MGItOGEwYy00NzI1NWE2YzcyNzI6YmE5NTZhOTctYWUxNS0xMWU1LWEzMDItZjhhOTYzMDY0OTc2\\\",\\n \\\"firstname\\\": \\\"Dalai\\\",\\n \\\"lastname\\\": \\\"Lama\\\",\\n \\\"user_category\\\": \\\"student\\\"\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n\n[block:embed]\n{\n \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQvkK7ZC9eDc%3Ffeature%3Doembed&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQvkK7ZC9eDc&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQvkK7ZC9eDc%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\\\" width=\\\"854\\\" height=\\\"480\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n \"url\": \"https://www.youtube.com/watch?v=QvkK7ZC9eDc&feature=youtu.be\",\n \"title\": \"Using Search API\",\n \"favicon\": \"https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico\",\n \"image\": \"https://i.ytimg.com/vi/QvkK7ZC9eDc/hqdefault.jpg\"\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"The Search Request\"\n}\n[/block]\nThe search request syntax will not vary much and the same query parameters you are currently using should work:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"GET /gooru-search/rest/v2/search/resource?pageNumber=1&pageSize=5&q=solar HTTP/1.1\\nHost: gooru.org\\nAuthorization: Token MTQ2NjU5MjA3NTQ5NTxhMDI3M2Y3OS05NWZjLTQ0MGItOGEwYy00NzI1NWE2YzcyNzI6YmE5NTZhOTctYWUxNS0xMWU1LWEzMDItZjhhOTYzMDY1OTc2\\nContent-Type: application/json\\nCache-Control: no-cache\\n\",\n \"language\": \"curl\"\n }\n ]\n}\n[/block]\nWhich should return a JSON in the following format:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"executionTime\\\": 17,\\n \\\"query\\\": {\\n \\\"rewrittenQueryString\\\": \\\"solar\\\",\\n \\\"userQueryString\\\": \\\"solar\\\"\\n },\\n \\\"resultCount\\\": 8,\\n \\\"searchCount\\\": 0,\\n \\\"searchResults\\\": [\\n {\\n \\\"addDate\\\": 1320025140000,\\n \\\"aggregator\\\": null,\\n \\\"assetURI\\\": null,\\n \\\"brokenStatus\\\": 0,\\n \\\"collaboratorCount\\\": null,\\n \\\"collectionCount\\\": 10,\\n \\\"contentFormat\\\": \\\"resource\\\",\\n \\\"contentId\\\": null,\\n \\\"contentPermissions\\\": null,\\n \\\"contentSubFormat\\\": \\\"video_resource\\\",\\n \\\"course\\\": null,\\n \\\"creator\\\": {\\n \\\"emailId\\\": \\\"\\\",\\n \\\"firstName\\\": \\\"Rocky\\\",\\n \\\"gooruUId\\\": \\\"ee410cef-2a44-46ef-878d-172511e54e07\\\",\\n \\\"isDeleted\\\": false,\\n \\\"lastName\\\": \\\"Shore\\\",\\n \\\"organizationName\\\": null,\\n \\\"partyUid\\\": \\\"ee410cef-2a44-46ef-878d-172511e54e07\\\",\\n \\\"profileImageUrl\\\": null,\\n \\\"userRoleSetString\\\": null,\\n \\\"username\\\": \\\"Rocky\\\",\\n \\\"usernameDisplay\\\": \\\"Rocky\\\"\\n },\\n \\\"customFields\\\": {\\n \\\"importMode\\\": \\\"Update\\\",\\n \\\"endUser\\\": \\\"Student\\\",\\n \\\"scriptCode\\\": \\\"latn\\\",\\n \\\"size\\\": \\\"Colossal Squid\\\",\\n \\\"domain\\\": {\\n \\\"name\\\": \\\"video.nationalgeographic.com\\\",\\n \\\"attribution\\\": \\\"National Geographic\\\",\\n \\\"url\\\": \\\"http:\\\\/\\\\/video.nationalgeographic.com\\\"\\n },\\n \\\"dataType\\\": \\\"MP4\\\",\\n \\\"publisher\\\": [\\n \\\"National Geographic\\\"\\n ],\\n \\\"mobileFriendliness\\\": \\\"iPad_friendly\\\",\\n \\\"language\\\": \\\"eng\\\",\\n \\\"accessMode\\\": [\\n \\\"Visual\\\"\\n ],\\n \\\"learningMode\\\": \\\"Expositive\\\"\\n },\\n \\\"depthOfKnowledges\\\": null,\\n \\\"description\\\": \\\"Students will learn about solar power in this video.\\\",\\n \\\"distinguish\\\": 0,\\n \\\"educationalUse\\\": null,\\n \\\"entryId\\\": null,\\n \\\"folder\\\": null,\\n \\\"gooruOid\\\": \\\"925611ee-ed47-4c73-8ad6-78d1c057c675\\\",\\n \\\"grade\\\": null,\\n \\\"hasFrameBreaker\\\": false,\\n \\\"indexId\\\": null,\\n \\\"instructional\\\": null,\\n \\\"isDeleted\\\": 0,\\n \\\"isOer\\\": 0,\\n \\\"lastModified\\\": 1402982788000,\\n \\\"lastModifiedString\\\": \\\"2014-06-17T05:26:28Z\\\",\\n \\\"libraryNames\\\": null,\\n \\\"license\\\": {\\n \\\"code\\\": \\\"Not Available\\\",\\n \\\"icon\\\": null,\\n \\\"name\\\": \\\"non-exclusive license\\\",\\n \\\"url\\\": \\\"http:\\\\/\\\\/creative.common.org\\\"\\n },\\n \\\"momentsOfLearning\\\": null,\\n \\\"publishStatus\\\": \\\"published\\\",\\n \\\"publisher\\\": [\\n \\\"National Geographic\\\"\\n ],\\n \\\"ratings\\\": {\\n \\\"average\\\": 0,\\n \\\"reviewCount\\\": 0,\\n \\\"count\\\": 0\\n },\\n \\\"recordSource\\\": null,\\n \\\"resourceAddedCount\\\": 10,\\n \\\"resourceFormat\\\": {\\n \\\"value\\\": \\\"Video\\\"\\n },\\n \\\"resourceSource\\\": {\\n \\\"frameBreaker\\\": false,\\n \\\"resourceSourceId\\\": 0,\\n \\\"activeStatus\\\": 0,\\n \\\"domainName\\\": \\\"video.nationalgeographic.com\\\",\\n \\\"attribution\\\": \\\"National Geographic\\\",\\n \\\"sourceName\\\": null,\\n \\\"type\\\": null,\\n \\\"url\\\": \\\"http:\\\\/\\\\/video.nationalgeographic.com\\\"\\n },\\n \\\"resourceTags\\\": null,\\n \\\"resourceType\\\": null,\\n \\\"resourceUsedUserCount\\\": 0,\\n \\\"resultUId\\\": \\\"2febd9d4-b786-4591-a5fe-b7458e9e2880\\\",\\n \\\"s3UploadFlag\\\": 0,\\n \\\"scollectionIds\\\": \\\"8bd94bd7-460f-4e49-9a32-ce9dd8c24eef || 2ea93031-65cb-4c93-ac2c-b16a9a6fdd88 || 33c2e2f9-107c-49e3-87f9-480456097c2f || cb455aa5-0371-471e-b63b-a2514b704ded || 60b15b12-b58f-4cdf-a931-a60c6b790b33 || 538f9e83-3ef1-411e-bc55-c819b3ec3690 || 49d7552b-5696-4ecc-bc48-e46eea0f6a18 || 7b498b07-7183-4138-a66c-22baffa3bf4d || 5179547d-09d5-42f8-9555-ac04bde5fab2 || 7a9d57eb-e816-4145-891d-61031a405f6d\\\",\\n \\\"scollectionTitles\\\": \\\"Energy Transport || Environmental Science || Solar Energy || Solar Power || Solar and Nuclear Energy (Warr) || Solar Power\\\",\\n \\\"sharing\\\": \\\"public\\\",\\n \\\"taxonomyDataSet\\\": \\\"{\\\\\\\"subject\\\\\\\":[],\\\\\\\"course\\\\\\\":[],\\\\\\\"domain\\\\\\\":[],\\\\\\\"curriculum\\\\\\\":{\\\\\\\"curriculumCode\\\\\\\":[],\\\\\\\"curriculumDesc\\\\\\\":[],\\\\\\\"curriculumName\\\\\\\":[],\\\\\\\"curriculumInfo\\\\\\\":[]}}\\\",\\n \\\"taxonomySet\\\": {\\n \\\"subject\\\": [\\n \\n ],\\n \\\"domain\\\": [\\n \\n ],\\n \\\"course\\\": [\\n \\n ],\\n \\\"curriculum\\\": {\\n \\\"curriculumName\\\": [\\n \\n ],\\n \\\"curriculumCode\\\": [\\n \\n ],\\n \\\"curriculumInfo\\\": [\\n \\n ],\\n \\\"curriculumDesc\\\": [\\n \\n ]\\n }\\n },\\n \\\"thumbnail\\\": \\\"0005\\\\/2674\\\\/925611ee-ed47-4c73-8ad6-78d1c057c675.png\\\",\\n \\\"thumbnails\\\": null,\\n \\\"title\\\": \\\"Solar Power\\\",\\n \\\"url\\\": \\\"http:\\\\/\\\\/video.nationalgeographic.com\\\\/video\\\\/player\\\\/environment\\\\/energy-environment\\\\/solar-power.html\\\",\\n \\\"user\\\": {\\n \\\"emailId\\\": \\\"\\\",\\n \\\"firstName\\\": \\\"Rocky\\\",\\n \\\"gooruUId\\\": \\\"ee410cef-2a44-46ef-878d-172511e54e07\\\",\\n \\\"isDeleted\\\": false,\\n \\\"lastName\\\": \\\"Shore\\\",\\n \\\"organizationName\\\": null,\\n \\\"partyUid\\\": \\\"ee410cef-2a44-46ef-878d-172511e54e07\\\",\\n \\\"profileImageUrl\\\": null,\\n \\\"userRoleSetString\\\": null,\\n \\\"username\\\": \\\"Rocky\\\",\\n \\\"usernameDisplay\\\": \\\"Rocky\\\"\\n },\\n \\\"viewCount\\\": 0,\\n \\\"views\\\": 0\\n }\\n ],\\n \\\"stats\\\": {\\n \\\"pageSize\\\": 8,\\n \\\"totalHitCount\\\": 2077,\\n \\\"pageNumber\\\": null\\n },\\n \\\"totalHitCount\\\": 2077\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Input Parameters & Request Syntax\"\n}\n[/block]\nGooru Search Syntax should follow this example:\n\n{REST_END_POINT}/gooru-search/rest/v2/search/{type}?pageNum={pageNum}&pageSize={pageSize}&q={search term}\n[block:parameters]\n{\n \"data\": {\n \"0-0\": \"pageSize\",\n \"1-0\": \"startAt\",\n \"2-0\": \"pageNum\",\n \"3-0\": \"q\",\n \"4-0\": \"Gooru-Session-Token\",\n \"5-0\": \"type\",\n \"h-0\": \"Name\",\n \"h-1\": \"Data Type\",\n \"h-2\": \"Param Type\",\n \"h-3\": \"Default Value\",\n \"h-4\": \"Optional?\",\n \"h-5\": \"Allowed Values\",\n \"0-5\": \"Only Integer values 1 to 20\",\n \"1-5\": \"Only Integer values\",\n \"2-5\": \"Only Integer values\",\n \"3-5\": \"Numbers , String, Logical expression(i.e query1 OR query2),Prefix filter query (i.e water:video, ocean:webpage)\\n\\nNote: The query term should be meaningful and must contain more than 3 characters\",\n \"4-5\": \"Session Token obtained from Gooru Core Authentication API.\",\n \"5-5\": \"Only “resource,scollection” values supported. \\n\\nResource refers to an individual resource, while scollection refers to a collection of resource.\",\n \"0-1\": \"Integer\",\n \"1-1\": \"Integer\",\n \"2-1\": \"Integer\",\n \"3-1\": \"String\",\n \"4-1\": \"String\",\n \"5-1\": \"String\",\n \"0-2\": \"Request Param\",\n \"1-2\": \"Request Param\",\n \"2-2\": \"Request Param\",\n \"3-2\": \"Request Param\",\n \"4-2\": \"Request Header\",\n \"5-2\": \"PathVariable\",\n \"0-3\": \"8\",\n \"1-3\": \"0\",\n \"2-3\": \"1\",\n \"3-3\": \"Nil\",\n \"4-3\": \"Nil\",\n \"5-3\": \"Nil\",\n \"0-4\": \"Yes\",\n \"1-4\": \"Yes\",\n \"2-4\": \"Yes\",\n \"3-4\": \"No\",\n \"4-4\": \"No\",\n \"5-4\": \"No\"\n },\n \"cols\": 6,\n \"rows\": 6\n}\n[/block]","updates":[],"order":1,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5864d2df79ce642d00f0ff11","project":"56439dfe9eebf70d00490d54","user":"55dd6b48a649eb170083b97a","githubsync":"","__v":0,"parentDoc":null,"createdAt":"2016-06-22T10:30:20.970Z","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Search API","slug":"new-search-api","order":18,"from_sync":false,"reference":false,"_id":"5864d2df79ce642d00f0feda","project":"56439dfe9eebf70d00490d54","__v":0,"version":"5864d2df79ce642d00f0fec7","createdAt":"2016-06-22T10:24:58.776Z"},"version":{"version":"2","version_clean":"2.0.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["5864d2df79ce642d00f0fec8","5864d2df79ce642d00f0fec9","5864d2df79ce642d00f0feca","5864d2df79ce642d00f0fecb","5864d2df79ce642d00f0fecc","5864d2df79ce642d00f0fecd","5864d2df79ce642d00f0fece","5864d2df79ce642d00f0fecf","5864d2df79ce642d00f0fed0","5864d2df79ce642d00f0fed1","5864d2df79ce642d00f0fed2","5864d2df79ce642d00f0fed3","5864d2df79ce642d00f0fed4","5864d2df79ce642d00f0fed5","5864d2df79ce642d00f0fed6","5864d2df79ce642d00f0fed7","5864d2df79ce642d00f0fed8","5864d2df79ce642d00f0fed9","5864d2df79ce642d00f0feda","5864d2df79ce642d00f0fedb","5864d2df79ce642d00f0fedc","5864d2df79ce642d00f0fedd","5864d2df79ce642d00f0fede","598aa64f4b6e990019b7a2d2","599bc76bc03fa2000f83db2a","599bcc3c3c5bf7000f3434fc","5d427dc9fa56fa0011135058","5d429c616863d5003af785a7","5d429e0889418f00c5e95d3f","5d42b5f098b05e003acb08b4","5d43c16985775c00ebeede3b","5d43d15446d584003da91e6d","5d43d61a5bdac50011b6f234","5d43d7c2db365100640dbc58","5d43d954bffa8400ff7efa78","5d43e414cf4f03005944344c","5d43eb42db365100640dbe4a","5d43ee6c78121b0057bc1dbf","5d9a18b4afc33400126c4e6f","5dc4f96dbb5da3006c8f5660"],"_id":"5864d2df79ce642d00f0fec7","createdAt":"2016-12-29T09:09:51.074Z","project":"56439dfe9eebf70d00490d54","releaseDate":"2016-12-29T09:09:51.074Z","__v":18}}
Searching with Gooru API
How to use Gooru's Search API