========================================================= Links and Code Snippets for Alma Elsewhere Presentation Chad Kluck, ELUNA 2019 --------------------------------------------------------- --------------------------------------------------------- Main Links --------------------------------------------------------- St. Thomas Libraries GitHub https://github.com/USTLibraries Chad Kluck GitHub https://github.com/chadkluck Presentation Link with Audio and Slides https://chadkluck.net/eluna-2019 Ex Libris Developer's Network https://developers.exlibrisgroup.com Postman https://www.getpostman.com https://www.getpostman.com/security Serverless options https://logz.io/blog/serverless-guide --------------------------------------------------------- API Example Links --------------------------------------------------------- https://api.chadkluck.net/eluna https://api.chadkluck.net/eluna?code=BAO https://api.chadkluck.net/eluna?code=LVP https://api.chadkluck.net/eluna?code=8BL https://api.chadkluck.net/eluna?code=DEV https://api.chadkluck.net/eluna?code=CPE https://api.chadkluck.net/eluna?code=CBL https://api.chadkluck.net/eluna?code=LHF Code to run your own instance of the ELUNA example api: https://github.com/ustlibraries/eluna-2019 --------------------------------------------------------- Helpful GitHub projects --------------------------------------------------------- https://github.com/ustlibraries/exlibris-api-example https://github.com/chadkluck/php-project-framework https://github.com/chadkluck/js-template Example: 8 Ball https://diversion.chadkluck.net/8ball https://github.com/chadkluck/8ball-api (the api service) https://github.com/chadkluck/8ball-js (the JavaScript client/UI) --------------------------------------------------------- Additional Presentations --------------------------------------------------------- This ELUNA presentation was based on/extends the presentation I gave at UMWUG (Upper Midwest User Group) Fall: https://chadkluck.net/umwug-2018 More on the Library Help LTI: “Drag, Drop, Done, Implementing Library Help LTI in Canvas” presentation given at LibTech 2019: https://chadkluck.net/libtech-2019 --------------------------------------------------------- API URLS - User, Loans, Fines, Fees --------------------------------------------------------- User /almaws/v1/users/{{user_id}}?user_id_type=all_unique&view=full&expand=loans,fees,requests&apikey={{apikey}}&format=json Loans /almaws/v1/users/{{user_id}}/loans?user_id_type=all_unique&limit=10&offset=0&order_by=due_date&direction=ASC&apikey={{apikey}}&format=json Holds/Requests /almaws/v1/users/{{user_id}}/requests?request_type=HOLD&user_id_type=all_unique&limit=10&offset=0&status=active&apikey={{apikey}}&format=json Fines /almaws/v1/users/{{user_id}}/fees?user_id_type=all_unique&status=ACTIVE&apikey={{apikey}}&format=json --------------------------------------------------------- API URLS - Search and Request --------------------------------------------------------- Perform a search on Primo /primo/v1/pnxs?q={{query}}&lang=eng&offset=1&limit=10&view=full&vid={{view}}&scope={{scope}}&apikey={{apikey}} When a user selects an item we get the BIB /almaws/v1/bibs/?view=full&expand=p_avail,e_avail,d_avail&nz_mms_id={{nz_mms_id}}&format={{format}}&apikey={{apikey}} Holding Link /almaws/v1/bibs/{{mms_id}}/holdings?format={{format}}&apikey={{apikey}} Get PID /almaws/v1/bibs/{{mms_id}}/holdings/{{holding_id}}/items/?format={{format}}&apikey={{apikey}} Make Request /almaws/v1/bibs/{{mms_id}}/holdings/{{holding_id}}/items/{{item_pid}}/requests?user_id={{user_id}}&format={{format}}&apikey={{apikey}} --------------------------------------------------------- API URLS - Import Invoices to Finance System --------------------------------------------------------- Get Fund Codes /almaws/v1/acq/funds?apikey={{apikey}}&view=full&limit=100&offset=0 Get Active Invoices: /almaws/v1/acq/invoices/?apikey={{apikey}}&base_status=ACTIVE&limit=100&view=full&offset=0 Get Each Vendor (based on invoices): /almaws/v1/acq/vendors/{{vendorCode}}?apikey={{apikey}} --------------------------------------------------------- PHP Code Snippet --------------------------------------------------------- // ------------------------------------------------------ // PHP - Return an array as JSON $data = array(); $data[] = "Hello World"; // put data in the array $cache = 60; //in seconds $origin = "https://www.yoursitedomain.com"; // CORS allowed origin $ts = gmdate("D, d M Y H:i:s", time() + $cache) . " GMT"; header("Expires: ".$ts); header("Pragma: cache"); header("Cache-Control: max-age=".$cache); header("Access-Control-Allow-Origin: ".$origin); // CORS header("Content-type: application/json"); echo json_encode($array); // ------------------------------------------------------ // PHP - Request json data and turn into array function getDataFromJSON($url) { $results = array(); try { $contents = @file_get_contents($url); // @ means suppress warnings $results = json_decode($contents, true); } catch (Exception $e) { echo "Caught exception: ". $e->getMessage(); } return $results; } $apikey = ""; // enter an API key here - needs access to Courses $url = "https://api-na.hosted.exlibrisgroup.com/almaws/v1/courses?limit=10&offset=0&order_by=code%2Csection&direction=ASC&format=json&apikey=".$apikey; // change this to whatever you want, be sure the key has access $data = getDataFromJSON($url);