{"id":49407,"library":"sp-service","title":"sp-service","description":"Module to help use SharePoint REST endpoints easily. Provides a comprehensive JavaScript class for interacting with SharePoint's REST API, including file/folder management, list item manipulation, user/group handling, commenting, versioning, and recycle bin operations. Current version 2.0.10, last major update December 2021. Built with Axios, includes automatic X-RequestDigest token handling. Key differentiator: singleton instance with pre-configured Axios interceptors, supports both default and custom instances.","status":"maintenance","version":"2.0.10","language":"javascript","source_language":"en","source_url":"https://github.com/aonghas/sp-service","tags":["javascript"],"install":[{"cmd":"npm install sp-service","lang":"bash","label":"npm"},{"cmd":"yarn add sp-service","lang":"bash","label":"yarn"},{"cmd":"pnpm add sp-service","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"HTTP client for making REST API calls","package":"axios","optional":false}],"imports":[{"note":"Default export is a singleton instance. Named export SharePoint is the class.","wrong":"const { SharePoint } = require('sp-service');","symbol":"SharePoint (default export)","correct":"import SharePoint from 'sp-service';"},{"note":"Named export allows creating custom instances with options.","wrong":"import SharePoint from 'sp-service';","symbol":"SharePoint (named class)","correct":"import { SharePoint } from 'sp-service';"},{"note":"Common alias for the default singleton instance.","wrong":"import { SP } from 'sp-service';","symbol":"SP (alias for default)","correct":"import SP from 'sp-service';"}],"quickstart":{"code":"import SP from 'sp-service';\n\n// Create a new list item\nSP.createItem('Documents', {\n  Title: 'New Document',\n  Description: 'Created via API'\n})\n  .then((response) => console.log('Item created:', response))\n  .catch((error) => console.error('Error:', error));\n\n// Get items with filter\nSP.getItems('Documents', { $top: 5, $select: 'Id,Title' })\n  .then((items) => console.log(items))\n  .catch(console.error);\n\n// Each request uses the same singleton instance\n// Set base URL via environment variables or constructor:\n// new SP({ baseUrl: 'https://your-sharepoint-site' })","lang":"javascript","description":"Demonstrates importing the singleton, creating a list item, and querying items with OData parameters."},"warnings":[{"fix":"import { SharePoint } from 'sp-service'; const sp = new SharePoint({ baseUrl: '...' });","message":"Default export is a singleton instance, not a class. Use new SharePoint() only on the named class export.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Set VITE_APP_URL or pass baseUrl in constructor: new SharePoint({ baseUrl: 'https://your-site' })","message":"Base URL is required. Falls back to VITE_APP_URL or VUE_APP_URL environment variable. If neither set, requests may fail.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Check the latest API by inspecting the index.js source.","message":"Class-based refactor in December 2021 may have changed method signatures. Refer to source code for exact parameters.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure user is authenticated to SharePoint site before using this module.","message":"Automatic X-RequestDigest handling requires a valid SharePoint session. The module does not handle authentication itself.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.0.10':40 '2021':45 'api':23 'automat':50 'axio':48,64 'bin':36 'built':46 'class':16 'comment':32 'comprehens':14 'configur':63 'current':38 'custom':70 'decemb':44 'default':68 'differenti':57 'easili':11 'endpoint':10 'file/folder':25 'handl':31,55 'help':6 'includ':24,49 'instanc':59,71 'interact':18 'interceptor':65 'item':28 'javascript':15,72 'key':56 'last':41 'list':27 'major':42 'manag':26 'manipul':29 'modul':4 'oper':37 'pre':62 'pre-configur':61 'provid':12 'recycl':35 'requestdigest':53 'rest':9,22 'servic':3 'sharepoint':8,20 'singleton':58 'sp':2 'sp-servic':1 'support':66 'token':54 'updat':43 'use':7 'user/group':30 'version':33,39 'x':52 'x-requestdigest':51","created_at":"2026-06-07T17:01:37.763910+00:00","updated_at":"2026-06-07T17:01:37.763910+00:00","problems":[{"fix":"Use default import directly: import SP from 'sp-service'; SP.createItem(...)","cause":"Using the default import as a class with 'new' operator or destructuring incorrectly.","error":"Cannot read properties of undefined (reading 'createItem')"},{"fix":"Set VITE_APP_URL or VUE_APP_URL environment variable, or pass baseUrl to constructor.","cause":"Missing base URL — neither passed in constructor nor set via environment variable.","error":"URL is not defined (or similar base URL error)"},{"fix":"Run 'npm install axios' alongside 'sp-service'.","cause":"Axios not installed as a peer dependency.","error":"axios is not defined (or similar module errors)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/aonghas/sp-service#readme","github":"https://github.com/aonghas/sp-service","docs":null,"changelog":null,"pypi":null,"npm":"sp-service","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}