The official Strapi SDK for JavaScript, available for browsers or Node.js backends.
Install
npm install strapi-sdk-javascript
Start now
New instance
; const strapi = 'http://localhost:1337';
Authentications
Local
await strapi;
Providers
// Redirect your user to the provider's authentication page.windowlocation = strapi;
Once authorized, the provider will redirects the user to your app with an access token in the URL.
// Complete the authentication: (The SDK will store the access token for you)await strapi;
You can now fetch private APIs
const posts = await strapi;
Files management
Browser
const form = ;form;form;const files = await strapi;
Node.js
const FormData = ;const fs = ;const form = ;form;const files = await strapi;
API
Strapi(baseURL, storeConfig, requestConfig)
request(method, url, requestConfig)
register(username, email, password)
login(identifier, password)
forgotPassword(email, url)
resetPassword(code, password, passwordConfirmation)
getProviderAuthenticationUrl(provider)
authenticateProvider(provider, params)
setToken(token, comesFromStorage)
clearToken(token)
getEntries(contentTypePluralized, params)
getEntry(contentTypePluralized, id)
getEntryCount(contentTypePluralized, params)
createEntry(contentTypePluralized, data)
updateEntry(contentTypePluralized, id, data)
deleteEntry(contentTypePluralized, id)
searchFiles(query)
getFiles(params)
getFile(id)
upload(data)
requestConfig
Custom axios request configuration. See documentation
Resources
Roadmap
- GraphQL
- Attach/Detach entry relationship
- Real time with Socket.io
Credits
License
MIT