Sample code for 30+ languages & platforms
React Native

SCIS Search

See more SCiS Schools Catalogue Examples

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

Chilkat React Native Downloads

React Native
import { Http, JsonObject, StringBuilder } from '@chilkat/react-native'

async function chilkatExample() {
  // This example assumes the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const http = new 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.
  http.login = 'myLogin';
  http.password = 'myPassword';
  http.basicAuth = true;

  const sbQuery = new StringBuilder();
  sbQuery.append('titleSearch:dogs AND publicationYear:2015');

  const sbUrl = new StringBuilder();
  sbUrl.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..
  sbUrl.append(sbQuery.getEncoded('url', 'utf-8'));
  sbUrl.append('&from=0&size=20&sort=author&order=asc');

  const sbResponseBody = new StringBuilder();
  try {
    await http.quickGetSbAsync(sbUrl.getAsString(), sbResponseBody);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  const jResp = new JsonObject();
  jResp.loadSb(sbResponseBody);
  jResp.emitCompact = false;

  console.log('Response Body:');
  console.log(jResp.emit());

  const respStatusCode = http.lastStatus;
  console.log(`Response Status Code = ${respStatusCode}`);
  if (respStatusCode >= 400) {
    console.log('Response Header:');
    console.log(http.lastHeader);
    console.log('Failed.');
    return;
  }

  // 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

  let vIndex = '';
  let vType = '';
  let vSourceDateIssuedMarc = 0;
  let vSourceIsbn13 = '';
  let vSourceImageFileName = '';
  let vSourcePublicationDetails = '';
  let vSourceIsbn10 = '';
  let vSourceId = '';
  let vId = '';
  let vScore = '';
  let j = 0;
  let countJ = 0;
  let strVal = '';

  const dataHitsTotal = jResp.intOf('data.hits.total');
  const dataHitsMaxScore = jResp.stringOf('data.hits.max_score');
  const dataTook = jResp.intOf('data.took');
  let i = 0;
  const countI = jResp.sizeOfArray('data.hits.hits');
  while (i < countI) {
    jResp.i = i;
    vIndex = jResp.stringOf('data.hits.hits[i]._index');
    vType = jResp.stringOf('data.hits.hits[i]._type');
    vSourceDateIssuedMarc = jResp.intOf('data.hits.hits[i]._source.dateIssuedMarc');
    vSourceIsbn13 = jResp.stringOf('data.hits.hits[i]._source.isbn13');
    vSourceImageFileName = jResp.stringOf('data.hits.hits[i]._source.imageFileName');
    vSourcePublicationDetails = jResp.stringOf('data.hits.hits[i]._source.publicationDetails');
    vSourceIsbn10 = jResp.stringOf('data.hits.hits[i]._source.isbn10');
    vSourceId = jResp.stringOf('data.hits.hits[i]._source.id');
    vId = jResp.stringOf('data.hits.hits[i]._id');
    vScore = jResp.stringOf('data.hits.hits[i]._score');
    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.isbn');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.isbn[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.languageTermCode');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.languageTermCode[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.mainAuthor.namePersonalPrimary');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.mainAuthor.namePersonalPrimary[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.title.titlePrimary');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.title.titlePrimary[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.title.noteStmOfResponsibility');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.title.noteStmOfResponsibility[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.scisType');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.scisType[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.languageTermValue');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.languageTermValue[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i].sort');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i].sort[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.contributor.namePersonalOther');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.contributor.namePersonalOther[j]');
      j++;
    }

    j = 0;
    countJ = jResp.sizeOfArray('data.hits.hits[i]._source.contributor.nameCorporateOther');
    while (j < countJ) {
      jResp.j = j;
      strVal = jResp.stringOf('data.hits.hits[i]._source.contributor.nameCorporateOther[j]');
      j++;
    }

    i++;
  }
}