{"id":12086,"library":"strapi-sdk-javascript","title":"Strapi JavaScript SDK","description":"The `strapi-sdk-javascript` package provides a client library for interacting with a Strapi backend, offering methods for CRUD operations, local and provider-based authentication (Facebook, GitHub, Google, Twitter), and file management. It aims to simplify API calls by abstracting HTTP requests. However, the package is officially unmaintained and deprecated by the Strapi team, who recommend using a standard HTTP client (like Axios or Fetch) configured for your Strapi API endpoints instead. The current stable version is 0.3.3, but it has not seen active development or releases for a significant period. Its key differentiator as an 'official' SDK is now moot due to its abandonment, with the recommended approach being direct API interaction. Developers should be aware it does not support newer Strapi features or GraphQL roadmap items.","status":"abandoned","version":"0.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/strapi/strapi-sdk-javascript","tags":["javascript","typescript"],"install":[{"cmd":"npm install strapi-sdk-javascript","lang":"bash","label":"npm"},{"cmd":"yarn add strapi-sdk-javascript","lang":"bash","label":"yarn"},{"cmd":"pnpm add strapi-sdk-javascript","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for making HTTP requests to the Strapi API.","package":"axios","optional":false},{"reason":"Required for file uploads in Node.js environments.","package":"form-data","optional":true}],"imports":[{"note":"While CommonJS `require` might work in some environments, the official documentation and examples use ESM `import`. It's recommended to use ESM for modern JavaScript projects.","wrong":"const Strapi = require('strapi-sdk-javascript');","symbol":"Strapi","correct":"import Strapi from 'strapi-sdk-javascript';"},{"note":"Most interactions occur through methods on an instantiated `Strapi` object. There are no direct named exports for individual API methods.","symbol":"StrapiInstanceMethods","correct":"import Strapi from 'strapi-sdk-javascript';\nconst strapi = new Strapi('http://localhost:1337');\nawait strapi.login('user', 'pass');"},{"note":"The package ships with TypeScript types. For type-only imports in TypeScript, use `import type` to ensure it's removed during compilation.","symbol":"TypeDefinition","correct":"import type Strapi from 'strapi-sdk-javascript';"}],"quickstart":{"code":"import Strapi from 'strapi-sdk-javascript';\n\nconst STRAPI_BASE_URL = process.env.STRAPI_URL ?? 'http://localhost:1337';\nconst STRAPI_USERNAME = process.env.STRAPI_USERNAME ?? 'testuser';\nconst STRAPI_PASSWORD = process.env.STRAPI_PASSWORD ?? 'password';\n\nasync function runStrapiSdkExample() {\n  console.log(`Connecting to Strapi at: ${STRAPI_BASE_URL}`);\n  const strapi = new Strapi(STRAPI_BASE_URL);\n\n  try {\n    // Local authentication\n    console.log('Attempting local login...');\n    await strapi.login(STRAPI_USERNAME, STRAPI_PASSWORD);\n    console.log('Login successful! Token stored.');\n\n    // Fetch entries (e.g., 'posts')\n    const posts = await strapi.getEntries('posts');\n    console.log(`Fetched ${posts.length} posts:`, posts.map(p => p.title));\n\n    // Example: Create an entry (assuming 'articles' is a content type)\n    // const newArticle = await strapi.createEntry('articles', { title: 'SDK Test Article', content: 'Content from SDK' });\n    // console.log('Created new article:', newArticle);\n\n    // Example: Get entry count\n    const postCount = await strapi.getEntryCount('posts');\n    console.log(`Total posts count: ${postCount}`);\n\n  } catch (error) {\n    console.error('Error during Strapi SDK operations:', error.message);\n    if (error.response) {\n      console.error('Server response:', error.response.data);\n    }\n  }\n}\n\nrunStrapiSdkExample();","lang":"typescript","description":"This quickstart demonstrates how to instantiate the Strapi SDK, perform local user authentication, and fetch entries from a Strapi API, including error handling. It uses environment variables for configuration."},"warnings":[{"fix":"Migrate your application to use a generic HTTP client (e.g., Axios, Fetch API) to interact directly with your Strapi API endpoints. Consult the Strapi API documentation for endpoint structures and request formats.","message":"The `strapi-sdk-javascript` package is officially unmaintained and deprecated by the Strapi team. Using it in production is highly discouraged as it will not receive updates, security patches, or support for newer Strapi versions or features.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"If using Strapi v4, definitely do not use this SDK. Implement API interactions manually using a modern HTTP client, following Strapi v4's specific documentation.","message":"This SDK was primarily designed for Strapi v3 (beta.x and early v3 versions). It does not natively support Strapi v4's updated API structures, new authentication flows, or features like GraphQL which were part of the SDK's roadmap but never implemented.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Ensure `form-data` is explicitly installed and correctly used with `form.getHeaders()` when uploading files in Node.js. For modern API interactions, consider using libraries that abstract multipart/form-data creation more directly if not using `fetch` with native `FormData`.","message":"File upload functionality requires `form-data` in Node.js, and browser-specific `FormData` in the browser. The `upload` method's `headers` parameter for Node.js is specific to getting headers from `form-data` and can be a point of confusion if not handled correctly.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Understand the security implications of client-side token storage. Implement token refresh mechanisms or secure storage strategies if not relying solely on the SDK's default behavior, though for an abandoned SDK, custom handling is more robust.","message":"The SDK stores the JWT token locally (e.g., in localStorage in browsers). While convenient, developers must ensure proper security practices around token storage and expiration are followed, especially in single-page applications.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Double-check your `strapi.login('identifier', 'password')` credentials. Ensure the Strapi server is running and accessible. If already logged in, the token might have expired, requiring re-authentication or a token refresh (which the SDK does not provide automatically).","cause":"Authentication failed due to incorrect credentials, missing token, or an expired token when accessing protected routes.","error":"Error: Request failed with status code 401"},{"fix":"Verify that `const strapi = new Strapi('http://localhost:1337');` has been executed before calling any methods on `strapi`. Check the API section of the README to ensure the method name and parameters are correct.","cause":"Attempting to call methods on an uninitialized or incorrectly initialized `Strapi` object, or calling a method that doesn't exist on the `Strapi` instance.","error":"TypeError: strapi.getEntries is not a function"},{"fix":"Install `form-data` (`npm install form-data`) and explicitly `const FormData = require('form-data');` at the top of your Node.js file when performing file uploads.","cause":"Attempting to use `FormData` for file uploads in a Node.js environment without importing the `form-data` package.","error":"ReferenceError: FormData is not defined (in Node.js)"},{"fix":"Verify that the `baseURL` passed to `new Strapi(baseURL)` is correct and the Strapi server is running. If in a browser, check the browser console for CORS errors and ensure your Strapi server is configured to allow requests from your frontend's origin.","cause":"The SDK could not connect to the specified Strapi server URL. This might be due to an incorrect `baseURL`, the Strapi server not running, or network connectivity issues (e.g., CORS policy blocking requests from a browser).","error":"Error: Network Error (axios)"}],"ecosystem":"npm"}