Sample code for 30+ languages & platforms
Xbase++

SCIS Search

See more SCiS Schools Catalogue Examples

Demonstrates the SCIS (Schools Catalogue Information Service) search API call.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbQuery
LOCAL oSbUrl
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cV_index
LOCAL cV_type
LOCAL nV_sourceDateIssuedMarc
LOCAL cV_sourceIsbn13
LOCAL cV_sourceImageFileName
LOCAL cV_sourcePublicationDetails
LOCAL cV_sourceIsbn10
LOCAL cV_sourceId
LOCAL cV_id
LOCAL cV_score
LOCAL j
LOCAL nCount_j
LOCAL cStrVal
LOCAL nDataHitsTotal
LOCAL cDataHitsMax_score
LOCAL nDataTook
LOCAL nDataTimed_out
LOCAL i
LOCAL nCount_i

nSuccess := 0

//  This example assumes the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oHttp := CreateObject("Chilkat.Http")

//  Implements the following CURL command:

//  curl -i -X GET --url 'https://api.scisdata.com/catalogue/api/search?query=titleSearch%3Adogs%20AND%20publicationYear%3A2015&from=0&size=20&sort=author&order=asc' -H 'Authorization: Basic ****'

//  Use the following online tool to generate HTTP code from a CURL command
//  Convert a cURL Command to HTTP Source Code

//  This causes the "Authorization: Basic ****" to be added to each request.
oHttp:Login := "myLogin"
oHttp:Password := "myPassword"
oHttp:BasicAuth := 1

oSbQuery := CreateObject("Chilkat.StringBuilder")
oSbQuery:Append("titleSearch:dogs AND publicationYear:2015")

oSbUrl := CreateObject("Chilkat.StringBuilder")
oSbUrl:Append("https://api.scisdata.com/catalogue/api/search?query=")
//  If non-usascii chars are included in the search, we don't know if utf-8 or windows-1252 is desired by the server.  You'll need to find out..
oSbUrl:Append(oSbQuery:GetEncoded("url", "utf-8"))
oSbUrl:Append("&from=0&size=20&sort=author&order=asc")

oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb(oSbUrl:GetAsString(), oSbResponseBody)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oSbQuery:destroy()
    oSbUrl:destroy()
    oSbResponseBody:destroy()
    RETURN
ENDIF

oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0

? "Response Body:"
? oJResp:Emit()

nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
    ? "Response Header:"
    ? oHttp:LastHeader
    ? "Failed."
    oHttp:destroy()
    oSbQuery:destroy()
    oSbUrl:destroy()
    oSbResponseBody:destroy()
    oJResp:destroy()
    RETURN
ENDIF

//  Sample JSON response:
//  (Sample code for parsing the JSON response is shown below)

//  {
//    "data": {
//      "hits": {
//        "hits": [
//          {
//            "_index": "scisdata2",
//            "_type": "bibdatatype",
//            "_source": {
//              "isbn": [
//                "9781517638160"
//              ],
//              "languageTermCode": [
//                "eng"
//              ],
//              "mainAuthor": {
//                "namePersonalPrimary": [
//                  "Abbott, Eleanor Hallowell."
//                ]
//              },
//              "title": {
//                "titlePrimary": [
//                  "Peace on Earth, good-will to dogs"
//                ],
//                "noteStmOfResponsibility": [
//                  "by Eleanor Hallowell Abbott."
//                ]
//              },
//              "scisType": [
//                "Book"
//              ],
//              "dateIssuedMarc": 2015,
//              "languageTermValue": [
//                "English"
//              ],
//              "contributor": {},
//              "isbn13": "9781517638160",
//              "imageFileName": "9781517638160.jpg",
//              "publicationDetails": "United States, Create Space Independent Publishing Platform, 2015",
//              "isbn10": "151763816X",
//              "id": "1867852"
//            },
//            "_id": "1867852",
//            "sort": [
//              "abbott, eleanor hallowell."
//            ],
//            "_score": null
//          },
//          {
//            "_index": "scisdata2",
//            "_type": "bibdatatype",
//            "_source": {
//              "isbn": [
//                "9781780747910"
//              ],
//              "languageTermCode": [
//                "eng"
//              ],
//              "mainAuthor": {
//                "namePersonalPrimary": [
//                  "Adams, Richard."
//                ]
//              },
//              "title": {
//                "titlePrimary": [
//                  "The plague dogs"
//                ],
//                "noteStmOfResponsibility": [
//                  "Richard Adams."
//                ]
//              },
//              "scisType": [
//                "Book"
//              ],
//              "dateIssuedMarc": 2015,
//              "languageTermValue": [
//                "English"
//              ],
//              "contributor": {},
//              "isbn13": "9781780747910",
//              "imageFileName": "9781780747910.jpg",
//              "publicationDetails": "New York, Rock the Boat, 2015",
//              "isbn10": "1780747918",
//              "id": "1749228"
//            },
//            "_id": "1749228",
//            "sort": [
//              "adams, richard."
//            ],
//            "_score": null
//          },
//           ...
//        ],
//        "total": 84,
//        "max_score": null
//      },
//      "took": 585,
//      "timed_out": false
//    },
//    "subscriptionStatus": {}
//  }

//  Sample code for parsing the JSON response...
//  Use the following online tool to generate parsing code from sample JSON:
//  Generate Parsing Code from JSON

nDataHitsTotal := oJResp:IntOf("data.hits.total")
cDataHitsMax_score := oJResp:StringOf("data.hits.max_score")
nDataTook := oJResp:IntOf("data.took")
nDataTimed_out := oJResp:BoolOf("data.timed_out")
i := 0
nCount_i := oJResp:SizeOfArray("data.hits.hits")
DO WHILE i < nCount_i
    oJResp:I := i
    cV_index := oJResp:StringOf("data.hits.hits[i]._index")
    cV_type := oJResp:StringOf("data.hits.hits[i]._type")
    nV_sourceDateIssuedMarc := oJResp:IntOf("data.hits.hits[i]._source.dateIssuedMarc")
    cV_sourceIsbn13 := oJResp:StringOf("data.hits.hits[i]._source.isbn13")
    cV_sourceImageFileName := oJResp:StringOf("data.hits.hits[i]._source.imageFileName")
    cV_sourcePublicationDetails := oJResp:StringOf("data.hits.hits[i]._source.publicationDetails")
    cV_sourceIsbn10 := oJResp:StringOf("data.hits.hits[i]._source.isbn10")
    cV_sourceId := oJResp:StringOf("data.hits.hits[i]._source.id")
    cV_id := oJResp:StringOf("data.hits.hits[i]._id")
    cV_score := oJResp:StringOf("data.hits.hits[i]._score")
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.isbn")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.isbn[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.languageTermCode")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.languageTermCode[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.mainAuthor.namePersonalPrimary")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.mainAuthor.namePersonalPrimary[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.title.titlePrimary")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.title.titlePrimary[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.title.noteStmOfResponsibility")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.title.noteStmOfResponsibility[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.scisType")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.scisType[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.languageTermValue")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.languageTermValue[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i].sort")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i].sort[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.contributor.namePersonalOther")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.contributor.namePersonalOther[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJResp:SizeOfArray("data.hits.hits[i]._source.contributor.nameCorporateOther")
    DO WHILE j < nCount_j
        oJResp:J := j
        cStrVal := oJResp:StringOf("data.hits.hits[i]._source.contributor.nameCorporateOther[j]")
        j := j + 1
    ENDDO
    i := i + 1
ENDDO

oHttp:destroy()
oSbQuery:destroy()
oSbUrl:destroy()
oSbResponseBody:destroy()
oJResp:destroy()